Account actions

Send a message

Send an encrypted text message to a conversation or to a user.

The message is encrypted and signed with your chat key, like on x.com. The first message to a person you have not written to yet starts the encrypted conversation; that person needs X Chat (encrypted messages) on their account. Text only, no media.

Reference: https://www.twittrapi.com/docs/account-actions/client-dm-send

post/client/dm/send

Request

  • Base URL: https://api.twittrapi.com
  • URL: https://api.twittrapi.com/client/dm/send
  • Auth: API key in header X-API-KEY

Query parameters

format'raw' | 'simple'

raw (default): X's JSON passed through. simple: flat camelCase JSON with a fixed schema and a {data, nextCursor, previousCursor, hasNextPage} envelope. Same price. The header X-Response-Format: simple does the same.

Request body

cookiestring required

Cookie header of your own logged-in X session. Must contain auth_token, ct0 and twid (your account ID, set by x.com at login); guest_id is used when present.

proxystring required

Your proxy, format http://user:pass@host:port. The requests to X go out through it. Used only for this request.

passcodestring required

Your X Chat passcode, the one you set up for encrypted messages on X. Send it as a string (a number works too, but loses leading zeros), up to 64 characters. It unlocks your chat keys for this request and is not saved. The unlocked keys stay in the server's memory for up to 30 minutes, so follow-up calls need no new unlock.

conversation_idstring

ID of the conversation, as returned by /client/dm/inbox. A one-to-one chat has the ID <smaller user ID>:<larger user ID>. Letters, digits, colon, hyphen and underscore, up to 128 characters. Either conversation_id or user_id is required.

user_idstring

Numeric ID of the other person (up to 20 digits) for a one-to-one chat. Used when conversation_id is not set.

textstring required

Message text, up to 10,000 characters. Must not be empty or only spaces.

Response

{conversation_id, id (sequence ID), message_id, created_at (Unix milliseconds), text}.

With format=simple: {data: {id, messageId, conversationId, createdAt, text}}. createdAt is RFC 3339.

RawPassthrough required

X's own JSON (raw format, the default), passed through unchanged. The shape is X's and can change; see https://www.twittrapi.com/docs/response-format.

Changes

No recorded changes to this operation across all 1 revision of this API.