X

X Direct Messages API

Endpoints related to retrieving, managing Direct Messages — 9 operation(s) in the X-published contract.

Operations 9

Each operation below carries the questions people ask an LLM about it and the instructions they give an agent to run it. Generated by API Evangelist overlay

POST /2/dm_conversations Start a group DM conversation · Create DM conversation #
Ask an LLM
“How do I start a new group Direct Message with several people?”
“Does creating a DM conversation support one-to-one chats or only groups?”
Tell an agent
Start a {conversation_type} DM with {participant_ids} and send {message}.
Create a new {conversation_type} conversation including {participant_ids}, opening with {message}.
GET /2/dm_conversations/media/{dm_id}/{media_id}/{resource_id} Download media from a legacy DM · Download DM Media #
Ask an LLM
“Can I download a photo or video attached to an older Direct Message?”
“Do I have to be in the conversation to fetch DM attachment bytes?”
Tell an agent
Download media {media_id} resource {resource_id} from DM {dm_id}.
Save the attachment {resource_id} of media {media_id} in legacy DM event {dm_id}.
GET /2/dm_conversations/with/{participant_id}/dm_events Get my DM history with one person · Get Direct Messages Events by Participant ID #
Ask an LLM
“What have I and a specific user said to each other in DMs?”
“Can I pull my one-to-one DM history with someone using just their user ID?”
Tell an agent
Show my DM history with user {participant_id}.
Get the last {max_results} DM events between me and {participant_id}.
POST /2/dm_conversations/with/{participant_id}/messages Send a DM to a user · Create DM message by participant ID #
Ask an LLM
“How do I send a Direct Message to someone by their user ID?”
“Can I attach media when DMing a user directly?”
Tell an agent
DM user {participant_id} saying {text}.
Send {participant_id} a direct message with attachment {attachments}.
POST /2/dm_conversations/{dm_conversation_id}/messages Send a message into an existing DM conversation · Create Direct Messages by Conversation ID #
Ask an LLM
“Can I post a message into a group DM conversation I'm already part of?”
“What's the call to reply inside an existing DM thread by its conversation ID?”
Tell an agent
Send {text} to DM conversation {dm_conversation_id}.
Post attachment {attachments} into conversation {dm_conversation_id}.
GET /2/dm_conversations/{id}/dm_events Read the events in a DM conversation · Get Direct Messages Events by Conversation ID #
Ask an LLM
“Which messages are in a particular group DM conversation?”
“Can I filter a conversation's DM events by event type?”
Tell an agent
Show the DM events in conversation {id}.
Get {event_types} events from DM conversation {id}.
GET /2/dm_events List my recent DM events across conversations · Get Direct Messages Events #
Ask an LLM
“What are my most recent Direct Messages across all conversations?”
“Can I list only join or leave events in my DMs?”
Tell an agent
List my recent DM events across all conversations.
Show my latest {max_results} DM events of type {event_types}.
DELETE /2/dm_events/{event_id} Delete a DM I sent · Delete DM event #
Ask an LLM
“Can I delete a Direct Message I sent?”
“What happens if I try to delete a DM event I don't own?”
Tell an agent destructive · confirm first
Delete DM event {event_id}.
Remove my direct message {event_id}.
GET /2/dm_events/{event_id} Get a single DM event · Get Direct Messages Events by ID #
Ask an LLM
“Can I look up one specific Direct Message event by its ID?”
“What details come back for a single DM event?”
Tell an agent
Get DM event {event_id}.
Show the direct message with event ID {event_id}.

Work with this as data

Every API here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for apis

7 MCP tools reach this
  • find_apisBrowse and filter every API in the catalog.
  • get_api_artifactsOne API's artifacts, grouped by type.
  • get_openapiThe primary OpenAPI for this API.
  • find_similar_apisAPIs that look like this one.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This API
curl "https://apis.io/api/v1/apis/x:x-direct-messages-api"
All apis
curl "https://apis.io/api/v1/apis?limit=25"

Discovery needs no key. Ratings and market analysis are Pro.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.

OpenAPI Specification

x-direct-messages-api-openapi.yml Raw ↑
openapi: 3.2.0
info:
  description: X API v2 core endpoints
  version: '2.168'
  title: X API v2 Direct Messages API
  termsOfService: https://developer.x.com/en/developer-terms/agreement-and-policy.html
  contact:
    name: X Developers
    url: https://developer.x.com/
  license:
    name: X Developer Agreement and Policy
    url: https://developer.x.com/en/developer-terms/agreement-and-policy.html
servers:
- description: X API
  url: https://api.x.com
tags:


# --- truncated at 32 KB (81 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/x/refs/heads/main/openapi/x-direct-messages-api-openapi.yml