X Write
Send DM
Send X direct messages from a connected account, store messageId, and attach one uploaded media ID
POST
Send DM
Documentation Index
Fetch the complete documentation index at: https://docs.xquik.com/llms.txt
Use this file to discover all available pages before exploring further.
10 credits per call · All plans from $0.00012/credit
userId. For media DMs, upload first with POST /x/media, pass the returned mediaId as the only media_ids item, and store the returned messageId. Use public media URLs with POST /x/tweets; this DM endpoint accepts one uploaded media ID instead.
message_id, user_id, account, send_status, optional media_id,
media_ids, and source_endpoint. For media DMs, keep media_ids as the
one-item request array and set media_id to the uploaded media ID that you
passed as that single item.
Send with media
Upload media first with Upload Media, then pass the returnedmediaId as the only media_ids item.
reply_to_message_id while the REST route rejects it.
Leave it unset. Pass exactly one uploaded media ID in media_ids, then store
the returned messageId with that media ID.
Media DM result handoff
After the media DM send returns200 OK, store the returned messageId with the uploaded media ID and recipient user ID so support logs, CRM records, queues, or agent memory can reconcile the attachment with the sent message.
media_ids as a one-item array in the request, keep media_id as the original POST /x/media result, and use message_id as the external DM identifier after the send succeeds.
Direct message handoff
UsePOST /x/dm/{userId} when a support, sales, community, CRM, or agent workflow needs to send an auditable direct message from a connected X account. If you only have a username, look up the recipient first with GET /x/users/{id}. If the workflow needs conversation context, read the latest messages with GET /x/dm/{userId}/history before sending.
messageId
Store
messageId as the external message ID for support logs, CRM records, queues, or agent memory.success
Mark the send job complete after a
200 OK response.userId
Keep the recipient X user ID from the path with the send job.
account
Store the connected X account that sent the DM.
text
Store the exact message text sent. Add your own
sent_at timestamp when downstream systems need it.media_ids[0]
Store the uploaded media ID when the DM includes one attachment from
POST /x/media.POST /x/media is a separate 10-credit call. Do not retry 422 x_dm_not_allowed unchanged; use another permitted connected account or ask the recipient to allow messages.
Headers
Your API key. Session cookie authentication is also supported. Generate a key from the dashboard.
Must be
application/json.Path parameters
The X user ID of the recipient.
Body
X username or account ID of your connected account to act as.
Non-empty message text to send. If X rejects oversized content, the API
returns
422 x_content_too_long.Optional one-item array containing an uploaded media ID. Upload media first with Upload Media, then pass the returned
mediaId as the only array item. Empty arrays and multiple IDs are rejected.Response
- 200 OK
- 400 Invalid Input
- 401 Unauthenticated
- 402 Subscription Required
- 402 Insufficient Credits
- 403 Account Needs Reauth
- 403 Account Restricted
- 422 Write Rejected
- 429 Rate Limited
- 503 Transient Error
- 500 Write Failed
Related: Direct Message Workflow for
lookup, history sync,
messageId storage, and media handoff; Get User
to look up a user’s ID before messaging; Get DM History
to sync participant-scoped messages; Upload Media
to create the one mediaId allowed in media_ids.Last modified on May 23, 2026
Send DM