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

Methods

AcceptMessageRequestAsync

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

string
required
The other user’s ID, or both user IDs joined by a hyphen.
Returns: Task<AcceptChatMessageRequestResponse>

AddConversationKeysAsync

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

string
required
id (path parameter).
AddConversationKeysRequest
required
Request payload.
Returns: Task<AddConversationKeysResponse>

AddGroupAdminsAsync

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

string
required
The ID of the group conversation, starting with g.
AddChatGroupAdminsRequest
required
Request payload.
Returns: Task<AddChatGroupAdminsResponse>

AddGroupMembersAsync

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

string
required
id (path parameter).
AddChatGroupMembersRequest
required
Request payload.
Returns: Task<AddChatGroupMembersResponse>

AddUserPublicKeyAsync

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

Parameters

string
required
id (path parameter).
AddUserPublicKeyRequest
required
Request payload.
Returns: Task<AddUserPublicKeyResponse>

ApproveGroupAdminRequestAsync

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

string
required
The ID of the group conversation, starting with g.
string
required
The ID of the user who requested admin permissions.
ApproveChatGroupAdminRequestRequest
required
Request payload.
Returns: Task<ApproveChatGroupAdminRequestResponse>

ArchiveConversationAsync

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

string
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.
ArchiveChatConversationRequest
required
Request payload.
Returns: Task<ArchiveChatConversationResponse>

CreateConversationAsync

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

Parameters

CreateChatConversationRequest
required
Request payload.
Returns: Task<CreateChatConversationResponse>

CreateGroupAdminRequestAsync

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

string
required
The ID of the group conversation, starting with g.
CreateChatGroupAdminRequestRequest
required
Request payload.
Returns: Task<CreateChatGroupAdminRequestResponse>

CreateGroupJoinRequestAsync

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

string
required
The ID of the group conversation, starting with g.
CreateChatGroupJoinRequestRequest
required
Request payload.
Returns: Task<CreateChatGroupJoinRequestResponse>

DeleteConversationAsync

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

string
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.
DeleteChatConversationRequest
required
Request payload.
Returns: Task<DeleteChatConversationResponse>

DeleteConversationMessageTtlAsync

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

string
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.
DeleteChatConversationMessageTtlRequest
required
Request payload.
Returns: Task<DeleteChatConversationMessageTtlResponse>

DeleteMessagesAsync

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

string
required
id (path parameter).
DeleteChatMessagesRequest
required
Request payload.
Returns: Task<DeleteChatMessagesResponse>

DisableGroupInviteAsync

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

string
required
The ID of the group conversation, starting with g.
DisableChatGroupInviteRequest
required
Request payload.
Returns: Task<DisableChatGroupInviteResponse>

EnableGroupInviteAsync

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/&lt;conversation_id&gt;/&lt;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

string
required
The ID of the group conversation, starting with g.
EnableChatGroupInviteRequest
required
Request payload.
Returns: Task<EnableChatGroupInviteResponse>

GetConversationAsync

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

string
required
id (path parameter).
Returns: Task<GetChatConversationResponse>

GetConversationEventsAsync

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

string
required
id (path parameter).
Returns: Task<GetChatConversationEventsResponse> (use GetConversationEventsPages(...) for IAsyncEnumerable page iteration)

GetConversationPinnedMessagesAsync

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

string
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: Task<GetChatConversationPinnedMessagesResponse> (use GetConversationPinnedMessagesPages(...) for IAsyncEnumerable page iteration)

GetConversationsAsync

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: Task<GetChatConversationsResponse> (use GetConversationsPages(...) for IAsyncEnumerable page iteration)

GetGroupAdminRequestsAsync

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

string
required
The ID of the group conversation, starting with g.
Returns: Task<GetChatGroupAdminRequestsResponse> (use GetGroupAdminRequestsPages(...) for IAsyncEnumerable page iteration)

GetGroupInviteAsync

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

string
required
The ID of the group conversation, starting with g.
string
required
The 10-character invite token from the group’s invite link.
Returns: Task<GetChatGroupInviteResponse>

GetMessageRequestAsync

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

string
required
The other user’s ID, or both user IDs joined by a hyphen.
Returns: Task<GetChatMessageRequestResponse>

GetMessageRequestsAsync

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: Task<GetChatMessageRequestsResponse> (use GetMessageRequestsPages(...) for IAsyncEnumerable page iteration)

GetSettingsAsync

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: Task<GetChatSettingsResponse>

InitializeGroupAsync

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: Task<InitializeChatGroupResponse>

MarkConversationReadAsync

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

string
required
id (path parameter).
MarkChatConversationReadRequest
required
Request payload.
Returns: Task<MarkChatConversationReadResponse>

MarkConversationUnreadAsync

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

string
required
id (path parameter).
Returns: Task<MarkChatConversationUnreadResponse>

MediaDownloadAsync

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

string
required
id (path parameter).
string
required
media_hash_key (path parameter).
Returns: Task<byte[]>

MediaUploadAppendAsync

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

Parameters

string
required
id (path parameter).
ChatMediaUploadAppendRequest
required
Request payload.
Returns: Task<ChatMediaUploadAppendResponse>

MediaUploadFinalizeAsync

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

Parameters

string
required
id (path parameter).
ChatMediaUploadFinalizeRequest
required
Request payload.
Returns: Task<ChatMediaUploadFinalizeResponse>

MediaUploadInitializeAsync

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

Parameters

ChatMediaUploadInitializeRequest
required
Request payload.
Returns: Task<ChatMediaUploadInitializeResponse>

MuteConversationAsync

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

string
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.
MuteChatConversationRequest
required
Request payload.
Returns: Task<MuteChatConversationResponse>

RejectGroupAdminRequestAsync

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

string
required
The ID of the group conversation, starting with g.
string
required
The ID of the user who requested admin permissions.
RejectChatGroupAdminRequestRequest
required
Request payload.
Returns: Task<RejectChatGroupAdminRequestResponse>

RejectGroupJoinRequestsAsync

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

string
required
The ID of the group conversation, starting with g.
RejectChatGroupJoinRequestsRequest
required
Request payload.
Returns: Task<RejectChatGroupJoinRequestsResponse>

RemoveGroupAdminsAsync

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

string
required
The ID of the group conversation, starting with g.
RemoveChatGroupAdminsRequest
required
Request payload.
Returns: Task<RemoveChatGroupAdminsResponse>

RemoveGroupMembersAsync

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

string
required
id (path parameter).
RemoveChatGroupMembersRequest
required
Request payload.
Returns: Task<RemoveChatGroupMembersResponse>

SendMessageAsync

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

string
required
A conversation’s id from Get Chat Conversations, or the recipient’s user ID for a 1:1 chat.
SendChatMessageRequest
required
At least one of encoded_message_create_event, content is required.
Returns: Task<SendChatMessageResponse>

SendTypingIndicatorAsync

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

string
required
id (path parameter).
Returns: Task<SendChatTypingIndicatorResponse>

UnarchiveConversationAsync

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

string
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.
UnarchiveChatConversationRequest
required
Request payload.
Returns: Task<UnarchiveChatConversationResponse>

UnmuteConversationAsync

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

string
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.
UnmuteChatConversationRequest
required
Request payload.
Returns: Task<UnmuteChatConversationResponse>

UpdateConversationMessageTtlAsync

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

string
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.
UpdateChatConversationMessageTtlRequest
required
Request payload.
Returns: Task<UpdateChatConversationMessageTtlResponse>

UpdateConversationScreenCaptureAsync

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

string
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.
UpdateChatConversationScreenCaptureRequest
required
At least one of blocking, detection is required.
Returns: Task<UpdateChatConversationScreenCaptureResponse>

UpdateGroupAsync

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

string
required
The ID of the group conversation, starting with g.
UpdateChatGroupRequest
required
Request payload.
Returns: Task<UpdateChatGroupResponse>

UpdateGroupAdminSettingsAsync

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

string
required
The ID of the group conversation, starting with g.
UpdateChatGroupAdminSettingsRequest
required
At least one of add_member, edit_group_info, send_message, start_call, edit_message_ttl, block_screen_capture is required.
Returns: Task<UpdateChatGroupAdminSettingsResponse>

UpdateSettingsAsync

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

UpdateChatSettingsRequest
required
At least one of allow_dms_from, always_allow_dms_from_subscribers, dm_quality_filter, dm_receipt_settings, av_settings is required.
Returns: Task<UpdateChatSettingsResponse>