X (Twitter) Setup
Configure X (Twitter) integration through the Twitter Developer Portal.
Prerequisites
- Twitter Developer Account
- Project with appropriate access tier
- OAuth 2.0 with PKCE enabled
Access Tiers
X offers different API access tiers with varying capabilities:
| Tier | Cost | Tweet Posts/Month | Read Tweets/Month |
|---|---|---|---|
| Free | $0 | 1,500 | 0 |
| Basic | $100/mo | 3,000 | 10,000 |
| Pro | $5,000/mo | 300,000 | 1,000,000 |
| Enterprise | Custom | Custom | Custom |
IMPORTANT
For production use with multiple users, Basic tier is the minimum recommended.
Required Scopes (OAuth 2.0)
| Scope | Purpose |
|---|---|
tweet.read | Read tweets |
tweet.write | Post tweets |
users.read | Read user info |
media.write | Upload images, GIFs, and videos for posts |
offline.access | Refresh tokens (required for long-lived access) |
Optional Scopes
| Scope | Purpose |
|---|---|
dm.read | Read DMs |
dm.write | Send DMs |
follows.read | Read following/followers |
like.read | Read likes |
like.write | Like tweets |
Callback URL
https://api.tendsocial.com/api/company/social-accounts/callback/TWITTERSet in: Developer Portal → Your App → User authentication settings → Callback URI
The callback URI must match the URI passed into the OAuth authorize request exactly. In production, set OAUTH_REDIRECT_BASE_URL=https://api.tendsocial.com so callback exchange uses the same URI registered in X.
Environment Variables
TWITTER_CLIENT_ID=your_client_id
TWITTER_CLIENT_SECRET=your_client_secretOAuth 2.0 with PKCE
X requires PKCE (Proof Key for Code Exchange) for OAuth 2.0:
- Generate
code_verifier(random 43-128 character string) - Create
code_challenge= BASE64URL(SHA256(code_verifier)) - Include
code_challengeandcode_challenge_method=S256in auth URL - Include
code_verifierwhen exchanging code for tokens
TendSocial handles this automatically via the Twitter adapter.
IMPORTANT
The token exchange must use the same code_verifier generated during authorization. Verify the PKCE state/verifier flow before submitting for X review or the reviewer will not be able to connect an account.
Platform Limitations
| Feature | Status |
|---|---|
| Text tweets | ✅ Supported (280 chars, or 25,000 for Premium) |
| Images | ✅ Up to 4 images per tweet |
| Videos | ✅ Supported |
| Polls | ❌ Not available via API |
| Threads | ✅ Supported (reply to own tweet) |
| Scheduled tweets | ❌ Not available via API (use TendSocial scheduler) |
| DMs | ⚠️ Requires elevated access |
| Analytics | ⚠️ Limited in lower tiers |
App Permissions Configuration
In Developer Portal → Your App → User authentication settings:
- App permissions: Read and write
- Type of App: Web App
- Callback URI: Your callback URL
- Website URL: Your app's website
For the initial review, request posting and media upload scopes only: tweet.read, tweet.write, users.read, media.write, and offline.access. Request DM scopes later only when the inbox workflow is ready to demonstrate end to end.