Skip to main content
{
  "userId": "user_123",
  "request_type": "contextual",
  "chatId": "chat_456",
  "nAdsBefore": 2,
  "messages": [
    {
      "role": "user",
      "content": "Looking for running shoes",
      "timestamp": "2024-11-23T10:00:00Z"
    },
    {
      "role": "assistant",
      "content": "What's your budget?",
      "timestamp": "2024-11-23T10:00:15Z"
    }
  ],
  "ad_formats": ["sponsored_message", "sponsored_carousel"],
  "prefetched": true,
  "request_id": "req_abc123",
  "country_code": "US",
  "region": "California",
  "city": "San Francisco",
  "device": "mobile",
  "timezone": "America/Los_Angeles",
  "config": {
    "max_headline_chars": 100,
    "image_enabled": true
  }
}
{
  "data": {
    "bid": 7.50,
    "bidId": "bid_abc123"
  }
}
Implementation Required: Your DSP must implement this endpoint on your own server. The SSP at ssp.thrads.ai will send POST requests to your configured DSP endpoint URL.

Authorization

Authorization
string
required
Bearer token for authentication. Format: Bearer your-api-key

Headers

Content-Type
string
required
Must be application/json
X-Forwarded-For
string
required
End-user’s IP address. First hop is the real user IP. Required on every bid request — use for geolocation, fraud detection, or frequency capping. The resolved country_code / region / city body fields are also provided as a convenience.
User-Agent
string
required
End-user’s device/browser string. Required on every bid request — use for device targeting, creative optimisation, or fraud detection.

Body

userId
string
required
Unique user identifier. Use anonymous UUIDs (e.g., user_a1b2c3d4-...). Do not use email or name.
request_type
string
required
Pipeline selector. One of:
  • "contextual" — in-chat ad. chatId and messages are required.
  • "opener" — pre-chat ad shown before the conversation starts. chatId and messages are not sent.
Defaults to "contextual" if omitted.
chatId
string
Conversation identifier. One unique ID per conversation, not per user. Reset when user starts a new chat.Required when request_type=contextual. Not sent for openers.
nAdsBefore
integer
Number of ads shown before this request in the current conversation. Added by SSP from cache. Contextual only.
messages
array
Conversation history. Must contain at least 2 messages, alternating between user and assistant roles, ending with a user message followed by an assistant message.Required when request_type=contextual. Not sent for openers (no conversation exists yet).
ad_formats
string[]
Ad formats the publisher can render. Your DSP must pick one from this list when bidding and identify it in the bid response (ad_data.ad_format). If omitted, assume ["sponsored_message"].Allowed values per request_type:
  • contextual: "sponsored_message", "sponsored_carousel"
  • opener: "sponsored_message", "sponsored_carousel"
prefetched
boolean
true when the publisher is requesting an ad before the assistant reply is shown (pre-fetch). false when the ad is requested after the reply has already been displayed. Useful for tuning latency expectations and creative relevance.
request_id
string
Optional request identifier for distributed tracing when called from SSP. Used for correlation across services.
country_code
string
required
ISO 3166-1 alpha-2 country code (e.g., "US", "GB"). Derived from IP geolocation.
region
string
State or region name (e.g., "California"). Derived from IP geolocation.
city
string
City name (e.g., "San Francisco"). Derived from IP geolocation.
device
string
required
Device type. Possible values: "mobile", "desktop", "tablet".
timezone
string
required
User’s timezone in IANA format (e.g., "America/Los_Angeles").
config
object
Publisher creative constraints. Your DSP should respect these when generating the ad.
Placement contract: every sponsored_message creative must declare a placement field — "image" (hero product photo) or "text" (advertiser logo + copy, no hero image). Each placement requires a matching URL: placement="image" needs image_url, placement="text" needs logo_url. Bids that omit placement or supply the wrong URL are rejected (dsp_missing_placement / dsp_invalid_image_bid / dsp_invalid_text_bid). See Ad Formats for the full contract.
{
  "userId": "user_123",
  "request_type": "contextual",
  "chatId": "chat_456",
  "nAdsBefore": 2,
  "messages": [
    {
      "role": "user",
      "content": "Looking for running shoes",
      "timestamp": "2024-11-23T10:00:00Z"
    },
    {
      "role": "assistant",
      "content": "What's your budget?",
      "timestamp": "2024-11-23T10:00:15Z"
    }
  ],
  "ad_formats": ["sponsored_message", "sponsored_carousel"],
  "prefetched": true,
  "request_id": "req_abc123",
  "country_code": "US",
  "region": "California",
  "city": "San Francisco",
  "device": "mobile",
  "timezone": "America/Los_Angeles",
  "config": {
    "max_headline_chars": 100,
    "image_enabled": true
  }
}
{
  "data": {
    "bid": 7.50,
    "bidId": "bid_abc123"
  }
}

Response

Additional fields (such as requestId, timestamp, status, message, etc.) are allowed in the response and will be ignored by the SSP.
data
object
required
Response data payload. Must contain bid and bidId when submitting a bid. Return empty object {} for no-bid.
error
string
Error message when the request fails. Only present on error responses.
Pre-rendered ad_data validation is strict. The SSP validates ad_data against the exact render response schema (extra="forbid"). Unknown fields will cause the bid to be rejected. Required fields: headline, description, url. Allowed optional fields include view_url and feedback_url. If you include ad_data, the render endpoint (/render-ad) is never called for that bid — make sure the ad creative is complete.

Status Codes

Status CodeMeaningScenario
200 OKSuccessBid generated successfully or DSP chose not to bid
400 Bad RequestInvalid inputMalformed request body or missing required fields
401 UnauthorizedAuthentication failedMissing or invalid Authorization header
429 Too Many RequestsRate limit exceededPublisher exceeded request quota
500 Internal Server ErrorServer errorException during auction execution, database failure, or service unavailable