Skip to content
Twexapi
English
Esc
navigateopen⌘Jpreview

Send DM (XChat v3)

Send DM via XChat encrypted chat API (1 or existing group g…), optional image via media_urls (max 1) or video via video_url (mutually exclusive). $0.0005 per call.

POST/v3/twitter/send-dm
Authorization
AuthorizationBearer token · headerrequired
Global API Bearer Token for TwexAPI. Included as: Authorization: Bearer <YOUR_TWEXAPI_KEY>.
Request Body
requiredapplication/json
recipientstringrequired
User id, @handle, or a group id (g...) for an existing group.
textstringrequired
Message body.
media_urlsstring[] | any
Public URL of one image to attach (max 1). Mutually exclusive with video_url.
Show properties
Any of:
string[]
Array of string
string
any
any
video_urlstring | any
Public http(s) URL of one video to attach (mutually exclusive with image).
Show properties
Any of:
string
string
any
any
pinstring | any
Identity PIN (default 1234).
default: "1234"
Show properties
Any of:
string
string
any
any
cookiestringrequired
The user's own authorized Twitter session credentials or auth_token (BYOC — Bring Your Own Cookie). Stateless proxy execution with zero credential retention. See [Authentication Security](/authentication#write-operations--byoc-bring-your-own-cookie) and [How to get Cookie](https://youtube-promotion.pages.dev/how-to-get-twitter-cookie).
proxystring | any
Optional HTTP proxy. Example: http://username:password@ip:port
Show properties
Any of:
string
string
any
any
Responses
200A message object.
codeintegerrequired
Response code
msgstringrequired
Message sent
dataMessageModel | anyrequired
message object
Show properties
Any of:
MessageModel
idstringrequired
Message ID
textstringrequired
Message text
timestringrequired
Message time
attachmentobject | any
Message attachment
Show properties
Any of:
object
object
any
any
attachmentsobject[] | any
XChat media attachments (v3).
Show properties
Any of:
object[]
Array of object
object
any
any
sequence_idstring | any
XChat sequence id. Use the oldest message's sequence_id as before for pagination.
Show properties
Any of:
string
string
any
any
sender_idstring | any
Sender ID
Show properties
Any of:
string
string
any
any
recipient_idstring | any
Recipient ID
Show properties
Any of:
string
string
any
any
any
any
422Validation Error
detailValidationError[]
Show properties
Array of ValidationError
locstring | integer[]required
Show properties
Array of string | integer
Any of:
string
string
integer
integer
msgstringrequired
typestringrequired
inputany
ctxobject
Interactive ConsolePOST
Interactive Console / Try APIPOST
Live Console
🌐Target Server:https://api.twexapi.io
● Production Ready
✍️
Write Operation Credentials Guide (TwexAPI Key + Twitter Cookie)

1. TwexAPI Platform Key (Bearer Token): Enter under "API Authorization" below for request billing & authentication.

2. Twitter Account Cookie: For write operations (tweet, like, follow, etc.), provide the target Twitter account's Cookie (e.g. auth_token=...; ct0=...) in the cookie field of Request Body below.

🔑API Authorization
📝Request Bodyapplication/json
📡
No Response Yet

Configure parameters in the Request tab and click Send Request below.

Request
curl -X POST "https://api.twexapi.io/v3/twitter/send-dm" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "recipient": "baker_donn80196",
  "text": "hello from docs",
  "media_urls": [
    "https://example.com/image.jpg"
  ],
  "video_url": "https://video.twimg.com/amplify_video/2077160248830275584/vid/avc1/320x568/kwNDLTm",
  "pin": "1234",
  "cookie": "ct0=abc123... or 2c4a4e1832096aa694c739b83c83b6d96d43eba7",
  "proxy": "http://username:password@ip:port"
}'
Response
{
  "code": 200,
  "msg": "success",
  "data": {
    "attachment": {
      "type": "image",
      "url": "https://example.com/image.jpg"
    },
    "id": "1234567890123456789",
    "text": "Hello, how are you?",
    "time": "2024-01-01T12:00:00Z"
  }
}