A plain JSON HTTP API for businesses and their marketing agents. Create campaigns, review clips, and pay creators programmatically — scoped to your own account.
POST https://rlceganwyarqvlzrzlzf.supabase.co/functions/v1/campaign
Headers: content-type: application/json
apikey: <project anon key>
Body: { "op": "...", ... }
Every request is one JSON body with an op. Three access levels:
| Level | How | Ops |
|---|---|---|
| public | none | list_campaigns, get_campaign, signup, advertiser_signup |
| creator | creator_token (from signup) | enroll, submit, balance, my_submissions, connect_account, verify_account |
| advertiser | advertiser_key (from advertiser_signup) | create_campaign, fund, my_campaigns, queue, approve, reject, record_views, pay, pay_all, clawback, report |
Advertiser ops are scoped: your key can only see and act on campaigns you created. Hand this key to your marketing agent and it can run everything below.
curl -sX POST $URL -H "apikey: $ANON" -H "content-type: application/json" \
-d '{"op":"advertiser_signup","name":"Acme Inc.","email":"ads@acme.com"}'
# -> { "id":"...", "name":"Acme Inc.", "advertiser_key":"advk_..." }
{"op":"create_campaign","advertiser_key":"advk_...",
"title":"Summer drop","description":"Clip our launch #acme",
"flat_fee_usd":25,"cpm_usd":2,"min_payout_usd":25,"max_payout_usd":300,
"view_cap_per_post":200000,"prize_pool_usd":1000,
"rules":{"platforms":["youtube","tiktok"],"required_hashtags":["#acme"]}}
# -> { "id":"", "status":"draft" }
{"op":"fund","advertiser_key":"advk_...","campaign_id":"","amount_usd":1000}
# -> { "status":"active", "funded_usd":1000 }
{"op":"queue","advertiser_key":"advk_...","campaign_id":""}
# -> { submissions:[ { id, creator, status, views, owed_usd, payout_id, ... } ] }
{"op":"approve","advertiser_key":"advk_...","submission_id":""} // starts earning (flat credited)
{"op":"reject","advertiser_key":"advk_...","submission_id":"","reason":"off-brand"}
{"op":"record_views","advertiser_key":"advk_...","submission_id":"","impressions":50000} // CPM accrues
{"op":"pay","advertiser_key":"advk_...","payout_id":""} // settle one creator
{"op":"pay_all","advertiser_key":"advk_...","campaign_id":""} // settle all approved
{"op":"report","advertiser_key":"advk_...","campaign_id":""} // funnel + pool
Payout owed = flat_fee + views/1000 × cpm, clamped by min/max and the funded pool. Money is held to the invariant funded = remaining + reserved + paid and every mutation is atomic.
{"op":"signup","handle":"@clipper"} # -> { creator_token }
{"op":"list_campaigns"} # discover (public)
{"op":"enroll","creator_token":"...","campaign_id":""}
{"op":"submit","creator_token":"...","campaign_id":"","platform":"youtube","post_url":"https://youtu.be/...","caption":"... #acme"}
{"op":"my_submissions","creator_token":"..."} # status + earnings
{"op":"balance","creator_token":"..."}
Automatic view tracking polls each approved post on a decaying cadence (YouTube live; TikTok/IG/X via connected accounts or a metrics vendor). Until a platform key is set, push views with record_views.
Agents can discover and call these as MCP tools. Add this server to any MCP client:
https://rlceganwyarqvlzrzlzf.supabase.co/functions/v1/clip-mcp
17 tools: discover_campaigns, advertiser_signup, create_campaign, fund_campaign, review_queue, approve_submission, reject_submission, record_views, pay_creator, pay_all, campaign_report, creator_signup, creator_enroll, creator_submit, creator_balance, get_campaign, my_campaigns. Pass your advertiser_key or creator_token in the tool arguments — scoping and auth still apply.
Creators connect any of six platforms from the dashboard. One OAuth function (social-oauth) handles all; register the redirect URI https://rlceganwyarqvlzrzlzf.supabase.co/functions/v1/social-oauth in each provider's app and set that platform's secrets. This verifies channel ownership and lets the platform pull view counts automatically using the creator's own authorization — no global API key. The polling worker refreshes connected posts on a decaying cadence.
Setup (one-time, admin): create a Google OAuth client, set GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET as Supabase Edge Function secrets, and register the redirect URI https://rlceganwyarqvlzrzlzf.supabase.co/functions/v1/yt-oauth. Optionally set YOUTUBE_API_KEY for public stats without OAuth.