Endpoints
Group Ads
One ad shown to multiple viewers in a group chat.
POST
Serve a single contextual ad to multiple users in a group chat. The engine runs one auction and generates one ad creative, then returns per-viewer impression and click URLs so each user’s engagement is individually tracked and billed.
Null fields are omitted from the response.
Maximum 5 viewers per request. Each viewer gets a unique
impUrl and clickUrl for individual attribution.Headers
Your Gravity API key. Format:
Bearer <key>Body
Session identifier. Used for frequency capping and reporting. Typically the group chat ID.
Conversation history from the group chat. Array of
{role, content} message objects. The engine uses the last few messages for contextual matching.Single placement for the group chat ad slot.
| Field | Type | Description |
|---|---|---|
placement | string | Placement type — use "group_chat". |
placement_id | string | Your slot identifier for this group chat. |
Array of viewers in the group chat (1–5). Each viewer gets a unique impression/click URL in the response.
| Field | Type | Required | Description |
|---|---|---|---|
email_hash | string | Yes | SHA-256 hex digest of the viewer’s email (email.strip().lower()). Must be exactly 64 characters. |
user | object | No | User context (same shape as the contextual endpoint user field). |
device | object | No | Device signals — ip, ua, country, etc. Used for bot detection and geo targeting per viewer. |
Optional. Arbitrary metadata forwarded to the engine for targeting and analytics.
Optional. Array of topic strings to exclude from matching.
Optional. Minimum relevancy threshold, 0.0–1.0. Falls back to publisher baseline when omitted.
Optional. When
true, returns test creative and skips billing/metrics.Response
On a successful match the endpoint returns HTTP200 with a single ad object and per-viewer tracking URLs:
Response fields
| Field | Type | Description |
|---|---|---|
adText | string | Generated ad copy, contextually matched to the conversation |
title | string | Product/campaign title |
brandName | string | Advertiser brand name |
cta | string | Call to action text |
url | string | Landing page URL |
favicon | string | Brand favicon URL |
viewers | array | Per-viewer tracking URLs (see below) |
Viewer tracking object
| Field | Type | Description |
|---|---|---|
email_hash | string | Echoes back the viewer’s email hash |
impUrl | string | Impression pixel URL — fire when the ad is visible to this viewer |
clickUrl | string | Tracked click URL — use for ad links shown to this viewer |
How it works
- One auction — the conversation context goes through a single auction to find the best-matching campaign.
- One ad generation — a single ad creative is generated using the publisher’s configured prompt template and model.
- Per-viewer fan-out — each viewer gets a unique tracking URL pair (
impUrl+clickUrl) with their own click ID (grclid). Bot viewers (detected by user agent) are excluded from the response. - One engine event — a single engine event is logged with per-viewer data stored in the request context.
No ad available
When no ad matches the context (or the request times out, hits a bot filter for all viewers, or encounters an unrecoverable error), the endpoint returns HTTP204 No Content with an empty body. Hide the ad slot in this case.