API Reference
The ad-network service runs on port 4080. In production, all endpoints are accessed through the Next.js API proxy at /api/ads/*.
Campaign Matching
POST /v1/match
Called by the facilitator at settle-time to find a matching campaign for the settled resource.
Request:
Response (matched):
Response (no match):
Campaigns
GET /v1/campaigns
List all campaigns with advertiser info.
GET /v1/campaigns/:id
Get a single campaign by ID.
POST /v1/campaigns
Create a new campaign.
Required fields: advertiser_id, name, budget_total, budget_daily, max_bid_amount, schedule_start, rec_resource_url, rec_description, rec_sponsor_name
Optional fields: target_categories, target_networks, target_transports, target_url_patterns, schedule_end, rec_bazaar_id, bid_strategy
All budget/bid amounts are in atomic USDC (6 decimals). 1000000 = 1.00 USDC.
PATCH /v1/campaigns/:id
Update campaign fields.
POST /v1/campaigns/:id/activate
Set campaign status to "active". The campaign immediately starts matching.
POST /v1/campaigns/:id/pause
Set campaign status to "paused". The campaign stops matching.
Advertisers
GET /v1/advertisers
List all advertisers.
POST /v1/advertisers
Register a new advertiser.
Required fields: name, wallet_address, network
Settlement Events
POST /v1/events
Record a settlement event from the facilitator. Called automatically by the facilitator after every sponsored settlement.
Request:
GET /v1/events
List recent settlement events. Accepts ?limit=N (default 50).
Conversions
POST /v1/conversions
Record a conversion (agent called a recommended resource).
Request:
GET /v1/campaigns/:id/conversions
Get all conversions for a campaign.
Publisher Manifest
GET /v1/manifest
Returns active campaigns for the publisher middleware (Model B). Publishers poll this periodically to cache campaign data locally.
Impression Beacon
GET /v1/track/impression/:campaignId
Impression beacon endpoint. HTTP clients fire this URL to confirm recommendation delivery. Returns 204 No Content.
Health
GET /healthz
Service health check. Returns service name, version, and Bazaar resource count.