Developer Documentation

Management REST API

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.

Programmatically provision properties, manage direct-sold and house campaigns, store encrypted BYOK network credentials, update mediation waterfalls, and query reporting — all scoped to your workspace under https://api.adsrouter.ai/v1/manage.

Authentication & Management API Keys

Management API endpoints are strictly separated from runtime ad serving. Do not use ar_sec_ property secrets here — create a workspace-scoped Management API Key (prefixed ar_mgmt_) in Dashboard → API Keys.

  • Dual auth support: Pass your key in the Authorization: Bearer ar_mgmt_... header (recommended for servers and scripts) or as a ?api_key=ar_mgmt_... query parameter (handy for MCP clients and webhooks).
  • Zero-downtime rotation: Rotating a key in the dashboard issues a new plaintext key (shown once) while keeping the previous key valid for a 24-hour grace window.
  • Instant revocation: Revoking a key immediately returns 403 Forbidden on all subsequent requests.
  • Audit trail: Every mutating call is recorded in ar_audit_logs with actor_type: "api".
MethodFormatNotes
Header (recommended) Authorization: Bearer ar_mgmt_... Checked first. Keeps credentials out of URL logs.
Querystring ?api_key=ar_mgmt_... Fallback when custom headers are unavailable.

Properties

Method & PathDescription
GET /v1/manage/propertiesList all properties in your workspace.
POST /v1/manage/propertiesCreate a property (name, kind, domain, app_id, allowed_origins, test_mode, default freq caps). Returns { property, secret } with the one-time ar_sec_ secret.
GET /v1/manage/properties/:idFetch a single property by UUID.
PATCH /v1/manage/properties/:idUpdate name, domain/app_id, allowed_origins, test_mode, status, or default frequency caps.
POST /v1/manage/properties/:id/rotate-secretIssue a new ar_sec_ secret (returned once) with a grace window for the previous secret.
POST /v1/manage/properties/:id/archiveSoft-archive a property (status = "archived"), blocking ad serving.
DELETE /v1/manage/properties/:idPermanently delete a property and its dependent rules/credentials.
curl -X POST https://api.adsrouter.ai/v1/manage/properties \
  -H "Authorization: Bearer $ADSROUTER_MGMT_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Chat Web App",
    "kind": "web",
    "domain": "chat.myapp.com",
    "default_freq_cap_hourly": 3,
    "default_freq_cap_daily": 12
  }'
const res = await fetch('https://api.adsrouter.ai/v1/manage/properties', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${process.env.ADSROUTER_MGMT_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    name: 'Chat Web App',
    kind: 'web',
    domain: 'chat.myapp.com',
    default_freq_cap_hourly: 3,
    default_freq_cap_daily: 12,
  }),
});
const { property, secret } = await res.json();
// Store `secret` (ar_sec_...) in your ad-serving backend env vars!
import os, requests

r = requests.post(
    "https://api.adsrouter.ai/v1/manage/properties",
    headers={
        "Authorization": f"Bearer {os.environ['ADSROUTER_MGMT_KEY']}",
        "Content-Type": "application/json",
    },
    json={
        "name": "Chat Web App",
        "kind": "web",
        "domain": "chat.myapp.com",
        "default_freq_cap_hourly": 3,
        "default_freq_cap_daily": 12,
    },
    timeout=10,
)
data = r.json()
prop, prop_secret = data["property"], data["secret"]

Campaigns (Direct-Sold & House)

Workspace management keys control your workspace's direct and house campaigns.

Method & PathDescription
GET /v1/manage/campaignsList workspace campaigns. Optional query filters: ?scope=direct|house, ?status=active|paused|draft|archived.
POST /v1/manage/campaignsCreate a direct or house campaign with targeting, dayparting, pacing, caps, and creative JSON. External creative.image_url and favicon_url are automatically mirrored to AdsRouter's CDN.
GET /v1/manage/campaigns/:idFetch a single campaign by UUID.
PATCH /v1/manage/campaigns/:idUpdate campaign fields, targeting, dayparting, pacing, caps, or creative (external creative images are mirrored to AdsRouter's CDN).
POST /v1/manage/campaigns/:id/statusTransition campaign status: body { "status": "active" | "paused" | "draft" | "archived" }.
DELETE /v1/manage/campaigns/:idPermanently delete a workspace campaign.
# Create an active direct-sold campaign
curl -X POST https://api.adsrouter.ai/v1/manage/campaigns \
  -H "Authorization: Bearer $ADSROUTER_MGMT_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Acme Cloud Q4 Sponsor",
    "scope": "direct",
    "status": "active",
    "priority": 10,
    "delivery_mode": "even_pacing",
    "cap_daily": 5000,
    "freq_cap_daily": 2,
    "targeting": {
      "countries": ["US", "CA"],
      "device_types": ["mobile", "desktop"],
      "include_keywords": ["postgres", "database", "hosting"]
    },
    "creative": {
      "brand_name": "Acme Cloud",
      "headline": "Serverless Postgres in 30 seconds",
      "description": "Start free with 10 GB storage and instant branching.",
      "cta": "Try free",
      "click_url": "https://acme.dev/?utm_source=adsrouter"
    }
  }'

# Pause the campaign later
curl -X POST https://api.adsrouter.ai/v1/manage/campaigns/$CAMPAIGN_ID/status \
  -H "Authorization: Bearer $ADSROUTER_MGMT_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "status": "paused" }'
// Create and later pause a campaign
const created = await fetch('https://api.adsrouter.ai/v1/manage/campaigns', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${process.env.ADSROUTER_MGMT_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    name: 'Acme Cloud Q4 Sponsor',
    scope: 'direct',
    status: 'active',
    priority: 10,
    targeting: { countries: ['US', 'CA'], include_keywords: ['postgres', 'hosting'] },
    creative: {
      brand_name: 'Acme Cloud',
      headline: 'Serverless Postgres in 30 seconds',
      cta: 'Try free',
      click_url: 'https://acme.dev/?utm_source=adsrouter',
    },
  }),
}).then((r) => r.json());

// Pause
await fetch(`https://api.adsrouter.ai/v1/manage/campaigns/${created.campaign.id}/status`, {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${process.env.ADSROUTER_MGMT_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ status: 'paused' }),
});
import os, requests

headers = {
    "Authorization": f"Bearer {os.environ['ADSROUTER_MGMT_KEY']}",
    "Content-Type": "application/json",
}

created = requests.post(
    "https://api.adsrouter.ai/v1/manage/campaigns",
    headers=headers,
    json={
        "name": "Acme Cloud Q4 Sponsor",
        "scope": "direct",
        "status": "active",
        "priority": 10,
        "targeting": {"countries": ["US", "CA"], "include_keywords": ["postgres", "hosting"]},
        "creative": {
            "brand_name": "Acme Cloud",
            "headline": "Serverless Postgres in 30 seconds",
            "cta": "Try free",
            "click_url": "https://acme.dev/?utm_source=adsrouter",
        },
    },
    timeout=10,
).json()

# Pause
requests.post(
    f"https://api.adsrouter.ai/v1/manage/campaigns/{created['campaign']['id']}/status",
    headers=headers,
    json={"status": "paused"},
    timeout=10,
)

BYOK Networks & Mediation Routing

Third-party network secrets are encrypted with AES-256-GCM at rest and are strictly write-only — GET /v1/manage/networks returns masked ••••last4 suffixes only.

Method & PathDescription
GET /v1/manage/networksList configured BYOK credentials (Gravity, Thrad, Velocity, Koah) with masked secrets.
PUT /v1/manage/networks/:networkUpsert credentials for gravity, thrad, velocity, or koah (workspace-default or property-specific via property_id).
DELETE /v1/manage/networks/:idDelete a BYOK credential row by UUID.
GET /v1/manage/properties/:id/routingList mediation rules for a property (default + placement overrides).
PUT /v1/manage/properties/:id/routingSave a mediation rule: { placement, strategy: "priority"|"split", targets: [{ source, priority, weight, enabled }] }.
DELETE /v1/manage/properties/:id/routing/:ruleIdDelete a mediation rule (reverts to default waterfall).

Reporting

Pull your workspace's real-time serving stats and synced third-party network revenue in one call — great for internal dashboards, automated daily digests, or reconciliation scripts.

Method & PathDescription
GET /v1/manage/reports/summary Aggregated requests, fills, fill rate, viewed impressions, clicks, and CTR — plus unified revenue and eCPM (total_revenue_micros, network_revenue_micros, direct_est_revenue_micros, blended_ecpm_micros), side-by-side network impressions and discrepancy % per source, and a networkSyncs array showing each connected network's latest sync status. Filter by ?preset=today|yesterday|7d|30d|90d|custom with optional &from=YYYY-MM-DD&to=YYYY-MM-DD (or legacy ?days=30) and &property_id=<uuid>.
GET /v1/manage/reports/impressionsRecent impression log rows (without raw conversation transcripts). Supports ?limit=50 and ?property_id=<uuid>.

Error Responses

StatusMeaning
400Validation error or malformed UUID parameter.
401Missing or invalid ar_mgmt_ key.
403Management key has been revoked or lacks required scope.
404Resource not found in this workspace (strict cross-workspace isolation).