Skip to main content
Moving from Legacy Direct Messages (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.
Cutover deadline: December 9, 2026. December 9, 2026 is the last day to move off legacy Direct Messages. After December 9, X stops accepting new unencrypted DMs, legacy webhooks stop sending unencrypted DM events, and /2/chat/* is the only API for DMs.Existing conversations are upgraded on X’s side — you do not need to migrate or archive your existing DM history. Contact your X account representative if you have blockers or need engineering assistance with your migration timeline.

Auth & OAuth scopes

User-context tokens, media.write for downloads, and OAuth 1.0a compatibility until Jan 31, 2027.

Endpoint & event mapping

Full v2, v1.1, Account Activity, X Activity, and new X Chat endpoint mappings.

Key custody & B2B storage

Checking existing keys, one-time PIN unlock/export, B2B approval criteria, and key lifecycle rules.

Troubleshooting & FAQ

Error reference, pre-cutover testing (allowlist & OAuth 1.0a), and partner FAQ.
  • v1.1 Direct Messages: direct_messages/* (events, typing indicator, mark read, welcome messages, DM media) and custom_profiles/*
  • v2 Direct Messages: /2/dm_events, /2/dm_events/{id}, and /2/dm_conversations/* (including DM media)
  • Legacy DM media uploads: media/upload with media_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 Activity dm.* events
Replacements: /2/chat/* and X Activity chat.received, chat.sent, and chat.conversation.join events.

1. What changes architecturally

No forward secrecy (or post-compromise security): X Chat wraps conversation keys to long-lived P-256 identity keys. Anyone who obtains an account’s identity private key can decrypt past and future conversation keys wrapped to it (rotating a conversation key protects only future messages). Disclose this to customers and protect private keys and PINs as root credentials — see Handling private keys.

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).

3. Endpoint mapping


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.
Never register new keys (POST /2/users/{id}/public_keys) silently on an account that already uses X Chat. Each X account has one active identity key. Registering a new keypair replaces the account’s previous identity and makes messages encrypted under the old keys unreadable — only create new keys on an existing X Chat account with the customer’s explicit approval (and have the admin choose a new PIN for secure key backup so they can also use X Chat in the X app).
1

Check whether the account already has keys

Call 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.
2

Check chat eligibility before starting a new 1:1

Request GET /2/users/{id}?user.fields=receives_your_chat with the sending account’s token:
  • encrypted — you can start an encrypted chat
  • unencrypted — the pair cannot be encrypted yet
  • none — you cannot message them
3

Unlock once and export (approved server-side custody)

Construct a server/native Chat XDK instance (@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

Conversation ID formatsMandatory 1:1 conversation key setup (first contact only)If your bot only replies to inbound messages, skip this step and reply encrypted with chat-xdk. To initiate a new 1:1 conversation with no key yet:
1

Fetch and verify both participants' keys

Fetch both public-key records and call verify_key_binding on each before encrypting.
2

Create and post the conversation key

Call 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.
3

Encrypt and send (reuse payload on retry)

Call 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.
Move all services for a brand account together: While any service still holds an active legacy DM connection for an account through an allowlisted app, new 1:1 chats stay unencrypted and key setup can fail with 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.1 direct_messages/*, media_category=dm_*, Account Activity DM webhooks, or XAA dm.* subscriptions.
  • User-context tokens on every /2/chat/* and /2/users/*/public_keys route; App-Only Bearer used only on GET /2/activity/stream.
  • OAuth 2.0 apps request tweet.read users.read dm.read dm.write media.write offline.access and 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 custody & security
  • 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_version rotation monitored; offboarding deletes all key copies and instructs Reset Chat.
End-to-end & cutover
  • Tested: : → - URL conversion, new 1:1 conversation key setup, encrypted send & idempotent retry, chat.received / chat.sent / chat.conversation.join delivery & deduplication, encrypted media round-trip, message request accept, group create, and mark read.
  • Spec caveats handled (POST …/read omits seen_until_sequence_id; POST …/members hand-parsed); permanent 403s not retried in a loop; rate-limit headers and retry-after honored.
  • 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

For SDK-specific cryptography, backup recovery, and decryption issues, see Fix common X Chat problems.

Testing before cutover

To test the encrypted path before December 9, 2026, send your testing or staging app ID to your X account representative.The legacy DM allowlist is tracked per app ID, not per project. While an account has an active legacy DM connection through any allowlisted app (on either side of the chat), new 1:1 chats stay unencrypted and POST /2/chat/conversations/{id}/keys can fail with a 403 mentioning follows even when follows are not the issue.
1

Use clean test accounts on both sides

Test with X accounts on both sides that have never been connected to your production legacy DM integration.
2

Verify encryption eligibility first

Call GET /2/users/{id}?user.fields=receives_your_chat and confirm the pair returns encrypted.
3

Never loop on the 403 or re-register keys

If POST …/keys returns 403, stop retrying and verify neither test account is connected to an allowlisted legacy DM app.

Partner FAQ

Browse the Partner FAQ

Searchable answers to the questions partners ask most: timeline, sign-in and permissions, keys and PINs, events and endpoints, and common errors.