Twitter DM API | Read the Inbox and Send Messages
Direct Messages: Read your account's DM inbox and the message history of a single conversation, and send new messages, all acting as the account behind your registered session.
Read your account's DM inbox and the message history of a single conversation, and send new messages, all acting as the account behind your registered session.
The usual flow is /dm/list to page through conversation threads (each carries a conversation_id and participant list), then /dm/conversation with that id to pull the full message history for one thread. /dm/send posts as your account. All three act on behalf of one X account, so each call authenticates with either a registered session (POST /customer/session) or per-call x-auth-token and x-ct0 headers, which is what lets one API key poll or send from many different accounts. All three are flat $0.0016 per call regardless of message count, so paging a long conversation costs the same as reading a short one.
This category has 3 endpoints. Each is a pay-per-call REST endpoint with bearer auth, JSON in and out.
| Method | Path | Cost | Description |
|---|---|---|---|
POST | /dm/send | $0.0016 | Send a direct message from your authenticated account. |
GET | /dm/list | $0.0016 | List the Direct Message conversations for your registered account. |
GET | /dm/conversation | $0.0016 | Read the message history of one DM conversation by conversation_id. |
Send DM
Send a direct message from your authenticated account.
DM Inbox
List the Direct Message conversations for your registered account.
DM Conversation
Read the message history of one DM conversation by conversation_id.
Leave Community POST
Remove your X account from a community it belongs to, by the community's numeric id. The call runs as your registered X session, sends one leave request and reports what X answered, without reading the community first. Billed at $0.0008 per applied write; a leave that does not apply is free. Cost: $0.0008 per call.
DM Inbox GET
List the DM conversations (inbox) for the account behind your session. Returns each conversation's ID, type, and participant user IDs. Pass a conversation_id to GET /dm/conversation to read its messages. Authenticate with a registered session (POST /customer/session) or per-call x-auth-token and x-ct0 headers, so one API key can poll the inboxes of many accounts. Read-only: this does not send DMs. It reads X's standard DM inbox, so conversations X has moved to end-to-end encrypted chat may not appear, and conversations still in the message-requests folder may be missing. Cost: $0.0016 per call.