GetXAPI
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/send

This endpoint costs $0.002 per API call.

Request Body

FieldTypeRequiredDescription
auth_tokenstringYesUser's auth token
recipient_idstringNoRecipient user id
recipient_usernamestringNoRecipient username (without @)
textstringYesMessage text

Notes

  • Provide either recipient_id or recipient_username.
  • If recipient_username is 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())

On this page