How to Send Twitter DMs via API — Complete Guide (2026)
Step-by-step guide to sending and reading Twitter DMs via API. Compare official X API vs GetXAPI — 7.5x cheaper DMs at $0.002 per call with simple Bearer token auth.

Sending and reading Twitter DMs programmatically is one of the most requested features by developers building outreach tools, customer support bots, and notification systems. But the official X API makes it painfully complex — OAuth 2.0 PKCE flows, developer account approvals, and $0.010+ per DM.
This guide covers everything you need to know about sending and reading Twitter DMs via API in 2026 — the official way, the easy way, and the pitfalls to avoid.
The problem with the official X API for DMs
As of February 2026, X replaced all fixed pricing tiers with a pay-per-use model. DM access now costs $0.010–$0.015 per API call, and requires a full OAuth 2.0 PKCE flow with dm.read and dm.write scopes.
Here's what that means in practice:
| Requirement | Official X API | GetXAPI |
|---|---|---|
| Developer account | Required (approval needed) | Not required |
| OAuth flow | OAuth 2.0 PKCE (3-legged, web server needed) | Bearer token |
| Cost per DM sent | ~$0.015 | $0.002 |
| Cost per DM read | ~$0.010 | $0.002 |
| Rate limit (send) | 15 per 15 minutes | No platform cap (~1,000/day Twitter limit) |
| Rate limit (read) | 15 per 15 minutes | 900 per 15 minutes |
| Setup time | Hours (OAuth app, callback URLs, token refresh) | Minutes (API key + auth_token) |
The official API also has a known bug where the /2/dm_events endpoint sometimes misses messages that are visible in the Twitter app. This has been reported on the X Developer Community forums and remains unresolved.
GetXAPI DM endpoints
GetXAPI offers two DM endpoints that cover both sending and reading direct messages:
Send a DM
POST /twitter/dm/send — $0.002 per call
| Parameter | Type | Required | Description |
|---|---|---|---|
auth_token |
string | Yes | Your Twitter session token |
recipient_id |
string | Either this or username | Recipient's Twitter user ID |
recipient_username |
string | Either this or ID | Recipient's @handle (without @) |
text |
string | Yes | Message content |
You can use either recipient_id or recipient_username — GetXAPI resolves the username to an ID automatically.
What you get back:
| Response field | Description |
|---|---|
id |
Unique message ID |
createdAt |
Timestamp (ISO 8601) |
senderId |
Your Twitter user ID |
recipientId |
Recipient's Twitter user ID |
text |
The message you sent |
recipient_username |
Recipient's @handle |
List DMs (Read inbox)
POST /twitter/dm/list — $0.002 per call (~50 messages per page)
| Parameter | Type | Required | Description |
|---|---|---|---|
auth_token |
string | Yes | Your Twitter session token |
cursor |
string | No | Pagination cursor from previous response |
count |
number | No | Messages per page (default: 50) |
What you get back:
| Response field | Description |
|---|---|
userId |
Your Twitter user ID |
message_count |
Number of messages in this page |
has_more |
Whether more pages exist |
next_cursor |
Cursor for next page (pass as cursor) |
messages |
Array of message objects |
Each message in the array contains: id, createdAt, senderId, recipientId, text, and recipient_username.
This is a GetXAPI exclusive — most third-party Twitter APIs only offer DM sending. GetXAPI lets you read your full DM inbox too.
How authentication works for DMs
DM endpoints require an auth_token — this is a Twitter session token tied to the account that will send/receive DMs. There are two ways to get one:
Option 1: Browser cookies
- Open Twitter/X in your browser and log in
- Open DevTools (F12) → Application → Cookies
- Find the
auth_tokencookie and copy its value - Use this value in your API calls
Option 2: Login endpoint
Call POST /twitter/user_login with your Twitter credentials:
| Parameter | Type | Required | Description |
|---|---|---|---|
username |
string | Yes | Twitter username |
password |
string | Yes | Account password |
email |
string | Recommended | Email for verification (Twitter may require it) |
totp_secret |
string | If 2FA enabled | TOTP secret key for 2FA |
The response includes auth_token, ct0, and twid. You only need the auth_token for DM calls.
Important: Always provide your email in the login request. Twitter's login flow sometimes triggers an email verification step — without it, login fails silently.
Before you send: Check if the user accepts DMs
Not every Twitter user has DMs open. If you try to DM someone who has DMs disabled, the request will fail. Save yourself the wasted API call by checking first.
GetXAPI's user endpoints include a canDm field that tells you whether a user accepts DMs:
| Endpoint | Returns canDm? |
Notes |
|---|---|---|
GET /twitter/user/info |
Yes | Quick profile lookup |
GET /twitter/user/followers_v2 |
Yes | Check DM-ability while fetching followers |
GET /twitter/user/following_v2 |
Yes | Check DM-ability while fetching following |
Pro tip: If you're building a DM outreach tool, use /twitter/user/followers_v2 to fetch your followers — it returns both the follower list and canDm status in a single call ($0.001). Then only DM the ones where canDm: true.
DM rate limits and daily caps
Understanding DM rate limits is critical for any bulk operation. There are two layers:
API-level limits (GetXAPI)
| Endpoint | Rate limit |
|---|---|
dm/send |
1,000 per day (per Twitter account) |
dm/list |
900 per 15 minutes |
Twitter account-level limits
Twitter enforces its own daily DM limits that vary by account age and status:
| Account type | Approximate daily DM limit |
|---|---|
| New/unverified account | ~500 DMs |
| Established account | ~1,000 DMs |
| Twitter Blue / Premium+ | ~1,500 DMs |
These limits are enforced by Twitter regardless of which API you use. If you hit the limit, Twitter returns an error and you need to wait until the next day.
Start sending DMs for $0.002 each
GetXAPI DM endpoints are 7.5x cheaper than the official X API. Send and read DMs with simple Bearer token auth.
Error handling for DMs
DM operations can fail for several reasons. Here's what to watch for:
| Error | Cause | What to do |
|---|---|---|
Invalid auth_token |
Token expired or malformed | Re-authenticate via login endpoint or browser cookies |
User not found |
Invalid recipient_id or recipient_username |
Verify the user exists with /twitter/user/info |
Cannot send DM |
Recipient has DMs disabled | Check canDm field before sending |
Rate limited |
Hit daily DM cap | Wait 24 hours or use a different account |
401 Unauthorized |
Invalid API key | Check your GetXAPI API key |
Retry strategy: Only retry on 429 (rate limit) and 5xx (server error) responses. Don't retry 400-level errors — they indicate a problem with your request that won't be fixed by retrying.
Cost comparison: DMs at scale
Here's what DM operations actually cost on each platform for common workloads:
| Operation | Official X API | twitterapi.io | GetXAPI |
|---|---|---|---|
| Send 100 DMs | $1.50 | $0.30 | $0.20 |
| Send 1,000 DMs | $15.00 | $3.00 | $2.00 |
| Read 10,000 messages | $100.00 | N/A | $0.40 |
| Send 1,000 DMs + read inbox | $25.00 | $3.00+ | $2.40 |
GetXAPI is 7.5x cheaper than the official X API for DM sending, and is the only third-party API that offers DM inbox reading.
Building a DM workflow: Step by step
Here's the complete flow for building a DM outreach system:
Step 1: Get your auth_token
Call POST /twitter/user_login with your Twitter credentials. Store the returned auth_token securely — you'll use it for all DM operations.
Step 2: Build your recipient list
Fetch your followers using GET /twitter/user/followers_v2. This returns both follower profiles and the canDm field. Filter for users where canDm: true.
Step 3: Send DMs
For each recipient, call POST /twitter/dm/send with their username or user ID. Add a delay between sends (e.g., 2-5 seconds) to avoid triggering Twitter's anti-spam detection.
Step 4: Monitor your inbox
Use POST /twitter/dm/list to check for replies. Paginate with cursor until has_more: false to get all messages.
Step 5: Handle errors gracefully
If a DM fails, check the error type. Don't retry client errors (400). For rate limits (429), wait and retry with exponential backoff. Store failed recipients to retry later.
Quick reference
| What | Endpoint | Method | Cost |
|---|---|---|---|
| Send a DM | /twitter/dm/send |
POST | $0.002 |
| Read DM inbox | /twitter/dm/list |
POST | $0.002 |
| Get auth token | /twitter/user_login |
POST | $0.001 |
| Check canDm | /twitter/user/info |
GET | $0.001 |
| Check canDm (bulk) | /twitter/user/followers_v2 |
GET | $0.001 |
Start sending DMs
GetXAPI gives you $0.10 in free credits at signup — that's 50 DM sends with no credit card required. Enough to test the full workflow.
- Sign up at getxapi.com — instant API key, no developer account needed
- Get your
auth_tokenvia the login endpoint or browser cookies - Send your first DM with
POST /twitter/dm/send - Check full pricing for DM endpoints at $0.002 per call
Read the full API documentation for detailed request/response schemas and more examples.
Frequently Asked Questions
With GetXAPI, it costs $0.002 per DM sent. The official X API charges approximately $0.015 per DM — that's 7.5x more expensive.
Twitter enforces account-level daily limits: ~500 for new accounts, ~1,000 for established accounts, and ~1,500 for Premium+ accounts. These limits apply regardless of which API you use.
Yes. GetXAPI's POST /twitter/dm/list endpoint lets you read your full DM inbox at $0.002 per call (~50 messages per page). This is a GetXAPI exclusive — most third-party APIs only offer DM sending.
With the official X API, yes — you need OAuth 2.0 PKCE with dm.write scope. With GetXAPI, you just need your API key and an auth_token (from browser cookies or the login endpoint). No OAuth setup required.