Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions changelog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ keywords: ["changelog", "API updates", "release notes", "what's new", "API chang

To subscribe to updates, please [**“Turn on notifications”**](https://help.x.com/en/managing-your-account/notifications-on-mobile-devices#:~:text=In%20the%20top%20menu,%20you,you%20would%20like%20to%20receive) for [**@API**](https://x.com/api). You can also follow this changelog in your feed reader via the [**RSS feed**](https://docs.x.com/changelog/rss.xml).

<Update label="Dec 3, 2026" description="SDKs">
### Ruby bindings for Chat XDK (`chat_xdk`)

Official **Ruby** bindings for the X Chat encryption SDK are now available as the [`chat_xdk`](https://rubygems.org/gems/chat_xdk) gem (Ruby 3.0+):

- **Prebuilt native libraries:** Platform gems bundle `libchat_xdk_ffi` for macOS (`arm64-darwin`, `x86_64-darwin`), Linux (`x86_64-linux`, `aarch64-linux`), and Windows (`x64-mingw-ucrt`) with no Rust toolchain required.
- **Full API parity:** Key generation, Juicebox PIN-backed storage (`setup` / `unlock`), raw key export/import (`export_keys` / `import_keys`), batch and single-event decryption (`decrypt_events` / `decrypt_event`), automatic public-key resolution (`set_resolve_public_keys`), message and file encryption, and signed group/conversation actions.

Install with `gem install chat_xdk` and see [Chat XDK](/xchat/xchat-xdk) and [`chat-xdk/examples/ruby`](https://github.com/xdevplatform/chat-xdk/tree/main/examples/ruby).
</Update>

<Update label="Dec 2, 2026" description="SDKs">
### Java 8+ support for Chat XDK (`com.x:chatxdk`) and Java XDK (`com.x:xdk`)

Expand Down
13 changes: 10 additions & 3 deletions xchat/getting-started.mdx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
title: "Get started: send your first encrypted message"
sidebarTitle: Getting Started
description: "A hands-on tutorial that takes you from zero to your first encrypted X Chat message, in Python, TypeScript, Go, Rust, C#, or Java."
keywords: ["X Chat tutorial", "X Chat quickstart", "Chat XDK", "encrypted DM", "Python", "TypeScript", "Go", "Rust", "C#", "Java"]
description: "A hands-on tutorial that takes you from zero to your first encrypted X Chat message, in Python, TypeScript, Go, Rust, C#, Java, or Ruby."
keywords: ["X Chat tutorial", "X Chat quickstart", "Chat XDK", "encrypted DM", "Python", "TypeScript", "Go", "Rust", "C#", "Java", "Ruby"]
---

Send and receive encrypted direct messages on X: set up keys, initialize a conversation, send a message, and decrypt inbound traffic.
Expand Down Expand Up @@ -82,6 +82,13 @@ X Chat apps use two pieces together:

Available on Maven Central. The jar bundles the native library for macOS (arm64, x64), Linux (x64, arm64), and Windows (x64); no `jna.library.path` setup is needed. Import from `com.x.chatxdk`. Requires JDK 8+.
</Tab>
<Tab title="Ruby">
```bash
gem install chat_xdk
```

Available on RubyGems. Published platform gems bundle the native library for macOS (`arm64-darwin`, `x86_64-darwin`), Linux (`x86_64-linux`, `aarch64-linux`), and Windows (`x64-mingw-ucrt`). Import with `require "chat_xdk"`. Requires Ruby 3.0+.
</Tab>
</Tabs>

Create an API client with your **user** OAuth 2.0 access token:
Expand Down Expand Up @@ -269,7 +276,7 @@ Skip this step if you loaded existing keys in [step 2](#2-initialize-the-chat-xd
Finish by calling `set_identity` with the registration's key version, so this session signs as the new identity.

<Tip>
Ready-to-run one-time registration scripts for every binding live under [`chat-xdk/examples`](https://github.com/xdevplatform/chat-xdk/tree/main/examples) (Python, TypeScript, Go, Rust, C#, and Java). Use them instead of hand-rolling the flow below when you just need to onboard a new identity.
Ready-to-run one-time registration scripts for every binding live under [`chat-xdk/examples`](https://github.com/xdevplatform/chat-xdk/tree/main/examples) (Python, TypeScript, Go, Rust, C#, Java, and Ruby). Use them instead of hand-rolling the flow below when you just need to onboard a new identity.
</Tip>

<Tabs>
Expand Down
2 changes: 1 addition & 1 deletion xchat/introduction.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The **X Chat API** lets you send and receive **encrypted** direct messages on X.

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

Expand Down
69 changes: 69 additions & 0 deletions xchat/media.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,27 @@ Read the MIME type and dimensions from the plaintext for the attachment descript
byte[] encryptedBlob = chat.encryptFile(fileParams);
```
</Tab>
<Tab title="Ruby">
```ruby
require "chat_xdk"

plaintext = File.binread("photo.jpg")
mime = ChatXdk.detect_mime_type(plaintext)
dims = ChatXdk.detect_image_dimensions(plaintext)
width = dims&.width || 0
height = dims&.height || 0
# payload: from encrypt_message with media_hash_key in its attachments
encrypted_blob = chat.encrypt_file(
ChatXdk::EncryptFileParams.new(
file: plaintext,
event_b64: payload.event_b64,
media_hash_key: media_hash_key,
conversation_key: raw_conv_key,
conversation_key_version: conversation_key_version
)
)
```
</Tab>
</Tabs>

`encrypt_file` / `decrypt_file` process the whole file in memory. For large files, `file_encryptor` / `file_decryptor` take the same parameters without the file bytes and return incremental objects: feed chunks with `push`, then call `finish` once; `finish` errors if the file was truncated.
Expand Down Expand Up @@ -314,6 +335,30 @@ Encrypt with a media attachment, then POST the send-message body (same field map
// and payload.encodedEventSignature to /2/chat/conversations/{id}/messages
```
</Tab>
<Tab title="Ruby">
```ruby
# chat has keys loaded and set_identity called (see Getting Started)
payload = chat.encrypt_message(
ChatXdk::EncryptMessageParams.new(
conversation_id: conversation_id,
text: caption || "",
conversation_key: raw_conv_key,
conversation_key_version: conversation_key_version,
attachments: [
ChatXdk::AttachmentDescriptor.media(
media_hash_key: media_hash_key,
width: width,
height: height,
filesize_bytes: ChatXdk.encrypted_file_size(plaintext.bytesize),
filename: "photo.jpg"
)
]
)
)
# POST payload.message_id (generated by the SDK), payload.encoded_message_create_event,
# and payload.encoded_message_event_signature to /2/chat/conversations/{id}/messages
```
</Tab>
</Tabs>

The conversation key pair can be omitted entirely: with `set_cache_keys(true)` enabled, `encrypt_message` resolves the key and version from the conversation's latest verified key change (see [Getting Started](/xchat/getting-started)).
Expand Down Expand Up @@ -424,6 +469,30 @@ Path: [`GET /2/chat/media/{conversation_id}/{media_hash_key}`](/x-api/chat/downl
String mime = ChatXdkUtilities.detectMimeType(plaintext);
```
</Tab>
<Tab title="Ruby">
```ruby
require "net/http"
require "uri"
require "chat_xdk"

api_id = conversation_id.tr(":", "-")
uri = URI.parse("https://api.x.com/2/chat/media/#{api_id}/#{media_hash_key}")
req = Net::HTTP::Get.new(uri)
req["Authorization"] = "Bearer #{access_token}"
res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |http| http.request(req) }

# event_b64: the message's event; keys: result.conversation_keys.keys
plaintext = chat.decrypt_file(
ChatXdk::DecryptFileParams.new(
encrypted: res.body.b,
event_b64: event_b64,
conversation_keys: keys,
media_hash_key: media_hash_key
)
)
mime = ChatXdk.detect_mime_type(plaintext) || "application/octet-stream"
```
</Tab>
</Tabs>

---
Expand Down
5 changes: 3 additions & 2 deletions xchat/migrate-from-legacy-dms.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ Existing conversations are upgraded on X's side — you do **not** need to migra
| **Python** (`chatxdk`, `import chat_xdk`) | `pip install chatxdk` | Python 3.10+. Supports Juicebox unlock and `export_keys` / `import_keys`. |
| **JS / TS (browser)** (`@xdevplatform/chat-xdk`) | `npm install @xdevplatform/chat-xdk juicebox-sdk` | WASM for browsers and Node 18+. Keys stay in Juicebox secure key backup (**no key export**). |
| **Node.js (server)** (`@xdevplatform/chat-xdk-server`) | `npm install @xdevplatform/chat-xdk-server` | Server-side `exportKeys` / `importKeys`. Never bundle into a browser app. |
| **Go, Rust, .NET 8+, JVM (JDK 8+)** | See [Chat XDK](/xchat/xchat-xdk) | Native bindings supporting `export_keys` / `import_keys`. Go ships prebuilt libraries for macOS and Linux `amd64` only (on Linux `ARM64`, use Python or `@xdevplatform/chat-xdk-server`). |
| **Go, Rust, .NET 8+, JVM (JDK 8+)** | See [Chat XDK](/xchat/xchat-xdk) | Native bindings supporting `export_keys` / `import_keys`. Go ships prebuilt libraries for macOS and Linux `amd64` only (on Linux `ARM64`, use Python, Ruby, or `@xdevplatform/chat-xdk-server`). |
| **Ruby** (`chat_xdk`, `require "chat_xdk"`) | `gem install chat_xdk` | Ruby 3.0+. Bundles prebuilt native libraries for macOS (`arm64`, `x64`), Linux (`x64`, `arm64`), and Windows (`x64`). Supports Juicebox unlock and `export_keys` / `import_keys`. |

There are no Ruby or PHP bindings — run encryption in a small service in a supported language and call it from your app. For REST transport, use the official XDK (`pip install xdk` / `npm install @xdevplatform/xdk`) or any HTTP client.
</Tab>
Expand Down Expand Up @@ -237,7 +238,7 @@ OAuth access and encryption keys are **separate control planes**: an OAuth token
</Step>

<Step title="Unlock once and export (approved server-side custody)">
Construct a server/native Chat XDK instance (`@xdevplatform/chat-xdk-server`, Python, 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.
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.
</Step>
Expand Down
Loading
Loading