https://api.social-api.ai/v1 and to the MCP server at https://api.social-api.ai/mcp carries a token in the Authorization header: Authorization: Bearer <token>. SocialAPI accepts two kinds of token: an API key, which you create and keep on your server, and an OAuth 2.1 access token, which an app receives after a SocialAPI user approves it.
Most integrations use an API key. Managing keys costs no credits.
Token types
A full-access API key and an OAuth access token can call every public endpoint of your SocialAPI account. A scoped API key can call only what its scopes and brands allow. The two token types work on the REST API and on the MCP server alike.
Endpoints
Creating, listing, changing, rotating, and revoking keys needs full access: a full-access key, an OAuth access token, or the dashboard. A scoped key, including a key restricted only to brands, that calls these endpoints gets
403 auth.insufficient_scope. GET /v1/keys/scopes is the exception: any valid key can call it.
Create a key
Create a key in the SocialAPI dashboard, or with the API:raw_key is shown once, in this response. Store it in a secret manager or an environment variable such as SOCAPI_KEY. GET /v1/keys shows only a preview afterwards, and no endpoint returns the secret again: a lost secret needs a rotation.
List keys
Rotate a key
Rotation issues a new secret and keeps the key’sid, name, scopes, and brand_ids:
raw_key. The old secret stops working at once, so update every service that uses it. last_used_at is cleared. Rotating a revoked key, or an ID that is not one of your keys, returns 404 resource.not_found.
To replace a secret with no downtime, create a second key with the same scopes and brands, deploy it to your services, then revoke the first key. Rotation cuts over at once and has no overlap.
To change a key’s name, scopes, or brands without a new secret, use PATCH /v1/keys/{id}, described in Scoped API keys.
Revoke a key
Authentication errors
- No
Authorizationheader returns401 auth.missing_header. Authorization: Bearerfollowed by nothing returns401 auth.empty_token.- A
sapi_key_token that is unknown or revoked returns401 auth.invalid_key. - Any other token that is invalid or expired returns
401 auth.invalid_token. - An OAuth access token whose user no longer exists returns
401 auth.user_not_found. - A scoped key outside its scopes or brands, or calling key management, returns
403 auth.insufficient_scope. - A failed payment on your SocialAPI account returns
402 billing.past_dueon every endpoint except every method of/v1/users/meand every/v1/billing/*endpoint. See Plans.
error.code, never on error.message. Every code is in Errors. The MCP server at /mcp answers the same failures with HTTP 401 (or 402 for a past-due account) and a body of the form {"error": "invalid or inactive API key"}, without the error envelope. The past-due 402 body also carries code: billing.past_due.
Keep keys safe
- Use keys only on a server. A key in a browser, a mobile app, or a public repository can be copied and used by anyone.
- Load keys from the environment. Read
SOCAPI_KEYfrom an environment variable or a secret manager, never from source code. - Create one key per service. Revoke one service’s key without stopping the others.
- Give each key only what it needs. Restrict keys to the scopes and brands the service uses, so a leaked key cannot reach other clients or actions.
- Guard full-access keys most. A full-access key can create more keys, including other full-access keys.
- Rotate a key you think leaked.
POST /v1/keys/{id}/rotateends the old secret at once and keeps the key’s restrictions. - Revoke keys you no longer use. Check
last_used_atto find them.
Use from an AI agent
See MCP tools for every tool.
Related
- Scoped API keys for keys limited to some scopes and brands
- OAuth for MCP clients for the OAuth 2.1 flow and its tokens
- The MCP server for connecting AI clients with a key or OAuth
- Errors for the full
auth.*list - Rate limits for how many requests you can send