Bid Request (v2)
curl --request POST \
--url https://ssp.thrad.ai/api/v2/bid-request \
--header 'thrad-api-key: <api-key>'import requests
url = "https://ssp.thrad.ai/api/v2/bid-request"
headers = {"thrad-api-key": "<api-key>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {'thrad-api-key': '<api-key>'}};
fetch('https://ssp.thrad.ai/api/v2/bid-request', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://ssp.thrad.ai/api/v2/bid-request",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"thrad-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://ssp.thrad.ai/api/v2/bid-request"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("thrad-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://ssp.thrad.ai/api/v2/bid-request")
.header("thrad-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://ssp.thrad.ai/api/v2/bid-request")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["thrad-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_bodyAPI Reference
Bid Request (v2)
One request, one auction, one strict contract.
POST
/
api
/
v2
/
bid-request
Bid Request (v2)
curl --request POST \
--url https://ssp.thrad.ai/api/v2/bid-request \
--header 'thrad-api-key: <api-key>'import requests
url = "https://ssp.thrad.ai/api/v2/bid-request"
headers = {"thrad-api-key": "<api-key>"}
response = requests.post(url, headers=headers)
print(response.text)const options = {method: 'POST', headers: {'thrad-api-key': '<api-key>'}};
fetch('https://ssp.thrad.ai/api/v2/bid-request', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://ssp.thrad.ai/api/v2/bid-request",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"thrad-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://ssp.thrad.ai/api/v2/bid-request"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("thrad-api-key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://ssp.thrad.ai/api/v2/bid-request")
.header("thrad-api-key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://ssp.thrad.ai/api/v2/bid-request")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["thrad-api-key"] = '<api-key>'
response = http.request(request)
puts response.read_bodyHeaders
| header | |
|---|---|
Authorization | required. Bearer <your key>. Its environment (staging or production) decides how ads are served. It is a secret: call from your server, never ship it in a page or an app. |
Content-Type | required. application/json |
Request
{
"version": "2.0",
"id": "req_123",
"context": {
"id": "chat_1",
"flow": "chat",
"chat": {
"messages": [
{
"role": "user",
"content": "What shoes are good for trail running?",
"timestamp": 1790000000
},
{
"role": "assistant",
"content": "Look for grip, drainage and a rock plate.",
"timestamp": 1790000004
}
],
"turn_number": 2
},
"summary": "User is shopping for trail running shoes.",
"keywords": ["trail running shoes", "running gear"]
},
"opportunities": [
{
"id": "opp_1",
"formats": [
{
"type": "card",
"assets": {
"title": {
"max_chars": 90
},
"description": {
"max_chars": 140
},
"image": {}
}
},
{
"type": "carousel",
"assets": {
"title": {
"max_chars": 40
},
"image": {}
}
}
]
}
],
"user": {
"id": "user_123",
"age_range": "25-34",
"extended_ids": {
"emails_sha256": [
"6db61e6dcbcf2390e4a46af426f26a133a3bee45021422fc7ae86e9136f14110"
],
"phone_numbers_sha256": [
"758fbf68945f21c416814c539ab578876c8d98fb69e6da692def92cd52417fe0"
]
},
"summary": "Runner, hikes on weekends, buys mid-range gear."
},
"device": {
"user_agent": "AcmeChat/4.2.0 (iPhone; iOS 18.0; Scale/3.00)",
"ip": "8.8.8.8",
"ids": {
"idfa": "6D92078A-8246-4BA4-AE5B-76104861E7DC"
},
"model": "iPhone16,2",
"os": "ios",
"type": "mobile",
"language": "en-US",
"geo": {
"country": "US",
"region": "CA",
"city": "San Francisco",
"timezone": "America/Los_Angeles"
}
},
"surface": {
"type": "app",
"store": "apple",
"bundle": "com.acme.chat",
"store_url": "https://apps.apple.com/app/id123456789"
},
"privacy": {
"gdpr_applies": true,
"tcf": "CPz4xQAPz4xQAAGABCENBJCgAP_AAH_AAAqIHNtd",
"us_privacy": "1YNN",
"att_status": "authorized"
}
}
version ("2.0"), id, opportunities. Everything else is optional. Unknown fields are refused.
context
| field | |
|---|---|
id | Optional. Your chat id: one per conversation. If supplied, 1–100 characters and not blank. |
flow | what the user is doing: chat, image.generate, image.edit, image.detect, video.generate, video.edit. |
chat.messages[] | role (user or assistant), content, optional timestamp in Unix seconds. At least one user message. Mask PII. |
chat.turn_number | how many turns so far. |
summary | a non-blank description of the conversation so far: what the user is trying to do and what they’ve asked for. Up to 10,000 characters. |
keywords | 1–8 non-blank topics, each 1–50 characters. E.g. ["running shoes", "marathon training"]. Empty lists, empty strings, and whitespace-only entries are refused. |
messages, a summary, keywords, or any mix of them. Send everything you have: more context means better matches. Context doesn’t guarantee an ad: targeting and campaign budgets still apply.
Send context.id when you have one. Without it you still get ads, but we can’t pace ads or avoid repeats within a conversation.
Without messages, send chat.turn_number if you can. Otherwise ad-offset rules (“no ad before turn N”) can’t apply.
None of them means the ad is shown before the conversation starts. That request serves card only: asking for any other format is refused with 400, and so is a turn_number above 0 without a conversation.
opportunities
| field | |
|---|---|
id | your id for this opportunity: the place in your UI where an ad can show. Echoed back. |
formats[].type | card, carousel or poll. |
formats[].assets | required. The parts this opportunity can draw, below. |
| format | assets | |
|---|---|---|
card | title | required. Optional max_chars (30 or more). |
card | description | required. Optional max_chars. |
card | image | optional. Leave it out for a text-only card with the advertiser’s logo. |
carousel | title | required. Optional max_chars. |
carousel | image | required. |
poll | question | required. Optional max_chars. |
poll | options | required. Optional max_chars. |
image takes no options: send {}. Every image is square (1:1), and there is no minimum size.
A listed part may still be missing from a bid, for example a card with no photo. A part you leave out never comes back. A card may also carry a cta, which you can’t list.
Only the first opportunity is auctioned. The rest come back with no_bid_reason: "multi_slot_not_supported".
user
| field | |
|---|---|
id | Optional. Your stable, anonymous id for this person. If supplied, 1–100 characters and not blank. No PII. |
age_range or age | one, never both. age_range is one of 0-12 13-17 18-24 25-34 35-44 45-54 55-64 65+. Under-18 users get no ads. |
extended_ids.emails_sha256 | up to 3 hashed emails: trim, lowercase, then SHA-256. |
extended_ids.phone_numbers_sha256 | up to 3 hashed phones: digits only with country code, no + or leading zeros, then SHA-256. |
summary | what you know about this person, in a line: profession, interests, current situation, preferences. Any shape; e.g. Software engineer, into trail running, training for a first marathon, prefers mid-range brands. No names, contact details or identifiers. |
user block can be omitted. Without user.id, contextual matching still works, as does chat pacing when context.id is supplied. User-based retargeting, campaign repeat limits, per-user abuse limits, and user-linked transcript storage are skipped. We do not generate an ID. Age checks still apply if an age is supplied without an ID.
Hashes are lowercase 64-character hex. Anything else is refused, so an unhashed address never reaches us. See User & Chat Identification for the exact hashing steps.
device
The end user’s device, never your server. Every field is optional, and the whole block can be left out.
Always send
geo.country. Without the user’s country, every campaign that targets a country is skipped. ip is only the fallback.Always send
type and os. Without them, device-targeted campaigns can’t match. user_agent is only the fallback.| field | fallback if missing | |
|---|---|---|
geo.country | The most important field. ISO 3166-1 alpha-2, uppercase: US. Almost every campaign targets a country. Required before any other geo field. | looked up from ip |
type | mobile tablet desktop. Needed for any campaign that targets a device type. | read from a browser user_agent. An app’s own user agent doesn’t tell us the device. |
os | android ios windows macos chromeos linux. Needed for any campaign that targets an OS. | read from user_agent, only when it names the OS |
ip | The end user’s public IPv4 or IPv6 address, never your server’s. Used for fraud checks and sent to demand partners. Exactly what is accepted is under device.ip below. | none |
user_agent | The end user’s user agent, never your server’s. Up to 1,000 characters. Demand partners bid less without it, and we compare it with the user agent on the tracker calls. | none |
| field | |
|---|---|
ids.idfa / ids.gaid | the advertising ID on iOS / Android. Send one, never both. It must match os when you send os: idfa with ios, gaid with android. The all-zero ID is refused: omit the field instead. Whether we pass it on depends on privacy.att_status and privacy.limit_ad_tracking. |
model | e.g. iPhone16,2. |
os_version | Optional actual OS version, such as "14". String of 1–64 characters, without control characters. Separate from os; do not use a version as the OS family. |
language | BCP 47 with the shortest language code: en-GB, fil. Not en_GB, not eng. |
geo.region, geo.city | for narrower targeting. Only read when you send geo.country. |
geo.timezone | IANA: America/Los_Angeles. |
geo.zip | postal code. |
geo.latitude, geo.longitude | the user’s location. Send both or neither. |
geo.accuracy_meters | how precise that location is. Only with latitude and longitude. |
screen.width, screen.height | the whole display in physical pixels, in portrait. See Screen and network. |
screen.pixel_ratio | physical pixels per point or CSS pixel, 0.5–5. |
manufacturer | lowercase: apple, samsung. |
connection_type | ethernet wifi cellular cellular_2g cellular_3g cellular_4g cellular_5g. |
mccmnc | the mobile operator of the user’s SIM card, as country code + network code: "310-260" is T-Mobile US. |
geo out and we look the user up from device.ip. Leave both out and the user’s country is unknown.
No header describes the end user. X-Forwarded-For, User-Agent and Accept-Language on your request are ignored: from your server they describe your server.
device.ip
Send exactly one bare address: IPv4 in dotted form (8.8.8.8) or IPv6 in any standard notation (2606:4700:4700::1111). Anything else is a 400 invalid_request naming device.ip:
| sent | refused because |
|---|---|
8.8.8.8, 10.0.0.1 | a list. Send the end user’s address only. |
8.8.8.8:443 | a port |
8.8.8.8/32 | a range |
[2606:4700::1111] | brackets |
" 8.8.8.8" | surrounding spaces |
08.8.8.8 | a leading zero |
| range | what it is |
|---|---|
0.0.0.0/8 | this-network |
10.0.0.0/8 | private |
100.64.0.0/10 | carrier-grade NAT |
127.0.0.0/8 | loopback |
169.254.0.0/16 | link-local |
172.16.0.0/12 | private (172.16.x to 172.31.x only; 172.32.x is public) |
192.0.0.0/24 | IETF protocol assignment |
192.0.2.0/24 | documentation |
192.168.0.0/16 | private |
198.18.0.0/15 | benchmarking |
198.51.100.0/24 | documentation |
203.0.113.0/24 | documentation |
224.0.0.0/4 | multicast |
240.0.0.0/4 | reserved, including 255.255.255.255 |
::/128 | unspecified |
::1/128 | loopback |
::ffff:0:0/96 | IPv4-mapped. Send the IPv4 address itself. |
100::/64 | discard-only |
2001:db8::/32 | documentation |
fc00::/7 | unique local (private) |
fe80::/10 | link-local |
ff00::/8 | multicast |
The documentation ranges (
192.0.2.x, 198.51.100.x, 203.0.113.x, 2001:db8::) are what examples and test fixtures usually use, so they are the ones most often hit by accident. To test from your laptop, send your own public IP.Screen and network
screen, manufacturer, connection_type and mccmnc describe the device’s hardware and network. Leave a field out when you can’t read it; never estimate it. A value outside the rules below is a 400 invalid_request.
screen is the whole physical display, not the window or the safe area, measured in portrait. width is the short edge and height the long one, however the device is held, so width > height is refused. Both are required inside screen, as whole numbers of physical pixels from 100 to 20,000. pixel_ratio is optional, from 0.5 to 5.
manufacturer is lowercase, 1–100 characters, with no surrounding spaces: apple, samsung. Anything with an uppercase letter is refused.
connection_type is the network the device is on now. Send cellular when you can’t tell the generation; never guess one. On a VPN or tethering, leave it out.
mccmnc says which mobile operator issued the user’s SIM card. Every operator has a fixed code made of two parts: the MCC (Mobile Country Code, three digits, the country) and the MNC (Mobile Network Code, two or three digits, the operator in that country). Send them joined by a hyphen. "310-260" is T-Mobile US, "234-15" is Vodafone UK. It must match ^[2-7]\d{2}-\d{2,3}$, and it is a string, never a number. It is the SIM’s home operator, so it doesn’t change when the user roams.
surface
Where the ad is shown: an app, a web page or a browser extension. Optional, but once you send it, type is required along with the fields that type needs.
{
"surface": {
"type": "app",
"store": "apple",
"bundle": "com.acme.chat",
"store_url": "https://apps.apple.com/app/id123456789"
}
}
{
"surface": {
"type": "web",
"domain": "acme.com"
}
}
{
"surface": {
"type": "extension",
"store_url": "https://chromewebstore.google.com/detail/acme/abcdefghijklmnopabcdefghijklmnop"
}
}
type needs its own fields, and refuses the fields another type owns. Anything missing or extra is a 400.
type | required | refused |
|---|---|---|
app | store, bundle, store_url | domain |
web | domain | store, bundle, store_url |
extension | store_url | store, bundle, domain |
| field | |
|---|---|
type | required when you send surface. app, web or extension (a browser extension). |
store | apple google amazon samsung huawei microsoft. Must fit device.os. |
bundle | Apple bundle ID or Google package name. |
store_url | the app’s or extension’s store page, https:// only. |
domain | the site’s bare lowercase domain: acme.com. Web only. A staging key may also send localhost while you develop locally; a production key gets HTTP 400 for it. |
container | Optional browser, webview or native. Describes the container that displays the ad and handles its navigation. browser requires type: web or extension; native requires type: app; webview supports any type. Separate from the staging/production environment selected by your key. |
capabilities | Optional object declaring navigation support using the booleans below. |
store must fit device.os: apple with ios or macos; google, amazon, samsung or huawei with android; microsoft with windows.
Optional mobile navigation declarations
Declare only support your publisher client actually implements. Missing declarations mean unknown; explicitfalse means unsupported. They do not grant tracking permission, establish attribution or activate a store-handoff route. No additional consent or advertising-ID field is required for these declarations.
surface.capabilities member | Meaning |
|---|---|
external_browser | The client can open an external browser from the ad action. |
app_links | A user tap can open OS-managed Android App Links or iOS Universal Links, with HTTPS fallback. |
custom_schemes | The client can attempt approved custom URL schemes and handle a bounded fallback. |
android_store_intent | The client can attempt an approved Android store intent and preserve the supplied fallback. true requires device.os: android. |
apple_signed_presentation | The native source app implements the separately specified Apple signed-presentation helper. true requires device.os: ios and surface.container: native. |
capabilities must contain at least one known member, with JSON boolean values (true or false). Unknown members and incompatible platform combinations are refused. Keep the returned action URL and tracker methods unchanged; capability declarations do not authorize rewriting them.
privacy
The consent signals you collected for this user. Every field is optional. Leaving one out means unknown, not “no”.
{
"privacy": {
"gdpr_applies": true,
"tcf": "CPz4xQAPz4xQAAGABCENBJCgAP_AAH_AAAqIHNtd",
"us_privacy": "1YNN",
"att_status": "denied"
}
}
| field | |
|---|---|
gdpr_applies | whether GDPR applies to this user: true or false. |
tcf | the IAB TCF consent string from your CMP, as-is. |
us_privacy | the IAB CCPA string: 1, then three of Y, N or -, e.g. 1YNN. |
att_status | iOS only. The App Tracking Transparency status: authorized, denied, restricted or not_determined. Anything but authorized means we don’t pass the advertising ID on. Refused when device.os is set to anything but ios. |
limit_ad_tracking | Every OS but iOS. The platform’s limit-ad-tracking flag, true or false (on Android, isLimitAdTrackingEnabled()). true means we don’t pass the advertising ID on. Refused with device.os: ios, where att_status says the same thing. |
Response
{
"version": "2.0",
"id": "req_123",
"currency": "USD",
"opportunities": [
{
"id": "opp_1",
"bids": [
{
"id": "c82b381f-7ff2-4607-a759-aef101072c18",
"price_cpm": 4.74,
"currency": "USD",
"ttl_ms": 3660000,
"advertiser": {
"name": "Trailhead Outfitters",
"domain": "trailhead.example",
"logo_url": "https://img.logo.dev/trailhead.example"
},
"trackers": [
{
"event": "viewable",
"method": "pixel",
"url": "https://ssp.thrads.ai/api/v1/tracking/ssp-view?token=…"
},
{
"event": "rendered",
"method": "pixel",
"url": "https://dsp.example/imp?id=…"
}
],
"win_url": "https://ssp.thrads.ai/api/v2/auction/win?token=…",
"loss_url": "https://ssp.thrads.ai/api/v2/auction/loss?token=…&reason=${AUCTION_LOSS}",
"format": "card",
"assets": {
"title": "Trail-tested shoes for long runs",
"description": "Lightweight, weatherproof, made to last 800+ miles.",
"cta": "Shop Now",
"image": {
"url": "https://media.thrads.ai/shoe.png"
}
},
"actions": {
"click_url": "https://dsp.thrad.ai/api/v1/tracking/redirect?token=…",
"feedback_url": "https://dsp.thrad.ai/api/v1/tracking/feedback?token=…"
}
}
]
}
]
}
| field | |
|---|---|
id, opportunities[].id | echoed from your request. |
bids | empty means no bid. |
no_bid_reason | present only when bids is empty. See No-bid reasons. |
price_cpm, currency | the price per 1,000 impressions. |
ttl_ms | how long the bid is valid. Don’t render it after that. |
advertiser | always present. Show it as “Sponsored by name”. |
trackers | fire every one, each at its event: rendered when you draw the ad, viewable once it is 50% on screen for 1 second, and click on the user’s advertiser-action click when returned. See Count the impression. |
format, assets | what to draw. |
actions | URLs to call: click_url on click, feedback_url for user feedback. |
win_url, loss_url | always present. You only call them if you run your own auction. See Auction notices. |
assets.items, each with title, image, optional price (amount as a string, currency) and its own actions.click_url. It has no bid-level click_url.
{
"format": "carousel",
"assets": {
"items": [
{
"title": "Trail Shoe 1",
"image": {
"url": "https://media.thrads.ai/shoe-1.png"
},
"price": {
"amount": "149.00",
"currency": "USD"
},
"actions": {
"click_url": "https://dsp.thrad.ai/api/v1/tracking/redirect?token=one"
}
}
]
},
"actions": {
"feedback_url": "https://dsp.thrad.ai/api/v1/tracking/feedback?token=…"
}
}
assets.question, 2 or more assets.options (each id and text) and an optional cta. Its actions always carry a vote_url. When the user picks an option, POST {"option_id": "<id>"} to vote_url: see Poll Voting. click_url, when present, is for the cta.
{
"format": "poll",
"assets": {
"question": "What are you training for?",
"options": [
{ "id": "0", "text": "A first 10k" },
{ "id": "1", "text": "A marathon" },
{ "id": "2", "text": "An ultra" }
],
"cta": "Shop trail shoes"
},
"actions": {
"vote_url": "https://ssp.thrads.ai/api/v1/tracking/sponsored-polls/vote?token=…",
"click_url": "https://dsp.thrad.ai/api/v1/tracking/sponsored-polls/cta?token=…",
"feedback_url": "https://dsp.thrad.ai/api/v1/tracking/feedback?token=…"
}
}
No-bid reasons
| value | |
|---|---|
no_fill | No ad matched this request. Most no-bids are this. |
frequency_capped | Too early in the chat, too soon after the last ad, or the chat already had its share of ads. Retrying the same turn won’t help. |
unsafe_content | The conversation is not suitable for ads. |
timeout | Demand did not answer in time. |
technical_error | Something failed on our side or a demand partner’s. |
multi_slot_not_supported | Only the first opportunity is auctioned. |
no_fill.
Auction notices
Every bid comes with a
win_url and a loss_url. You don’t have to call them. Call them only if you run your own auction on your side (header bidding), where our bid competes with bids from other SSPs. If you just show our ad, skip this section: the trackers are all you need.| call it when | |
|---|---|
win_url | our bid won and you will render it. |
loss_url | our bid did not serve, for any reason. First replace ${AUCTION_LOSS} with a code below. |
204.
| code | meaning |
|---|---|
102 | lost to a higher bid |
100 | below your floor |
2 | expired before you could render |
1 | your internal error |
3 | our response was invalid |
204 | wrong format for the opportunity |
205 | advertiser excluded |
208 | category excluded |
500 | you chose not to show an ad at all |
500.
Errors
{
"version": "2.0",
"id": "req_123",
"error": {
"code": "invalid_request",
"message": "The request does not match the protocol",
"fields": [
"opportunities: Field required"
]
}
}
code, never on message. fields appears only for invalid_request.
| status | code |
|---|---|
400 | invalid_request |
401 | missing_api_key, invalid_api_key |
403 | frontend_integration_unsupported (your key is registered for a browser integration), forbidden |
404 | not_found |
429 | rate_limited |
