v1.1 direct_messages/*, v2 /2/dm_events, /2/dm_conversations, and Account Activity DM webhooks) to the X Chat API (/2/chat/*) is an architectural change, not a URL swap. X routes only ciphertext; encryption, decryption, and signing run in your client using the Chat XDK.
Auth & OAuth scopes
media.write for downloads, and OAuth 1.0a compatibility until Jan 31, 2027.Endpoint & event mapping
Key custody & B2B storage
Troubleshooting & FAQ
What is being retired on December 9, 2026?
What is being retired on December 9, 2026?
- v1.1 Direct Messages:
direct_messages/*(events, typing indicator, mark read, welcome messages, DM media) andcustom_profiles/* - v2 Direct Messages:
/2/dm_events,/2/dm_events/{id}, and/2/dm_conversations/*(including DM media) - Legacy DM media uploads:
media/uploadwithmedia_category=dm_* - Legacy real-time DM events: Account Activity DM events (
direct_message_events,direct_message_indicate_typing_events,direct_message_mark_read_events) and X Activitydm.*events
/2/chat/* and X Activity chat.received, chat.sent, and chat.conversation.join events.1. What changes architecturally
- Legacy DMs vs. X Chat
- Official Chat XDK packages
2. Authentication and OAuth 2.0 scope matrix
Every/2/chat/* and /2/users/*/public_keys route requires user-context authentication. App-Only Bearer tokens are rejected with 403 unsupported-authentication (the sole exception is GET /2/activity/stream, which requires an App-Only Bearer token).
- OAuth 2.0 (Recommended)
- OAuth 1.0a (Until Jan 31, 2027)
403 missing-scopes listing the missing values. There are no separate X Chat scopes — if your integration only reads and archives messages, dm.write is not needed (though media.write is still required to download chat attachments).3. Endpoint mapping
- Legacy v2 → X Chat
- Legacy v1.1 → X Chat
- Real-time events & webhooks
- New X Chat endpoints
- No 1:1 equivalent
4. Key custody and B2B key storage
OAuth access and encryption keys are separate control planes: an OAuth token authorizes API calls, while private keys unlock and sign message contents. See Handling private keys for full security rules.- Check keys & unlock flow
- Architecture by app type
- B2B approval requirements
- Key lifecycle events
Check whether the account already has keys
GET /2/users/{id}/public_keys (or batch GET /2/users/public_keys?ids=... for up to 100 accounts).- Key backup details returned: The account already uses X Chat. Recover the existing keys with the owner’s PIN. Only generate and register new keys if the customer explicitly authorizes replacing their existing identity (which makes messages encrypted under the old keys unreadable).
- No keys returned: The account has never set up X Chat. For a dedicated bot account (or an uninitialized business account where the admin chooses the PIN in your connect flow so they can still use X Chat in the X app later), generate and register a keypair once via
POST /2/users/{id}/public_keys.
Check chat eligibility before starting a new 1:1
GET /2/users/{id}?user.fields=receives_your_chat with the sending account’s token:encrypted— you can start an encrypted chatunencrypted— the pair cannot be encrypted yetnone— you cannot message them
Unlock once and export (approved server-side custody)
@xdevplatform/chat-xdk-server, Python, Ruby, Go, .NET, JVM, or Rust — browser WASM cannot export keys) with juicebox_config, call unlock(pin) once, call export_keys(), store only the opaque blob in a KMS / HSM / Secrets Manager (one secret per account keyed by user_id + public_key_version, least-privilege IAM, audited reads), and discard the PIN immediately. Workers load the blob with import_keys(blob, version) and set_identity(user_id, version) — no PIN needed.Never auto-retry a wrong PIN: Juicebox enforces a small, hardware-enforced, non-renewable wrong-guess budget (juicebox_config.max_guess_count). Exhausting it deletes the backup and makes older encrypted messages unreadable. Fail closed after one wrong attempt. Unlocks also carry an independent edge rate limit (~30 unlocks/min per egress IP) — unlock once and reuse the result.5. Key workflows and caveats
- 1:1 key setup & sending
- Media upload & download
- History & message requests
- Rate limits, SDK & spec caveats
chat-xdk. To initiate a new 1:1 conversation with no key yet:Fetch and verify both participants' keys
verify_key_binding on each before encrypting.Create and post the conversation key
prepare_conversation_key_change (rename the SDK’s encrypted_key field to encrypted_conversation_key in conversation_participant_keys) and POST /2/chat/conversations/{recipient_id}/keys. Skip this step when a conversation already has a key — never rotate on every send.Encrypt and send (reuse payload on retry)
encrypt_message and POST /2/chat/conversations/{recipient_id}/messages. Because the Chat XDK binds message_id into the signature, resend the exact same encrypted payload on retry — re-encrypting creates a duplicate message.403. Stop all legacy DM calls and subscriptions for that account together when switching.6. Pre-cutover verification checklist
Codebase & authentication- Zero remaining calls to
/2/dm_events,/2/dm_conversations, v1.1direct_messages/*,media_category=dm_*, Account Activity DM webhooks, or XAAdm.*subscriptions. - User-context tokens on every
/2/chat/*and/2/users/*/public_keysroute; App-Only Bearer used only onGET /2/activity/stream. - OAuth 2.0 apps request
tweet.read users.read dm.read dm.write media.write offline.accessand verify media download succeeds (media.write). OAuth 1.0a apps have “Read, Write and Direct Messages” and a plan to move to OAuth 2.0 before January 31, 2027.
- Key architecture chosen per Handling private keys; X partner approval and customer contract/disclosures completed for any B2B server-side key custody.
- No code path silently registers new keys on an account that already has keys without explicit customer approval; brand account’s official X app still works after onboarding.
- Zero PINs or private keys in databases, env vars, logs, or APM; Juicebox
unlock()fails closed after one wrong attempt with no auto-retry;public_key_versionrotation monitored; offboarding deletes all key copies and instructs Reset Chat.
- Tested:
:→-URL conversion, new 1:1 conversation key setup, encrypted send & idempotent retry,chat.received/chat.sent/chat.conversation.joindelivery & deduplication, encrypted media round-trip, message request accept, group create, and mark read. - Spec caveats handled (
POST …/readomitsseen_until_sequence_id;POST …/membershand-parsed); permanent403s not retried in a loop; rate-limit headers andretry-afterhonored. - Enterprise allowlisted apps: coordinated with your X account representative to remove the app from the legacy-DM allowlist after cutover.
7. Troubleshooting and FAQ
Common migration errors
Testing before cutover
- Encrypted path & allowlist
- Testing with OAuth 1.0a
POST /2/chat/conversations/{id}/keys can fail with a 403 mentioning follows even when follows are not the issue.Use clean test accounts on both sides
Verify encryption eligibility first
GET /2/users/{id}?user.fields=receives_your_chat and confirm the pair returns encrypted.Never loop on the 403 or re-register keys
POST …/keys returns 403, stop retrying and verify neither test account is connected to an allowlisted legacy DM app.