Skip to content

Get Developer Access Fresh

Before you can run XMCP or call the X API directly, you need a developer account and an app with credentials. This procedure gets you from zero to a working first request.

Procedure

flowchart TD
    A[Create developer account] --> B[Create an app in the Developer Console]
    B --> C[Copy Bearer Token + OAuth keys]
    C --> D[Make a first request with cURL]
    D --> E{Response OK?}
    E -->|200| F[Ready to set up XMCP]
    E -->|401 / 403| G[Check token + permissions]
    G --> D

Step 1 - Get your credentials

In the Developer Console (https://console.x.com), open your app and copy:

  • Bearer Token - for app-only, read-only requests
  • OAuth consumer key + consumer secret - required by XMCP for user-context actions (creating posts, etc.)

Step 2 - Make your first request

The fastest way to confirm access is a user lookup with cURL:

bash
curl "https://api.x.com/2/users/by/username/xdevelopers" \
  -H "Authorization: Bearer $BEARER_TOKEN"

Replace $BEARER_TOKEN with your actual Bearer Token. A working response looks like:

json
{
  "data": {
    "id": "2244994945",
    "name": "X Developers",
    "username": "xdevelopers"
  }
}

Step 3 - Request more fields

By default, endpoints return minimal fields. Use the fields parameter to ask for more:

bash
curl "https://api.x.com/2/users/by/username/xdevelopers?user.fields=created_at,description,public_metrics" \
  -H "Authorization: Bearer $BEARER_TOKEN"

Response:

json
{
  "data": {
    "id": "2244994945",
    "name": "X Developers",
    "username": "xdevelopers",
    "created_at": "2013-12-14T04:35:55.000Z",
    "description": "The voice of the X Developer Platform",
    "public_metrics": {
      "followers_count": 570842,
      "following_count": 2048,
      "tweet_count": 14052,
      "listed_count": 1672
    }
  }
}

More starter requests

bash
# Look up a post by ID
curl "https://api.x.com/2/tweets/1460323737035677698?tweet.fields=created_at,public_metrics" \
  -H "Authorization: Bearer $BEARER_TOKEN"

# Search recent posts (last 7 days)
curl "https://api.x.com/2/tweets/search/recent?query=from:xdevelopers&tweet.fields=created_at" \
  -H "Authorization: Bearer $BEARER_TOKEN"

# Get a user's recent posts
curl "https://api.x.com/2/users/2244994945/tweets?max_results=5" \
  -H "Authorization: Bearer $BEARER_TOKEN"

Beginner-friendly endpoints

EndpointWhat it does
User lookupGet a user profile by username or ID
Post lookupGet a post by ID
Recent searchSearch posts from the last 7 days

In code

python
import requests

bearer_token = "YOUR_BEARER_TOKEN"
url = "https://api.x.com/2/users/by/username/xdevelopers"

headers = {"Authorization": f"Bearer {bearer_token}"}
response = requests.get(url, headers=headers)

print(response.json())
javascript
const bearerToken = "YOUR_BEARER_TOKEN";
const url = "https://api.x.com/2/users/by/username/xdevelopers";

fetch(url, {
  headers: { Authorization: `Bearer ${bearerToken}` }
})
  .then(res => res.json())
  .then(data => console.log(data));

For production use, prefer the official Python or TypeScript SDKs (XDKs), which handle authentication, pagination, and rate limiting automatically.

Verification checklist

  • [ ] Developer account created
  • [ ] App created in the Developer Console
  • [ ] Bearer Token copied
  • [ ] OAuth consumer key and secret copied (needed for XMCP)
  • [ ] First cURL request returned a 200 with data

Troubleshooting

SymptomLikely causeFix
401 UnauthorizedWrong or regenerated Bearer TokenRe-copy the token; check the header format Bearer YOUR_TOKEN
403 ForbiddenApp lacks access, or endpoint needs user contextCheck app permissions; use OAuth 1.0a / 2.0 for write actions
429 Too Many RequestsRate limit hitCheck x-rate-limit-reset and back off (see Rate Limits)

See also