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.
Back to API Reference
/DM Endpoints
POST
/v3/twitter/send-dmAuthorization
AuthorizationBearer token · headerrequiredGlobal API Bearer Token for TwexAPI. Included as: Authorization: Bearer <YOUR_TWEXAPI_KEY>.
Request Body
requiredapplication/jsonrecipientstringrequiredUser id, @handle, or a group id (g...) for an existing group.
textstringrequiredMessage body.
media_urlsstring[] | anyPublic URL of one image to attach (max 1). Mutually exclusive with video_url.
Show propertiesHide properties
Any of:
string[]
Array of
stringstringany
anyvideo_urlstring | anyPublic http(s) URL of one video to attach (mutually exclusive with image).
Show propertiesHide properties
Any of:
string
stringany
anypinstring | anyIdentity PIN (default 1234).
default: "1234"
Show propertiesHide properties
Any of:
string
stringany
anycookiestringrequiredThe 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 | anyOptional HTTP proxy. Example: http://username:password@ip:port
Show propertiesHide properties
Any of:
string
stringany
anyResponses
200A message object.
codeintegerrequiredResponse code
msgstringrequiredMessage sent
dataMessageModel | anyrequiredmessage object
Show propertiesHide properties
Any of:
MessageModel
idstringrequiredMessage ID
textstringrequiredMessage text
timestringrequiredMessage time
attachmentobject | anyMessage attachment
Show propertiesHide properties
Any of:
object
objectany
anyattachmentsobject[] | anyXChat media attachments (v3).
Show propertiesHide properties
Any of:
object[]
Array of
objectobjectany
anysequence_idstring | anyXChat sequence id. Use the oldest message's sequence_id as before for pagination.
Show propertiesHide properties
Any of:
string
stringany
anysender_idstring | anySender ID
Show propertiesHide properties
Any of:
string
stringany
anyrecipient_idstring | anyRecipient ID
Show propertiesHide properties
Any of:
string
stringany
anyany
any422Validation Error
detailValidationError[]Show propertiesHide properties
Array of
ValidationErrorlocstring | integer[]requiredShow propertiesHide properties
Array of
string | integerAny of:
string
stringinteger
integermsgstringrequiredtypestringrequiredinputanyctxobject⚡Interactive ConsolePOST
⚡Interactive Console / Try APIPOSTLive 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"
}'const response = await fetch("https://api.twexapi.io/v3/twitter/send-dm", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json"
},
body: JSON.stringify({
"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"
})
});import requests
response = requests.post(
"https://api.twexapi.io/v3/twitter/send-dm",
headers={
"Authorization": "Bearer YOUR_TOKEN",
"Content-Type": "application/json"
},
json={
"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"
}
}{
"detail": [
{
"loc": [
"string"
],
"msg": "string",
"type": "string",
"input": null,
"ctx": {}
}
]
}