Developer Documentation

Direct-Sold & House Ads

Integrating with an AI coding agent?
Point Claude Code, Cursor, or Codex at https://adsrouter.ai/llms-full.txt — it contains every endpoint, auth header, JSON schema, Koah bridge snippet, and beacon rule in one self-contained file.

AdsRouter includes a full first-party ad server for your own direct-sold sponsors (scope: "direct") and house promotions (scope: "house"), plus optional access to operator-managed AdsRouter Network campaigns (scope: "network").

Campaign Scopes

ScopeManaged ByTypical Position in Waterfall
directPublisher (scoped to your workspace)Top priority — honor sponsor IO commitments first
networkAdsRouter Network (operator-managed advertisers)Middle — competes alongside or ahead of 3rd-party networks
housePublisher (scoped to your workspace)Bottom fallback — promote your Pro plan or newsletter on unfilled turns

Targeting Rules (targeting JSON)

Every campaign evaluates targeting deterministically against the incoming POST /v1/ad request. Omitted or empty arrays match all traffic.

{
  "property_ids": ["prop-uuid-1"],
  "placements": ["chat_below_answer", "sidebar_card"],
  "countries": ["US", "CA", "GB"],
  "device_types": ["mobile", "desktop"],
  "platforms": ["ios", "android", "web"],
  "oses": ["iOS", "macOS"],
  "include_keywords": ["running", "marathon", "sneakers"],
  "exclude_keywords": ["injury", "lawsuit", "medical"]
}
  • Keyword matching: Case-insensitive word-boundary matching across recent messages[] and assistant_response. Any hit in exclude_keywords disqualifies the campaign immediately; if include_keywords is non-empty, at least one keyword must match.
  • Pluggable ranker: Eligible candidates are scored by lib/engine/ranker.js (priority + weight + keyword relevance by default, with a clean hook for periodic async/LLM re-ranking weights).

Dayparting (IANA Timezones)

Restrict delivery to specific days of the week (0 = Sunday … 6 = Saturday) and 24-hour windows in any IANA timezone (e.g. America/New_York, Europe/London):

{
  "timezone": "America/New_York",
  "windows": [
    { "days": [1, 2, 3, 4, 5], "start_hour": 9, "end_hour": 18 }
  ]
}

Pacing & Delivery Caps

  • even_pacing (default): Smooths delivery linearly across starts_at → ends_at toward cap_total / cap_daily with a controlled burst allowance so a sponsor's budget does not exhaust at 12:05 AM.
  • traffic_pct: Deterministically samples a percentage (0–100) of eligible requests.
  • asap: Delivers as fast as eligible traffic arrives until cap_daily or cap_total is hit.

Creative Schema

{
  "headline": "Ship faster with Acme Cloud",
  "description": "Zero-config Postgres and edge workers starting at $0.",
  "image_url": "https://cdn.acme.dev/banner.png",
  "cta": "Start free",
  "brand_name": "Acme Cloud",
  "favicon_url": "https://cdn.acme.dev/icon.png",
  "click_url": "https://acme.dev/?utm_source=adsrouter",
  "sponsored_label": "Sponsored"
}