> ## Documentation Index
> Fetch the complete documentation index at: https://docs.x.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Send encrypted direct messages with the X Chat API

> Learn what the X Chat API offers: send and receive encrypted direct messages on X, with the Chat XDK handling the hard parts for you.

The **X Chat API** lets you send and receive **encrypted** direct messages on X. Message bodies are encrypted on the client; X routes ciphertext and cannot read plaintext content. Messages are also **signed** so recipients can verify the sender.

***

## What you need in your app

| Piece | Responsibility |
| :- | :- |
| **[Chat XDK](https://docs.x.com/xchat/xchat-xdk.md)** | Generate keys, encrypt/decrypt, sign/verify, optional passcode-protected secure key backup (Python, JS, Rust, Go, C#, Java) |
| **X API access** | Public keys, conversation keys, messages, events, media: via **[XDK](https://docs.x.com/xdks/python/overview.md)** (Python/TypeScript) or HTTPS |
| **Delivery** | [Webhooks or activity stream](https://docs.x.com/xchat/real-time-events.md) for live events; events API for history |

Follow **[Getting Started](https://docs.x.com/xchat/getting-started.md)** for a full implementation. For concepts only, see the **[Cryptography primer](https://docs.x.com/xchat/cryptography-primer.md)**.

***

## How encryption works (overview)

1. Create **identity** and **signing** keypairs; store private keys securely (secure key backup or protected blob).
2. **Publish public keys** so others can exchange conversation keys with you and verify signatures.
3. Share a **conversation key** by posting encrypted copies for each participant.
4. **Encrypt and sign** outbound messages; send only ciphertext to X.
5. **Receive** ciphertext via webhooks, stream, or event history.
6. **Verify and decrypt** with the Chat XDK.

***

## Useful endpoints

Grouped under **API reference** in the sidebar, including:

* Public keys: register and fetch
* Conversations and messages: list/get conversations, add/rotate keys, events, send, typing, read, group membership
* Media: upload and download encrypted attachments ([guide](https://docs.x.com/xchat/media.md))

***

## Auth notes

Use **OAuth 2.0 user context** with DM-related scopes (`dm.read`, `dm.write`, plus `users.read` / `tweet.read` as required; `media.write` for uploads). X Chat activity for a user requires that user's authorization. Secure key backup configuration is returned on **your** public-key record (`juicebox_config` field); see Getting Started.

***

## Next steps

1. [Cryptography primer](https://docs.x.com/xchat/cryptography-primer.md): optional background on encryption concepts
2. [Getting Started](https://docs.x.com/xchat/getting-started.md): implement keys, send, and receive
3. [Chat XDK](https://docs.x.com/xchat/xchat-xdk.md): encryption SDK reference
4. [Building UI apps with WASM](https://docs.x.com/xchat/building-ui-apps-with-wasm.md) and [Handling private keys](https://docs.x.com/xchat/handling-private-keys.md): keep keys on-device and treat PINs as root credentials
5. [Real-time events](https://docs.x.com/xchat/real-time-events.md), [Media](https://docs.x.com/xchat/media.md), or [Troubleshooting](https://docs.x.com/xchat/troubleshooting.md) when you need those topics
