# How to Automate X (Twitter) DM Campaigns using the API

- Tool: API Automations
- Difficulty: Advanced
- Fix time: 6–10 hours
- Compatibility: X API v2, Pro tier ($5,000/month) recommended; Basic tier has a documented DM rate limit bug
- Last updated: May 2026

## TL;DR

X's DM API (POST /2/dm_conversations/with/:participant_id/messages) lets you send direct messages programmatically — but Basic tier ($200/month) is effectively limited to 1 DM request per 24 hours due to a known, unresolved bug since August 2025. Pro tier ($5,000/month) works as documented at 15 requests per 15 minutes. The platform cap is 500 DMs per day per account regardless of tier. Know the true cost before building.

## Best practices

- Test your tier's actual DM rate limits before building — Basic tier has a documented bug that makes bulk DM automation practically impossible without Pro
- Keep DM content genuinely useful and personalized — X can suspend accounts for DM spam, and users can report unsolicited messages
- Build your campaign to send at most 490 DMs per day, leaving a 10-DM buffer before the 500 platform cap
- Refresh your recipient list before each campaign run — follower lists change, and sending to deactivated accounts wastes budget and raises error rates
- Personalize at minimum with the recipient's name — identical messages to hundreds of users is the primary trigger for spam detection
- Add a campaign opt-out mechanism — include instructions for users to DM back 'STOP' and maintain a suppression list

## Frequently asked questions

### Can I send bulk DMs on the Basic tier ($200/month)?

In practice, no. As of August 2025, the dm_conversations/with/:id/dm_events endpoint is effectively limited to 1 request per 24 hours on Basic tier despite X documenting 75,000/month. This bug remains unresolved as of May 2026. DM sends (POST) may work at higher volume but have inconsistent behavior. For reliable bulk DM automation, Pro tier ($5,000/month) is the only practical option.

### What is the maximum number of DMs I can send per day?

500 DMs per day per account — this is an account-level platform cap that applies to all tiers including Pro and Enterprise. This cannot be increased. To reach more users, you would need multiple X accounts, each with its own campaign. X Premium accounts (users, not developers) have a 10x higher cap, but that applies to the account itself, not the API.

### What happens if a user has DMs restricted to followers only?

The API returns a 403 Forbidden response. You cannot override this setting — the user must change their own DM privacy settings. Mark these users as 'dm_restricted' in your campaign log and do not retry. A common workaround is to first follow the user and wait for a follow-back before attempting to DM them, but this significantly slows campaign execution.

### How do I get the numeric user ID for a recipient when I only know their username?

Use GET /2/users/by/username/:username to look up a user ID from their username. This costs $0.005 per read on pay-per-use. For campaigns targeting your own followers, use GET /2/users/{id}/followers to get both user IDs and usernames simultaneously, avoiding the lookup step.

### Will X suspend my account for sending automated DMs?

Potentially yes, if the DMs are unsolicited, repetitive, or promotional in nature without clear user opt-in. X's platform policy prohibits using the API for bulk unsolicited DMs. Best practices: only DM engaged users (followers who have interacted with your content), personalize each message, include an opt-out instruction, and keep volume under 100 DMs/day initially to build account trust.

### Can RapidDev help me build a compliant DM campaign infrastructure?

Yes. RapidDev can guide you through building a DM campaign backend with proper rate limiting, recipient management, and opt-out tracking using Supabase and Next.js. We also have resources on X API tier selection to help you decide whether pay-per-use or Pro tier makes sense for your expected campaign volume.

---

Source: https://www.rapidevelopers.com/api-automations/how-to-automate-twitter-dm-campaigns-using-the-api
© RapidDev — https://www.rapidevelopers.com/api-automations/how-to-automate-twitter-dm-campaigns-using-the-api
