Skip to content

API Reference

For interactive API documentation, run the backend and visit http://localhost:8000/docs.

OpenSNS runs on FastAPI. Interactive API docs are available at /docs for Swagger UI and /redoc for ReDoc.

This page documents the REST routes that are currently defined in backend/app/api/. It stays aligned with the code, so if a route is not present in the backend it is not listed here.

Protected endpoints require this header:

Authorization: Bearer <token>

The /auth/login, /auth/refresh, and /auth/google/callback routes return access and refresh tokens. Most authenticated routes use the JWT access token from access_token.

MethodPathDescriptionAuth requiredKey request fieldsKey response fields
POST/auth/registerCreate a new account with email and passwordNoemail, passwordid, email, is_active, is_verified, auth_provider, created_at
POST/auth/verify?token=...Verify an email address with a verification tokenNotoken query parametermessage
POST/auth/resend-verificationSend a new verification emailNoemailmessage
POST/auth/loginLog in with email and passwordNoOAuth2 form fields username, passwordaccess_token, token_type, refresh_token
POST/auth/refreshExchange a refresh token for a new access tokenNorefresh_tokenaccess_token, token_type, refresh_token
GET/auth/googleStart Google OAuth loginNoNoneauth_url, state
POST/auth/google/callbackComplete Google OAuth login and create tokensNocode, stateaccess_token, token_type, refresh_token
GET/auth/meReturn the current user profileYesNoneid, email, is_active, is_verified, auth_provider, created_at
POST/auth/logoutClear the access cookie and revoke an optional refresh tokenNoOptional refresh_tokenmessage
Terminal window
curl -X POST http://localhost:8000/auth/login \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "username=user@example.com&password=secret"
{
"access_token": "eyJhbGciOi...",
"token_type": "bearer",
"refresh_token": "rft_123456789"
}
MethodPathDescriptionAuth requiredKey request fieldsKey response fields
POST/campaigns/Create a new campaign and start the generation pipelineYestitle, product_url, optional description, brand_kit_id, template_idCampaign object with id, title, product_url, status, created_at, updated_at
GET/campaigns/List campaigns for the current userYesNoneArray of campaign objects
GET/campaigns/statsReturn campaign counts by statusYesNonetotal, completed, in_progress, failed
GET/campaigns/{campaign_id}Get a single campaign by IDYescampaign_id path parameterCampaign object
POST/campaigns/{campaign_id}/approveApprove a campaign awaiting approval and resume processingYescampaign_id path parameterCampaign object
DELETE/campaigns/{campaign_id}Delete a campaign owned by the current userYescampaign_id path parametermessage
GET/campaigns/{campaign_id}/exportExport campaign assets as a ZIP fileYescampaign_id path parameterZIP download
Terminal window
curl -X POST http://localhost:8000/campaigns/ \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"title": "Spring launch",
"product_url": "https://example.com/product",
"description": "Generate ads for the spring campaign"
}'
{
"id": 42,
"title": "Spring launch",
"product_url": "https://example.com/product",
"description": "Generate ads for the spring campaign",
"brand_kit_id": null,
"template_id": null,
"user_id": 7,
"status": "PENDING",
"created_at": "2026-04-13T09:00:00Z",
"updated_at": "2026-04-13T09:00:00Z"
}
MethodPathDescriptionAuth requiredKey request fieldsKey response fields
GET/assets/campaign/{campaign_id}List assets for a campaignNocampaign_id path parameterArray of asset objects with id, campaign_id, type, content, asset_metadata, ai_disclosure, created_at
GET/assets/{asset_id}Get a single asset by IDNoasset_id path parameterAsset object
Terminal window
curl http://localhost:8000/assets/campaign/42
[
{
"id": 301,
"campaign_id": 42,
"type": "IMAGE",
"content": "https://cdn.example.com/assets/image.png",
"asset_metadata": "{\"platform\":\"meta\",\"angle\":\"A\"}",
"ai_disclosure": "{}",
"created_at": "2026-04-13T09:10:00Z"
}
]
MethodPathDescriptionAuth requiredKey request fieldsKey response fields
GET/settings/Get the current user settings recordYesNoneDefault engine settings, UGC settings, engine URLs, API key presence flags, AI label settings
PUT/settings/Update user settings, including API keys and engine URLsYesAny subset of settings fields such as default_llm_engine, openai_api_key, fal_api_key, ollama_url, ugc_enabled, ai_label_textUpdated settings object
Terminal window
curl -X PUT http://localhost:8000/settings/ \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"default_llm_engine": "openai",
"ugc_enabled": true,
"ai_label_text": "AI Generated"
}'
{
"default_llm_engine": "openai",
"default_image_engine": "fal",
"default_video_engine": "fal-video",
"default_ugc_engine": "heygen",
"ugc_enabled": true,
"ugc_avatar_id": null,
"ugc_voice_id": null,
"ollama_url": null,
"comfyui_url": null,
"sadtalker_url": null,
"default_tts_engine": "openai-tts",
"default_bgm_engine": "static-bgm",
"tts_enabled": false,
"bgm_enabled": false,
"tts_voice_id": null,
"bgm_style": null,
"has_openai_key": true,
"has_fal_key": true,
"has_firecrawl_key": false,
"has_heygen_key": false,
"has_did_key": false,
"has_anthropic_key": false,
"has_google_key": false,
"has_groq_key": false,
"ai_disclosure_enabled": true,
"ai_label_text": "AI Generated",
"ai_label_position": "BOTTOM_RIGHT"
}
MethodPathDescriptionAuth requiredKey request fieldsKey response fields
GET/billing/overviewReturn subscription, usage, and credit cost overviewYesNonesubscription, usage, credit_costs, usage_percentage
GET/billing/plansList available subscription plansNoNonePlan map keyed by tier
GET/billing/credit-packsList available credit packsNoNoneCredit pack map keyed by pack ID
GET/billing/ls-configReturn LemonSqueezy configuration for the signed in userYesNonestore_id, customer_email
POST/billing/create-checkoutCreate a LemonSqueezy checkout URLYesvariant_id, optional checkout_type, optional custom_dataurl
GET/billing/analytics?days=...Return credit usage analytics for the selected periodYesdays query parameterperiod_days, total_credits, by_type, daily, lifetime
POST/billing/webhookInternal LemonSqueezy webhook receiverNoSigned webhook body, X-Signature, X-Event-Name headersstatus
Terminal window
curl http://localhost:8000/billing/overview \
-H "Authorization: Bearer <token>"
{
"subscription": {
"tier": "PRO",
"status": "ACTIVE",
"current_period_start": "2026-04-01T00:00:00Z",
"current_period_end": "2026-05-01T00:00:00Z",
"cancel_at_period_end": false,
"limits": {
"credits_per_month": 500,
"team_members": 3
}
},
"usage": {
"period_start": "2026-04-01T00:00:00Z",
"credits_used": 48,
"credits_limit": 500,
"bonus_credits": 0
},
"credit_costs": {
"image": 1,
"video": 12,
"repurpose": 5,
"product_photo": 3,
"tts": 2,
"bgm": 0
},
"usage_percentage": 9
}
MethodPathDescriptionAuth requiredKey request fieldsKey response fields
GET/publishing/connectionsList active social publishing connectionsYesNoneArray of connection objects
DELETE/publishing/connections/{connection_id}Remove a publishing connectionYesconnection_id path parametermessage
GET/publishing/meta/authStart Meta OAuth flowYesNoneauth_url, state
GET/publishing/meta/callback?code=...&state=...Finish Meta OAuth flow and store page or Instagram connectionsYescode, stateconnections
GET/publishing/x/authStart X OAuth flowYesNoneauth_url, state
GET/publishing/x/callback?code=...&state=...Finish X OAuth flow and store the connectionYescode, stateconnections
GET/publishing/threads/authStart Threads OAuth flowYesNoneauth_url, state
GET/publishing/threads/callback?code=...&state=...Finish Threads OAuth flow and store the connectionYescode, stateconnections
POST/publishing/campaigns/{campaign_id}/publishPublish campaign assets to a selected social platformYescampaign_id path parameter, platform, optional asset_ids, caption, targeting, budgetPublish log object
Terminal window
curl -X POST http://localhost:8000/publishing/campaigns/42/publish \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"platform": "FACEBOOK",
"caption": "Spring launch",
"asset_ids": [301]
}'
{
"id": 9001,
"campaign_id": 42,
"platform": "FACEBOOK",
"status": "PUBLISHING",
"external_post_id": null,
"external_url": null,
"error_message": null,
"created_at": "2026-04-13T09:15:00Z"
}
MethodPathDescriptionAuth requiredKey request fieldsKey response fields
GET/ugc/enginesList UGC engine availability for the current userYesNoneengines, default_engine
GET/ugc/avatars?engine=...List available avatars for a UGC engineYesengine query parameter, default heygenavatars, engine
GET/ugc/voices?engine=...List available voices for a UGC engineYesengine query parameter, default heygenvoices, engine
Terminal window
curl http://localhost:8000/ugc/avatars?engine=heygen \
-H "Authorization: Bearer <token>"
{
"engine": "heygen",
"avatars": [
{
"avatar_id": "avatar_123",
"name": "Professional Presenter"
}
]
}
MethodPathDescriptionAuth requiredKey request fieldsKey response fields
POST/waitlist/Join the waitlistNoemailid, email, source, created_at
GET/waitlist/List waitlist entriesYesNoneArray of waitlist entries
Terminal window
curl -X POST http://localhost:8000/waitlist/ \
-H "Content-Type: application/json" \
-d '{"email":"waitlist@example.com"}'
{
"id": 12,
"email": "waitlist@example.com",
"source": "web",
"created_at": "2026-04-13T09:20:00Z"
}

Some route names in the product brief do not exist in the backend yet, so this page reflects the actual FastAPI routers instead of placeholder endpoints.

For exact request and response schemas, use the interactive Swagger UI or inspect the Pydantic models in backend/app/models/models.py.

Generate ad creatives from any product URL. Open source, self-hostable, free tier available.

Try OpenSNS Free →