Skip to main content
Access Chat endpoints via client.chat (ChatClient).

Methods

accept_message_request

POST /2/chat/message_requests/{id}/accept Accept a Chat Message Request Accepts the other user’s pending message request in a 1:1 Chat conversation, which moves to the authenticated user’s inbox. Without a pending request, including after a successful accept, the response is 404. Replying to a request does not accept it.

Parameters

str
required
The other user’s ID, or both user IDs joined by a hyphen.
Returns: AcceptMessageRequestResponse

add_conversation_keys

POST /2/chat/conversations/{id}/keys Add Conversation Keys Adds (initializes or rotates) the encryption keys for a Chat conversation. Call this before sending messages in a new 1:1 conversation, and again with a newer key version to rotate the conversation key. 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).

Parameters

str
required
id (path parameter).
AddConversationKeysRequest
required
Request payload.
Returns: AddConversationKeysResponse

add_group_admins

POST /2/chat/conversations/{id}/admins Add Admins to a Chat Group Conversation Grants admin rights to one or more members of an existing encrypted Chat group conversation.

Parameters

str
required
The ID of the group conversation, starting with g.
AddGroupAdminsRequest
required
Request payload.
Returns: AddGroupAdminsResponse

add_group_members

POST /2/chat/conversations/{id}/members Add Members to a Chat Group Conversation Adds one or more members to an existing encrypted Chat group conversation, rotating the conversation key. Adding a user who has a pending join request approves that request; approval needs the same key-rotation body as adding any member.

Parameters

str
required
id (path parameter).
AddGroupMembersRequest
required
Request payload.
Returns: AddGroupMembersResponse

add_user_public_key

POST /2/users/{id}/public_keys Add Public Key Registers a user’s public key for X Chat encryption.

Parameters

schemas.UserId
required
id (path parameter).
AddUserPublicKeyRequest
required
Request payload.
Returns: AddUserPublicKeyResponse

approve_group_admin_request

POST /2/chat/conversations/{id}/admin_requests/{user_id}/approve Approve an Admin Request in a Chat Group Conversation Makes the user who requested admin permissions an admin of an encrypted Chat group conversation. Only a group admin can approve.

Parameters

str
required
The ID of the group conversation, starting with g.
str
required
The ID of the user who requested admin permissions.
ApproveGroupAdminRequestRequest
required
Request payload.
Returns: ApproveGroupAdminRequestResponse

archive_conversation

POST /2/chat/conversations/{id}/archive Archive a Chat Conversation Archives a Chat conversation for the authenticated user only. Archiving an archived conversation changes nothing. Works for group and 1:1 conversations. For 1:1 conversations, provide the recipient’s user ID; the server constructs the canonical conversation ID from the authenticated user and recipient.

Parameters

str
required
The ID of the conversation: a group ID starting with g, the other user’s ID for a 1:1 conversation, or both user IDs of a 1:1 conversation joined by a hyphen.
ArchiveConversationRequest
required
Request payload.
Returns: ArchiveConversationResponse

create_conversation

POST /2/chat/conversations/group Create Chat Group Conversation Creates a new encrypted Chat group conversation on behalf of the authenticated user.

Parameters

CreateConversationRequest
required
Request payload.
Returns: CreateConversationResponse

create_group_admin_request

POST /2/chat/conversations/{id}/admin_requests Request Admin Permissions in a Chat Group Conversation Asks the admins of an encrypted Chat group conversation to make the authenticated user an admin. An admin approves or rejects the request.

Parameters

str
required
The ID of the group conversation, starting with g.
CreateGroupAdminRequestRequest
required
Request payload.
Returns: CreateGroupAdminRequestResponse

create_group_join_request

POST /2/chat/conversations/{id}/join_requests Request to Join a Chat Group Asks to join an encrypted Chat group conversation through its invite link. The request stays pending until a group admin adds the user to the group.

Parameters

str
required
The ID of the group conversation, starting with g.
CreateGroupJoinRequestRequest
required
Request payload.
Returns: CreateGroupJoinRequestResponse

delete_conversation

DELETE /2/chat/conversations/{id} Delete a Chat Conversation Deletes a Chat conversation for the authenticated user only; other participants keep it. Works for group and 1:1 conversations. For 1:1 conversations, provide the recipient’s user ID; the server constructs the canonical conversation ID from the authenticated user and recipient. Deleting a pending message request’s conversation deletes the request, like Delete in the X app.

Parameters

str
required
The ID of the conversation: a group ID starting with g, the other user’s ID for a 1:1 conversation, or both user IDs of a 1:1 conversation joined by a hyphen.
DeleteConversationRequest
required
Request payload.
Returns: DeleteConversationResponse

delete_conversation_message_ttl

DELETE /2/chat/conversations/{id}/message_ttl Turn Off Disappearing Messages in a Chat Conversation Stops new messages in a 1:1 or group Chat conversation from disappearing, for every participant. For 1:1 conversations, provide the recipient’s user ID; the server constructs the canonical conversation ID from the authenticated user and recipient.

Parameters

str
required
The ID of the conversation: a group ID starting with g, the other user’s ID for a 1:1 conversation, or both user IDs of a 1:1 conversation joined by a hyphen.
DeleteConversationMessageTtlRequest
required
Request payload.
Returns: DeleteConversationMessageTtlResponse

delete_messages

POST /2/chat/conversations/{id}/messages/delete Delete Chat Messages Deletes one or more messages from a Chat conversation. For 1:1 conversations, provide the recipient’s user ID; the server constructs the canonical conversation ID from the authenticated user and recipient. Delete for all removes a message you sent (or, in groups you administer, any message) for every participant; delete for self removes any message only from your own view.

Parameters

str
required
id (path parameter).
DeleteMessagesRequest
required
Request payload.
Returns: DeleteMessagesResponse

disable_group_invite

DELETE /2/chat/conversations/{id}/invite Disable a Chat Group Invite Link Turns off the invite link for an encrypted Chat group conversation. The existing link stops working.

Parameters

str
required
The ID of the group conversation, starting with g.
DisableGroupInviteRequest
required
Request payload.
Returns: DisableGroupInviteResponse

enable_group_invite

POST /2/chat/conversations/{id}/invite Enable a Chat Group Invite Link Turns on the invite link for an encrypted Chat group conversation and returns the link details. The client builds the link and sends it as invite_url, in the form https://x.com/i/chat/group_join/<conversation_id>/<token>, where the token is exactly 10 letters, digits, ’-’ or ’_’. invite_url is required when action_signatures is sent. To make the link expire, send validity_duration_msec or validity_expiry_timestamp_msec. With action_signatures, send validity_expiry_timestamp_msec, because the signed payload carries the expiry. The group name and avatar sent here are stored unencrypted and shown to anyone who opens the link.

Parameters

str
required
The ID of the group conversation, starting with g.
EnableGroupInviteRequest
required
Request payload.
Returns: EnableGroupInviteResponse

get_conversation

GET /2/chat/conversations/{id} Get Chat Conversation Returns metadata for a Chat conversation including type, muted status, group details, and your unread state. For the unread state, request chat_conversation.fields=unread,last_read_event_id,newest_event_id: those fields give your read state, computed from your latest read receipt and the conversation’s latest notifying message. Use chat_conversation.fields to select which fields are returned. Use expansions to hydrate member, admin, or participant user objects. Use user.fields to control which profile fields are returned for expanded users; in a 1:1 chat, user.fields=receives_your_chat on the participant says how you can message them: encrypted, unencrypted, or none.

Parameters

str
required
id (path parameter).
Returns: GetConversationResponse

get_conversation_events

GET /2/chat/conversations/{id}/events Paginated Get Chat Conversation Events Retrieves the events of a specific Chat conversation, newest first, with pagination support: messages, key changes, group changes, and read receipts. Events with an id above the conversation’s last_read_event_id are unread: they come after the point you read up to. To collect them, page until an event’s id is at or below it. Only id and encoded_event are always present. Events are either end-to-end encrypted or unencrypted, such as messages sent before the conversation was encrypted. Encrypted events carry conversation_key_version, and usually conversation_token and message_event_signature; treat an encrypted event without message_event_signature as unverified. An event without conversation_key_version is unencrypted. Decode each encoded_event client-side, and decrypt it with the conversation key named by conversation_key_version when that is present. A page holds up to max_results events and can hold fewer while has_more is true. For 1:1 conversations, provide the recipient’s user ID; the server constructs the canonical conversation ID from the authenticated user and recipient.

Parameters

str
required
id (path parameter).
Returns: Iterator[GetConversationEventsResponse]

get_conversation_pinned_messages

GET /2/chat/conversations/{id}/pinned_messages Paginated Get Chat Conversation Pinned Messages Retrieves the pinned message events of a Chat conversation with pagination support. Each event is a Base64-encoded Thrift pin event whose contents are end-to-end encrypted; decode and decrypt it client-side. For 1:1 conversations, provide the recipient’s user ID; the server constructs the canonical conversation ID from the authenticated user and recipient.

Parameters

str
required
The ID of the conversation: a group ID starting with g, the other user’s ID for a 1:1 conversation, or both user IDs of a 1:1 conversation joined by a hyphen.
Returns: Iterator[GetConversationPinnedMessagesResponse]

get_conversations

GET /2/chat/conversations Paginated Get Chat Conversations Retrieves a list of Chat conversations for the authenticated user’s inbox, newest first: the most recently active conversation comes first. To find the chat with a particular person, start with participant_query set to their @username or name; with expansions=participant_ids, user.fields=receives_your_chat says how you can message each match. The unread, last_read_event_id and newest_event_id fields give your read state, computed from your latest read receipt and each conversation’s latest notifying message. Request them with chat_conversation.fields=unread,last_read_event_id,newest_event_id. The filters unread_only, type, is_archived, is_muted, participant_ids, participant_query, start_time and end_time are optional, and all filters must match (AND). participant_query keeps conversations where another participant’s username, or a word of their display name, starts with the query, ignoring case and accents; with a leading @ it matches usernames only. It considers the 100 people who best match the query, uses only public profile information, and never matches group names, nicknames or messages. start_time and end_time apply to the time of each conversation’s latest message. Each page covers max_results conversations and returns those that match, so a page can hold fewer than max_results, or none, while meta.next_token is set and has_more is true: keep paging, passing meta.next_token as pagination_token. Once a page reaches a conversation whose latest message is older than start_time, has_more is false. A pagination_token only works with the same filters as the request that returned it; with other filters, the request fails with a 400. When both are provided, start_time must be earlier than end_time.

Parameters

Returns: Iterator[GetConversationsResponse]

get_group_admin_requests

GET /2/chat/conversations/{id}/admin_requests Paginated Get Pending Admin Requests for a Chat Group Conversation Returns the users who have asked to become admins of an encrypted Chat group conversation. Only a group admin can list admin requests. Use user.fields to select which profile fields are returned.

Parameters

str
required
The ID of the group conversation, starting with g.
Returns: Iterator[GetGroupAdminRequestsResponse]

get_group_invite

GET /2/chat/conversations/{id}/invites/{token} Get a Chat Group Invite Link Returns the preview of an encrypted Chat group conversation from its invite link: group name, avatar, member count, and the authenticated user’s join state. The conversation ID and the token both come from the invite link.

Parameters

str
required
The ID of the group conversation, starting with g.
str
required
The 10-character invite token from the group’s invite link.
Returns: GetGroupInviteResponse

get_message_request

GET /2/chat/message_requests/{id} Get Chat Message Request Retrieves the message request state of a 1:1 Chat conversation and its newest message events. Like opening the request in an X app, reading it marks the returned messages as delivered and updates the unread badge.

Parameters

str
required
The other user’s ID, or both user IDs joined by a hyphen.
Returns: GetMessageRequestResponse

get_message_requests

GET /2/chat/message_requests Paginated Get Chat Message Requests Retrieves the authenticated user’s pending Chat message requests from one inbox. Message contents are end-to-end encrypted unless the conversation is unencrypted. Accepting or deleting requests between pages can skip or repeat requests, and a page can be empty while next_token is set.

Parameters

Returns: Iterator[GetMessageRequestsResponse]

get_settings

GET /2/chat/settings Get Chat Settings Returns the authenticated user’s Chat privacy settings: who can message them, read receipts, the message quality filter, and audio/video call permissions.

Parameters

Returns: GetSettingsResponse

initialize_group

POST /2/chat/conversations/group/initialize Initialize Chat Group Initializes a new Chat group conversation and returns a unique conversation ID. Use the returned conversation_id in a subsequent POST /chat/conversations/group call to fully create and configure the group.
Returns: InitializeGroupResponse

mark_conversation_read

POST /2/chat/conversations/{id}/read Mark Conversation as Read Marks a specific Chat conversation as read on behalf of the authenticated user. For 1:1 conversations, provide the recipient’s user ID; the server constructs the canonical conversation ID from the authenticated user and recipient. Without action_signatures the conversation is marked read up to its newest event and the read receipt is unsigned. With one action signature over a MarkConversationReadEvent, the server sends that signed read receipt, marking the conversation read up to the event it names.

Parameters

str
required
id (path parameter).
MarkConversationReadRequest
required
Request payload.
Returns: MarkConversationReadResponse

mark_conversation_unread

POST /2/chat/conversations/{id}/unread Mark Conversation as Unread Marks a specific Chat conversation as unread on behalf of the authenticated user. For 1:1 conversations, provide the recipient’s user ID; the server constructs the canonical conversation ID from the authenticated user and recipient.

Parameters

str
required
id (path parameter).
Returns: MarkConversationUnreadResponse

media_download

GET /2/chat/media/{id}/{media_hash_key} Download Chat Media Downloads encrypted media bytes from an XChat conversation. The response body contains raw binary bytes. A media item too large to return in one response fails with a 413 problem of type https://api.x.com/2/problems/response-too-large, and a retry fails the same way.

Parameters

str
required
id (path parameter).
str
required
media_hash_key (path parameter).
Returns: bytes

media_upload_append

POST /2/chat/media/upload/{id}/append Append Chat Media Upload Appends media data to an XChat upload session.

Parameters

str
required
id (path parameter).
MediaUploadAppendRequest
required
Request payload.
Returns: MediaUploadAppendResponse

media_upload_finalize

POST /2/chat/media/upload/{id}/finalize Finalize Chat Media Upload Finalizes an XChat media upload session.

Parameters

str
required
id (path parameter).
MediaUploadFinalizeRequest
required
Request payload.
Returns: MediaUploadFinalizeResponse

media_upload_initialize

POST /2/chat/media/upload/initialize Initialize Chat Media Upload Initializes an XChat media upload session.

Parameters

MediaUploadInitializeRequest
required
Request payload.
Returns: MediaUploadInitializeResponse

mute_conversation

POST /2/chat/conversations/{id}/mute Mute a Chat Conversation Mutes notifications for a Chat conversation for the authenticated user only. Works for group and 1:1 conversations. For 1:1 conversations, provide the recipient’s user ID; the server constructs the canonical conversation ID from the authenticated user and recipient.

Parameters

str
required
The ID of the conversation: a group ID starting with g, the other user’s ID for a 1:1 conversation, or both user IDs of a 1:1 conversation joined by a hyphen.
MuteConversationRequest
required
Request payload.
Returns: MuteConversationResponse

reject_group_admin_request

POST /2/chat/conversations/{id}/admin_requests/{user_id}/reject Reject an Admin Request in a Chat Group Conversation Declines a user’s pending request for admin permissions in an encrypted Chat group conversation. Only a group admin can reject.

Parameters

str
required
The ID of the group conversation, starting with g.
str
required
The ID of the user who requested admin permissions.
RejectGroupAdminRequestRequest
required
Request payload.
Returns: RejectGroupAdminRequestResponse

reject_group_join_requests

POST /2/chat/conversations/{id}/join_requests/reject Reject Join Requests for a Chat Group Conversation Rejects pending requests to join an encrypted Chat group conversation. Only group admins can reject requests. To approve a request instead, add the requesting users with addChatGroupMembers; adding a user clears their pending request.

Parameters

str
required
The ID of the group conversation, starting with g.
RejectGroupJoinRequestsRequest
required
Request payload.
Returns: RejectGroupJoinRequestsResponse

remove_group_admins

POST /2/chat/conversations/{id}/admins/remove Remove Admins from a Chat Group Conversation Revokes admin rights from one or more admins of an existing encrypted Chat group conversation. They stay members of the group.

Parameters

str
required
The ID of the group conversation, starting with g.
RemoveGroupAdminsRequest
required
Request payload.
Returns: RemoveGroupAdminsResponse

remove_group_members

POST /2/chat/conversations/{id}/members/remove Remove Members from a Chat Group Conversation Removes one or more members from an existing encrypted Chat group conversation. To leave a group, pass your own user ID. Leaving does not delete the conversation for the caller. When the removal rotates the conversation key, send group_key_rotation_data and the action signatures for the removal and the key change, in that order.

Parameters

str
required
id (path parameter).
RemoveGroupMembersRequest
required
Request payload.
Returns: RemoveGroupMembersResponse

send_message

POST /2/chat/conversations/{id}/messages Send Chat Message Sends a message or reaction to a Chat conversation, which you can find with participant_query on Get Chat Conversations. Send it end-to-end encrypted by default: encoded_message_create_event, built with the Chat XDK. Plaintext content is only a fallback for a 1:1 chat that X Chat can’t encrypt: use it only when the recipient’s receives_your_chat user field (user.fields=receives_your_chat) is unencrypted. When content is refused, nothing is sent and the problem’s detail says why; HTTP 400 https://api.x.com/2/problems/encryption-required means the chat can be encrypted or is a group, so send it encrypted instead. A recipient you can’t message (closed inbox, system account, or a block) returns HTTP 403 https://api.x.com/2/problems/recipient-not-messageable.

Parameters

str
required
A conversation’s id from Get Chat Conversations, or the recipient’s user ID for a 1:1 chat.
SendMessageRequest
required
At least one of encoded_message_create_event, content is required.
Returns: SendMessageResponse

send_typing_indicator

POST /2/chat/conversations/{id}/typing Send Typing Indicator Sends a typing indicator to a specific Chat conversation on behalf of the authenticated user. For 1:1 conversations, provide the recipient’s user ID; the server constructs the canonical conversation ID from the authenticated user and recipient.

Parameters

str
required
id (path parameter).
Returns: SendTypingIndicatorResponse

unarchive_conversation

DELETE /2/chat/conversations/{id}/archive Unarchive a Chat Conversation Unarchives a Chat conversation for the authenticated user only. Unarchiving a conversation that is not archived changes nothing. Works for group and 1:1 conversations. For 1:1 conversations, provide the recipient’s user ID; the server constructs the canonical conversation ID from the authenticated user and recipient.

Parameters

str
required
The ID of the conversation: a group ID starting with g, the other user’s ID for a 1:1 conversation, or both user IDs of a 1:1 conversation joined by a hyphen.
UnarchiveConversationRequest
required
Request payload.
Returns: UnarchiveConversationResponse

unmute_conversation

DELETE /2/chat/conversations/{id}/mute Unmute a Chat Conversation Unmutes notifications for a Chat conversation for the authenticated user only. Works for group and 1:1 conversations. For 1:1 conversations, provide the recipient’s user ID; the server constructs the canonical conversation ID from the authenticated user and recipient.

Parameters

str
required
The ID of the conversation: a group ID starting with g, the other user’s ID for a 1:1 conversation, or both user IDs of a 1:1 conversation joined by a hyphen.
UnmuteConversationRequest
required
Request payload.
Returns: UnmuteConversationResponse

update_conversation_message_ttl

PUT /2/chat/conversations/{id}/message_ttl Turn On Disappearing Messages in a Chat Conversation Sets how long new messages in a 1:1 or group Chat conversation last before they disappear, for every participant. For 1:1 conversations, provide the recipient’s user ID; the server constructs the canonical conversation ID from the authenticated user and recipient.

Parameters

str
required
The ID of the conversation: a group ID starting with g, the other user’s ID for a 1:1 conversation, or both user IDs of a 1:1 conversation joined by a hyphen.
UpdateConversationMessageTtlRequest
required
Request payload.
Returns: UpdateConversationMessageTtlResponse

update_conversation_screen_capture

PUT /2/chat/conversations/{id}/screen_capture Update Screen Capture Settings for a Chat Conversation Turns screenshot blocking or screenshot detection on or off in a Chat conversation, for every participant. In a group conversation, only admins can change these settings. Each request changes one setting: send either blocking or detection. For 1:1 conversations, provide the recipient’s user ID; the server constructs the canonical conversation ID from the authenticated user and recipient.

Parameters

str
required
The ID of the conversation: a group ID starting with g, the other user’s ID for a 1:1 conversation, or both user IDs of a 1:1 conversation joined by a hyphen.
UpdateConversationScreenCaptureRequest
required
At least one of blocking, detection is required.
Returns: UpdateConversationScreenCaptureResponse

update_group

PUT /2/chat/conversations/{id} Update a Chat Group Conversation Renames an encrypted Chat group conversation, changes its avatar, or sets its description. The client encrypts each value with the conversation key and lists the values it changed in modified_fields.

Parameters

str
required
The ID of the group conversation, starting with g.
UpdateGroupRequest
required
Request payload.
Returns: UpdateGroupResponse

update_group_admin_settings

PUT /2/chat/conversations/{id}/admin_settings Update the Admin-Only Settings of a Chat Group Conversation Sets which actions only admins can perform in an existing encrypted Chat group conversation. A setting set to true restricts that action to admins, and false opens it to all members. Setting send_message to true makes the group announcement-only. Omitted settings keep their stored value. When sending action_signatures, sign over the full merged settings: the stored values with this request’s changes applied, not only the settings in the request.

Parameters

str
required
The ID of the group conversation, starting with g.
UpdateGroupAdminSettingsRequest
required
At least one of add_member, edit_group_info, send_message, start_call, edit_message_ttl, block_screen_capture is required.
Returns: UpdateGroupAdminSettingsResponse

update_settings

PUT /2/chat/settings Update Chat Settings Updates the authenticated user’s Chat privacy settings: who can message them, read receipts, the message quality filter, and audio/video call permissions. allow_dms_from, dm_receipt_settings, and dm_quality_filter accept only their listed values, matched exactly and case-sensitively; anything else is a 400. av_settings must set at least one of its settings. Whether settings omitted from a partial av_settings keep their values or are reset is not yet confirmed; send every av_settings field you want to keep.

Parameters

UpdateSettingsRequest
required
At least one of allow_dms_from, always_allow_dms_from_subscribers, dm_quality_filter, dm_receipt_settings, av_settings is required.
Returns: UpdateSettingsResponse