Skip to main content
GET
Twitter DM API for message history & CRM sync
1 credit per result returned · All plans from $0.00012/credit
This Twitter API DM endpoint reads participant-scoped conversation history. Pass the connected participant account through account. Store message IDs and next_cursor in private systems. Keep full message text private. Use Send DM when the workflow needs a reply. Compare fields with X’s Direct Messages lookup guide. Xquik returns the normalized message fields listed below.
Requires a connected X account passed via the account query parameter. DM history is participant-scoped, so pass the connected account that belongs to the conversation.
DM history responses can contain private message text. Store them in a private support, CRM, warehouse, or agent memory system. Do not write full DM bodies to shared logs or public artifacts.

Which DM workflow?

Read conversation history

Use GET /x/dm/{userId}/history with account, then store messages[].id and next_cursor in a private system.

Send text reply

Use POST /x/dm/{userId}, pass the same connected account, and store the returned messageId.

Send one media item

Use POST /x/media first, then pass the returned media ID as the only media_ids item on the DM send.

Resolve participant ID

Use GET /x/users/{id} when a workflow starts from a handle and needs the numeric userId for history or send calls.
These examples turn each page into private dm_history rows. Store message_id, sender_id, receiver_id, message_text, and created_at. Also store optional media_url, conversation_user_id, sender_account, and page_next_cursor for each page. Keep message_text only in private systems. Use IDs, timestamps, media URLs, and job status in shared logs.

Path parameters

string
required
Target X user ID for the DM conversation (numeric string).

Query parameters

string
required
X handle (without the @ prefix) of the connected X account used to read the conversation. DM history is participant-scoped, so the account must belong to the conversation. Connect an account on the dashboard before calling this endpoint.
string
Pagination cursor. Use the previous response’s next_cursor to fetch older messages.
string
Legacy pagination cursor. Use cursor for new integrations. When both are present, cursor takes precedence.

Headers

string
required
Your API key. You can also authenticate with an OAuth bearer token.

Response

200 OK

object[]
Contains direct messages. Message object fields.
string
Identifies the message.
string
Contains message text when available.
string
Identifies the sender.
string
Identifies the recipient.
string
Reports the ISO 8601 timestamp when available.
string
Links attached media when present.
boolean
Reports whether older messages are available.
string
Provides the next-page cursor. Returns an empty string after the final page.

400 Invalid user ID

The user ID is empty or invalid.

400 Account required

The account query parameter was missing or empty. Pass the handle of a connected X account that participates in the conversation.

401 Unauthenticated

Supply a valid API key or OAuth bearer token.

402 Insufficient credits

Metered access requires enough available credits. Possible error values include no_subscription, subscription_inactive, no_credits, and insufficient_credits.

403 DM not permitted

X rejected the DM read. Use a participating connected account. If it needs reauthentication, reconnect it before retrying.

403 Account restricted

The connected X account is suspended, locked, or otherwise restricted. Use a different connected account.

403 Account needs reauth

Reconnect the connected account from the dashboard.

404 Account not found

The requested connected X account was not found. Connect it first or pass another account handle.

429 Rate limit exceeded

You exceeded your tier’s rate limit. Wait for Retry-After before retrying.

424 Dependency failed

The opt-in normalized contract returns 424 when the read service fails. Send xquik-api-contract: 2026-04-29 to opt in. Default v1 returns 502.

502 X API unavailable

The read service failed. Retry after a short delay.

Twitter DM API questions

Can I retrieve DM history?

Yes. Call GET /x/dm/{userId}/history with a participating connected account.

Can I send a reply through this endpoint?

No. Use Send DM. This endpoint reads history only.

Does this endpoint create direct message webhooks?

No. It reads participant-scoped history when called. It does not register webhooks.

How do I authenticate?

Send an API key or OAuth bearer token.

How do I handle a rate limit?

Wait for Retry-After, then retry the same page.

History sync handoff

Use this endpoint when a CRM, support desk, warehouse job, or agent needs participant-scoped DM context before sending a reply.

Dedupe imported messages

Store messages[].id as the external DM ID for CRM notes, support tickets, warehouse rows, or agent memory.

Preserve participants

Store messages[].senderId and messages[].receiverId with the connected account so each private conversation stays tied to the correct sender.

Resume older pages

Store next_cursor when has_next_page is true, then pass it as cursor on the next sync job.

Keep media context

Store optional messages[].mediaUrl with messages[].createdAt when a DM includes an image, GIF, or video attachment.
Related. Direct Message Workflow for lookup, participant-scoped history sync, messageId storage, and media handoff; Get User to resolve the recipient userId; Send DM to reply from the connected account; Upload Media when a reply needs one uploaded mediaId.