POST /2/chat/conversations/{id}/keys
Initializes encryption keys for a Chat conversation. This is the first step before sending messages in a new 1:1 conversation.
For 1:1 conversations, provide the recipient's user ID as the conversation_id. The server constructs the canonical conversation ID from the authenticated user and recipient.
The request body must contain the conversation key version and participant keys (the conversation key encrypted for each participant using their public key).
Workflow (1:1 conversation):
- Generate a conversation key using the SDK
- Encrypt the key for both participants using their public keys
- Call this endpoint to register the keys
- Send messages using
POST /chat/conversations/{id}/messages
Authentication:
- Requires OAuth 1.0a User Context or OAuth 2.0 User Context
- Required scopes:
tweet.read,users.read,dm.write
Servers
- https://api.x.com
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
id |
String | Yes |
The recipient's user ID for a 1:1 conversation, or a group conversation ID (prefixed with 'g'). |
Request headers
| Name | Type | Required | Description |
|---|---|---|---|
Content-Type |
String | Yes |
The media type of the request body.
Default value: "application/json" |
Request body fields
| Name | Type | Required | Description |
|---|---|---|---|
base64_encoded_key_rotation |
String | No |
Base64-encoded key rotation payload for ratchet tree key management. |
conversation_participant_keys[] |
Array | Yes |
The conversation key encrypted for each participant using their public key. |
conversation_participant_keys[].encrypted_conversation_key |
String | No |
Conversation key encrypted with this participant's public key. |
conversation_participant_keys[].public_key_version |
String | No |
Version of the participant's public key used for encryption. |
conversation_participant_keys[].user_id |
String | No |
Participant user ID. |
action_signatures[] |
Array | No |
Cryptographic signatures for the key initialization action. |
action_signatures[].message_id |
String | No |
ID of the message being signed. |
action_signatures[].message_event_signature |
Object | No |
Message event signature for verification. |
action_signatures[].message_event_signature.message_signing_key_info_list[] |
Array | No |
List of signing key information for message verification. |
action_signatures[].message_event_signature.message_signing_key_info_list[].member_id |
String | No |
The member ID associated with this signing key. |
action_signatures[].message_event_signature.message_signing_key_info_list[].signing_public_key |
String | No |
The signing public key. |
action_signatures[].message_event_signature.message_signing_key_info_list[].public_key_version |
String | No |
The version of the public key. |
action_signatures[].message_event_signature.signature |
String | No |
The signature of the message event. |
action_signatures[].message_event_signature.signing_public_key |
String | No |
The public key used for signing. |
action_signatures[].message_event_signature.signature_version |
String | No |
The version of the signature algorithm. |
action_signatures[].message_event_signature.public_key_version |
String | No |
The version of the public key used for signing. |
action_signatures[].encoded_message_event_detail |
String | No |
Base64-encoded message event detail. |
action_signatures[].signature_payload |
String | No |
Cryptographic signature payload. |
conversation_key_version |
String | Yes |
Version of the conversation encryption key (typically a timestamp in milliseconds). |
How to start integrating
- Add HTTP Task to your workflow definition.
- Search for the API you want to integrate with and click on the name.
- This loads the API reference documentation and prepares the Http request settings.
- Click Test request to test run your request to the API and see the API's response.