DM
DM Send
Send Twitter direct messages programmatically via API. $0.002 per call. GetXAPI DM send endpoint documentation with code examples.
POST
/twitter/dm/sendThis endpoint costs $0.002 per API call.
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
auth_token | string | Yes | User's auth token |
ct0 | string | No | Optional current CSRF token cookie. When provided with twid, skips server-side credential resolution. |
twid | string | No | Optional current user ID cookie, for example u=1234567890. Must be provided with ct0. |
recipient_id | string | No | Recipient user id |
recipient_username | string | No | Recipient username (without @) |
text | string | Yes | Message text |
proxy | string | No | Proxy URL (http://, https://, socks5://, or socks4://) |
Notes
- If you already have current
ct0andtwid, send both to skip the extra server-side credential bootstrap fromauth_token. If either one is omitted, the server resolves them fromauth_tokenas before. Stale or invalid supplied values are not validated upfront and may fail on the actual Twitter action instead of returning an early401. - Provide either
recipient_idorrecipient_username. - If
recipient_usernameis used, it is resolved to a user id via the pool.
Response (200)
{
"status": "success",
"msg": "DM sent successfully",
"data": {
"id": "2019384131067818211",
"createdAt": "2026-02-05T12:14:29.846Z",
"senderId": "1858475867762270208",
"recipientId": "1234567890123456789",
"text": "Hello!",
"recipient_username": "target_user"
}
}Error Responses
400 - Missing fields
{
"error": "Missing required field: recipient_id or recipient_username"
}Example
curl -X POST "https://api.getxapi.com/twitter/dm/send" \
-H "Authorization: Bearer API_KEY" \
-H "Content-Type: application/json" \
-d '{
"auth_token": "your_auth_token",
"recipient_username": "target_user",
"text": "Hello!"
}'
# With recipient_id
curl -X POST "https://api.getxapi.com/twitter/dm/send" \
-H "Authorization: Bearer API_KEY" \
-H "Content-Type: application/json" \
-d '{
"auth_token": "your_auth_token",
"recipient_id": "1234567890123456789",
"text": "Hello!"
}'const response = await fetch("https://api.getxapi.com/twitter/dm/send", {
method: "POST",
headers: {
Authorization: "Bearer API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
auth_token: "your_auth_token",
recipient_username: "target_user",
text: "Hello!",
}),
});
const data = await response.json();
console.log(data);import requests
response = requests.post(
"https://api.getxapi.com/twitter/dm/send",
headers={"Authorization": "Bearer API_KEY"},
json={
"auth_token": "your_auth_token",
"recipient_username": "target_user",
"text": "Hello!",
},
)
print(response.json())DM ConversationNew
Fetch the full message history of a single Twitter DM conversation via API, newest first with cursor pagination. $0.001 per call. GetXAPI DM conversation endpoint docs.
Upload MediaNew
Upload an image, GIF, or video to Twitter/X and get a media_id for tweets via API. $0.001 per call. GetXAPI media upload endpoint.