Keys / X

TWITTER_BEARER_TOKEN

The app-only Bearer Token your app sends as Authorization: Bearer <token> to read public data from the X API.

Expires
never; it works until you regenerate or invalidate it
API
create with the API key and secret; invalidate with OAuth 1.0a

Get it

Create one on console.x.com. The steps aren't recorded yet.

Set it

TWITTER_BEARER_TOKEN=...

No official SDK reads it on its own. X's Java SDK names TWITTER_BEARER_TOKEN in its README, but your app passes it in; the Python and TypeScript XDKs take it as bearer_token and bearerToken. Or keep it out of .env with keypin: keypin run -- npm run dev

Replace it

  1. An app has one Bearer Token at a time, and a new one stops the old one. Plan for a short gap.
  2. In the Developer Console, open the app's Keys and tokens and click Regenerate next to the Bearer Token. X shows it once. Or call POST oauth2/invalidate_token, then POST oauth2/token.
  3. Deploy it everywhere that reads TWITTER_BEARER_TOKEN. Requests with the old token fail until then.

Set rotate_every on the key in keypin.toml and a rotated date on its vault item, and keypin status shows when it's due.

Sources, checked 2026-11-16