API Endpoints
Every route is registered under /api. Base URL is the backend host — the
dashboard reads it from NEXT_PUBLIC_API_URL.
The authoritative list is backend/src/app.ts and the modules/*/routes*.ts
files it registers; this page describes the shape and the groups rather than
enumerating all ~150 routes.
Calling the API
Authenticated requests need both headers:
Authorization: Bearer <Firebase ID token>
x-organization-id: <organization uuid>Omitting the org header on an org-scoped route is 400 ORGANIZATION_ID_REQUIRED.
Sending one the caller is not a member of is 403 ORGANIZATION_ACCESS_DENIED —
never a silent fallback to another org.
Write routes additionally require a role. VIEWER may read but not write;
MEMBER covers day-to-day work; ADMIN covers org settings, members and
billing; OWNER is needed to change another user's role. A role failure is
403 INSUFFICIENT_ROLE.
Responses
Success returns the resource directly (or 204 with no body). Errors are:
{ "error": "Campaign not found", "code": "NOT_FOUND" }| Status | When |
|---|---|
400 | Validation failure (VALIDATION_ERROR) or a bad request |
401 | Missing or invalid Firebase token |
403 | Not a member of the org, insufficient role, or not a super admin |
404 | No such resource in this org |
409 | Duplicate record |
503 | A required integration is not configured (AI, billing, scheduler) |
Route groups
| Prefix | Module | What it covers |
|---|---|---|
/api/auth | auth | Profile bootstrap, access-code validation. Rate-limited, no org required. |
/api/organizations, /api/users, /api/invitations | orgs | Org CRUD, members, roles, invitations, access requests, support contact. |
/api/admin | admin | Super-admin only: platform stats, org and user management, access codes. |
/api/google-ads, /api/meta-ads, /api/tiktok-ads, /api/google-analytics, /api/shopify | accounts | Per-platform OAuth connect/callback, account listing, connection status, disconnect. |
/api/google-ads/…, /api/meta-ads/…, /api/tiktok-ads/… | campaigns | Campaign CRUD, status and budget changes, ad groups, ads, keywords, PMax asset groups, search terms, negative keywords, creative performance. |
/api/planner | campaigns | Campaign plans — drafts that have not touched an ad platform. |
/api/analytics, /api/campaigns/summary | reporting | Dashboard summary, blended MER and true (Shopify-attributed) ROAS. |
/api/shopify | shopify | Order webhook, order/product sync, revenue and true-ROAS analytics. |
/api/product-feed, /api/product-segments | products | Merchant Center feed sync and rule-based product segments. |
/api/ai, /api/learnings | insights | Content tools, dashboard insights, alerts, recommendation lifecycle, the assistant, and per-client learnings. All 503 when AI is disabled. |
/api/agents | automation | Recommendation approve/reject and the agent activity feed. |
/api/data/sync, /api/scheduler/* | automation | Manual sync for one org; Cloud Scheduler entry points. |
/api/onboarding, /api/scanner | onboarding | Onboarding wizard, website scan, generated marketing plan. |
/api/billing, /api/webhooks/stripe | billing | Stripe checkout and portal sessions; subscription webhook. |
/api/assets | assets | Creative asset library. |
/api/video-jobs | video | Veo video-generation jobs. |
/api/health | — | Liveness plus a database check. No auth. |
Unauthenticated routes
A handful of routes deliberately have no bearer token, because the caller is not a browser session:
GET /api/health- OAuth callbacks —
/api/{platform}/auth/callback, verified by OAuth state POST /api/shopify/webhooks— verified by HMACPOST /api/webhooks/stripe— verified by Stripe signaturePOST /api/scheduler/*— verified byX-Scheduler-Secret, fail-closed- Invitation lookup/decline and access requests, which are pre-account by nature