Before you start
- An X account with a verified email address and phone number.
- A payment method for X pay-per-use credits. X sells no free tier to new developer accounts.
- Access to the SocialAPI dashboard. Saving X credentials is a dashboard action: no API endpoint saves them.
Set up the app
Create the developer account and the app
Set up user authentication
- App permissions: Read and write and Direct message.
- Type of App: Web App, Automated App or Bot. Both give the app a Client Secret.
- Callback URI / Redirect URL:
https://api.social-api.ai/oauth/callback/twitter. It must match exactly, with no trailing slash. - Website URL: your own site, or
https://social-api.ai.
tweet.read, tweet.write, tweet.moderate.write, users.read, dm.read, dm.write, like.write, media.write, and offline.access. The app permissions above let X grant them. Changing the app permissions later means each person reconnects.Copy the OAuth 2.0 credentials
Save the credentials in SocialAPI
Connect an account
POST /v1/accounts/connect with "platform": "twitter", as in Connect an X account.auth_url. Without saved credentials, POST /v1/accounts/connect returns 412 byok.credentials_missing.Use a different app for one brand
Save a second X app for a single brand, for example one client’s brand in an agency account, from the same dashboard page. Under Brand overrides, click Override on the brand’s row, paste that app’s Client ID and Client Secret, then click Save and continue. A brand with its own app connects through that app. Every other brand uses your default app. Click Remove on the brand’s row to return that brand to the default.Replace the client secret
After you regenerate the Client Secret in X, click Rotate under Default credentials, or on the brand’s row under Brand overrides, and save the new secret the same way as in step 4. Until you do, a new connection ends on your redirect URI witherror=byok.credentials_invalid.
Troubleshooting
Test credentials fails, or connecting ends with error=byok.credentials_invalid
Test credentials fails, or connecting ends with error=byok.credentials_invalid
POST /v1/accounts/connect returns 412 byok.credentials_missing
POST /v1/accounts/connect returns 412 byok.credentials_missing
Connecting ends with error=byok.app_access_denied
Connecting ends with error=byok.app_access_denied
X shows a callback URL mismatch
X shows a callback URL mismatch
https://api.social-api.ai/oauth/callback/twitter exactly, with no trailing slash and no extra path.The connection works but calls return 403 platform.twitter.insufficient_scope
The connection works but calls return 403 platform.twitter.insufficient_scope
Calls return 402 platform.twitter.usage_capped
Calls return 402 platform.twitter.usage_capped
Calls return 429 platform.twitter.rate_limit
Calls return 429 platform.twitter.rate_limit
Related
- X / Twitter API: capabilities, limits, and scopes
- Platform apps: which platforms use SocialAPI’s app and which use yours
- Connect accounts: the shared connect flow
- Errors: every error code