SocialAPI uses OAuth in two distinct contexts:Documentation Index
Fetch the complete documentation index at: https://docs.social-api.ai/llms.txt
Use this file to discover all available pages before exploring further.
- Connecting platform accounts (Instagram, Facebook, etc.) to your SocialAPI account so you can manage them through the API.
- Authenticating MCP/API clients (Claude, ChatGPT, Cursor) via the built-in OAuth 2.1 authorization server so they can call the API on your behalf.
Connecting platform accounts
SocialAPI manages platform OAuth on your behalf. Your application kicks off the connection, sends the user to the platform’s consent screen, and receives a redirect back to a URL of your choice with the result. You never see or store platform access tokens — SocialAPI persists them encrypted and proxies all subsequent calls. This is a managed connection pattern, not an OAuth flow you implement against SocialAPI. For OAuth 2.1 (used by MCP and third-party API clients calling SocialAPI), see the section below.Step 1: Initiate the connection
CallPOST /v1/accounts/connect with the platform slug, your post-connection redirect_uri, and an optional state value for correlation:
| Field | Location | Required | Notes |
|---|---|---|---|
platform | top-level | yes | Platform slug (instagram, facebook, threads, tiktok, linkedin, twitter, youtube, google). |
redirect_uri | top-level | recommended | Your post-connection callback. Must be pre-registered (see Whitelisting redirect URIs). If omitted, the user sees a built-in HTML success page instead of being redirected. |
state | top-level | optional | Opaque correlation value, max 512 chars, echoed back verbatim in the final redirect. Use it to tie the result to a session on your side. |
brand_id | top-level | optional | Attach the account to an existing brand. If omitted, a new brand is auto-created. |
metadata | top-level | optional | Platform-specific connection data only (for example, TikTok BYOK uses this for apikey). For standard managed OAuth this is empty or omitted. |
state in the response is SocialAPI’s internal CSRF token used between our connect call and our platform callback. Your application does not need to read or store it; just send the user to auth_url.
Step 2: User authorizes on the platform
Redirect your user to theauth_url. They log in to the platform and grant permissions. The platform redirects back to SocialAPI’s callback (not yours). SocialAPI exchanges the code for an access token, persists it encrypted, and then 302-redirects the user to your redirect_uri.
Step 3: Receive the result at your redirect_uri
Success:
account_id. Facebook accounts that manage multiple Pages still resolve to a single account in the connection result; Page details are exposed separately under /v1/accounts/{id}/pages and are not part of this flow.
Error (the user denied consent, the platform returned an error, or the link expired):
status first. On success, persist the account_id against your user record and call /v1/accounts/{id} for full account details. On error, surface a retry path in your UI — the customer can restart from Step 1.
Fallback when redirect_uri is omitted
If your connect call did not include redirect_uri, SocialAPI renders a built-in HTML success or error page in place of the redirect. This is intended for ad-hoc connections (for example, the SocialAPI dashboard itself); production integrations should always supply redirect_uri.
Whitelisting redirect URIs
Everyredirect_uri you use must be pre-registered. Register URIs from the SocialAPI dashboard under Settings → OAuth redirect URIs. The management API exists at /v1/oauth/redirect-uris but is dashboard-only (requires the dashboard JWT, not an API key).
A connect call with a redirect_uri that is not on the whitelist returns 400 with an error.
Correlation state (customer-controlled)
The top-level state field on POST /v1/accounts/connect is your correlation token, not a security primitive enforced by SocialAPI. It is echoed back unchanged in the final redirect. Common uses:
- Tie the redirect to the originating session (set
stateto a server-side session ID). - CSRF defense for your own application — generate a random value, store it in the user’s session, and verify it matches when the redirect lands.
state. If you do not pass one, the final redirect will include state= with an empty value.
Listing connected accounts
Reconnecting an account
If you callPOST /v1/accounts/connect for an account that is already connected, the flow runs again and the stored token is upserted. This is safe to call when tokens expire and is the supported path for token refresh on platforms that lack long-lived tokens.
OAuth 2.1 for MCP and API clients
SocialAPI includes a built-in OAuth 2.1 authorization server that enables MCP clients (Claude, ChatGPT, Cursor) and other third-party applications to authenticate users and call the API on their behalf. The implementation follows these RFCs:- RFC 8414 for authorization server metadata discovery
- RFC 7591 for dynamic client registration
- RFC 7636 for PKCE (required)
- RFC 7009 for token revocation
Discovery
Clients can discover the authorization server configuration at:Step 1: Register a client
Register your application using dynamic client registration:Step 2: Authorize the user
Redirect the user to the authorization endpoint with PKCE parameters:redirect_uri with ?code=...&state=....
PKCE is required. The only supported challenge method is
S256. Requests without a code_challenge are rejected with 400.social:all, which grants full access to the user’s account. This is the default if no scope is specified.
Step 3: Exchange the code for tokens
/v1 endpoints.
Step 4: Refresh the access token
When the access token expires, use the refresh token to get a new pair:Revoking tokens
To revoke a refresh token (for example, on user logout):200, even if the token is already invalid.
Supporting endpoints
| Endpoint | Method | Purpose |
|---|---|---|
/.well-known/oauth-authorization-server | GET | RFC 8414 metadata discovery |
/oauth/register | POST | RFC 7591 dynamic client registration |
/oauth/authorize | GET | Authorization with PKCE |
/oauth/token | POST | Code exchange and refresh token rotation |
/oauth/revoke | POST | RFC 7009 token revocation |