ØSTEN AI

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" }
StatusWhen
400Validation failure (VALIDATION_ERROR) or a bad request
401Missing or invalid Firebase token
403Not a member of the org, insufficient role, or not a super admin
404No such resource in this org
409Duplicate record
503A required integration is not configured (AI, billing, scheduler)

Route groups

PrefixModuleWhat it covers
/api/authauthProfile bootstrap, access-code validation. Rate-limited, no org required.
/api/organizations, /api/users, /api/invitationsorgsOrg CRUD, members, roles, invitations, access requests, support contact.
/api/adminadminSuper-admin only: platform stats, org and user management, access codes.
/api/google-ads, /api/meta-ads, /api/tiktok-ads, /api/google-analytics, /api/shopifyaccountsPer-platform OAuth connect/callback, account listing, connection status, disconnect.
/api/google-ads/…, /api/meta-ads/…, /api/tiktok-ads/…campaignsCampaign CRUD, status and budget changes, ad groups, ads, keywords, PMax asset groups, search terms, negative keywords, creative performance.
/api/plannercampaignsCampaign plans — drafts that have not touched an ad platform.
/api/analytics, /api/campaigns/summaryreportingDashboard summary, blended MER and true (Shopify-attributed) ROAS.
/api/shopifyshopifyOrder webhook, order/product sync, revenue and true-ROAS analytics.
/api/product-feed, /api/product-segmentsproductsMerchant Center feed sync and rule-based product segments.
/api/ai, /api/learningsinsightsContent tools, dashboard insights, alerts, recommendation lifecycle, the assistant, and per-client learnings. All 503 when AI is disabled.
/api/agentsautomationRecommendation approve/reject and the agent activity feed.
/api/data/sync, /api/scheduler/*automationManual sync for one org; Cloud Scheduler entry points.
/api/onboarding, /api/scanneronboardingOnboarding wizard, website scan, generated marketing plan.
/api/billing, /api/webhooks/stripebillingStripe checkout and portal sessions; subscription webhook.
/api/assetsassetsCreative asset library.
/api/video-jobsvideoVeo 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 HMAC
  • POST /api/webhooks/stripe — verified by Stripe signature
  • POST /api/scheduler/* — verified by X-Scheduler-Secret, fail-closed
  • Invitation lookup/decline and access requests, which are pre-account by nature

On this page