Skip to main content
The X API uses standard HTTP status codes. Successful requests return 2xx codes; errors return 4xx or 5xx codes with details in the response body.

HTTP status codes

Success codes

CodeMeaningDescription
200OKRequest successful
201CreatedResource created (POST requests)
204No ContentSuccess with no response body (DELETE requests)

Client error codes

CodeMeaningCommon causes
400Bad RequestInvalid JSON, malformed query, missing required parameters
401UnauthorizedInvalid or missing authentication credentials
403ForbiddenValid auth but no permission for this resource or action
404Not FoundResource doesn’t exist or has been deleted
409ConflictStream has no rules (filtered stream only)
429Too Many RequestsRate limit or usage cap exceeded

Server error codes

CodeMeaningWhat to do
500Internal Server ErrorWait and retry; check status page
502Bad GatewayWait and retry
503Service UnavailableX is overloaded; wait and retry
504Gateway TimeoutWait and retry

Error response format

Error responses include structured details:
{
  "title": "Invalid Request",
  "detail": "The 'query' parameter is required.",
  "type": "https://api.x.com/2/problems/invalid-request"
}
FieldDescription
typeURI identifying the error type
titleShort error description
detailSpecific explanation for this error
Additional fields may be present depending on the error type.

Error types

TypeDescription
about:blankGeneric error (see HTTP status code)
.../invalid-requestMalformed request or invalid parameters
.../resource-not-foundPost, user, or other resource doesn’t exist
.../not-authorized-for-resourceNo access to private/protected content
.../client-forbiddenApp not enrolled or lacks required access
.../usage-cappedUsage cap exceeded
.../rate-limit-exceededRate limit exceeded
.../streaming-connectionStream connection problem
.../rule-capToo many filtered stream rules
.../invalid-rulesRule syntax error
.../duplicate-rulesRule already exists

Partial errors

Some requests can partially succeed. A 200 response may include both data and errors:
{
  "data": [
    {"id": "123", "text": "Hello"}
  ],
  "errors": [
    {
      "resource_id": "456",
      "resource_type": "tweet",
      "title": "Not Found Error",
      "detail": "Could not find tweet with id: [456].",
      "type": "https://api.x.com/2/problems/resource-not-found"
    }
  ]
}
This happens when requesting multiple resources and some are unavailable.

Troubleshooting common errors

Check your authentication:
  • Verify you’re using the correct authentication method for the endpoint
  • Ensure credentials haven’t been regenerated
  • Check the Authorization header format
  • For OAuth 1.0a, verify signature calculation
Authentication guide →
Check your access:
  • Verify your app has access to this endpoint
  • Some endpoints require specific enrollment or approval
  • User-context endpoints need appropriate OAuth scopes
  • The resource may be private or protected
Rate limited:
  • Check x-rate-limit-reset header for when to retry
  • Implement exponential backoff
  • Consider caching responses
  • Spread requests across the time window
Rate limits guide →
Fix your request:
  • Validate JSON syntax
  • Check for missing required parameters
  • Verify parameter types (strings vs. numbers)
  • Escape special characters in queries
Check these factors:
  • Protected accounts’ posts are only visible with authorization
  • Deleted posts return 404
  • Some posts are withheld in certain regions
  • Verify search query syntax is correct
Handle reconnection:
  • Implement automatic reconnect with backoff
  • Use recovery features for missed data
  • Check for full-buffer disconnects (client not consuming fast enough)
  • Verify at least one stream rule exists
Streaming guide →

Rate limit headers

Every response includes rate limit information:
x-rate-limit-limit: 900
x-rate-limit-remaining: 847
x-rate-limit-reset: 1705420800
HeaderDescription
x-rate-limit-limitMax requests in current window
x-rate-limit-remainingRequests remaining
x-rate-limit-resetUnix timestamp when window resets

Best practices

Check status codes

Always check HTTP status before parsing the response body.

Handle partial errors

Check for errors array even in 200 responses.

Implement retry logic

Use exponential backoff for 429 and 5xx errors.

Log request details

Include request ID and timestamp for debugging.

Getting help

When posting questions about errors, include:
  • The API endpoint URL
  • Request headers (sanitize credentials)
  • Full error response
  • What you expected to happen
  • Steps you’ve tried