POST /2/dm_conversations/:dm_conversation_id/messages

POST /2/dm_conversations/:dm_conversation_id/messages

Creates a Direct Message on behalf of an authenticated user, and adds it to the specified conversation.

Endpoint URL

https://api.x.com/2/dm_conversations/:dm_conversation_id/messages

Authentication and rate limits

Authentication methods
supported by this endpoint

OAuth 2.0 App-only

OAuth 2.0 Authorization Code with PKCE

OAuth 1.0a is also available for this endpoint.

Rate limit

User rate limit (User context): 200 requests per 15-minute window per each authenticated user

App rate limit (Application-only): 15000 requests per 24-hour window shared among all users of your app

OAuth 2.0 scopes required by this endpoint

dm.write

dm.read

tweet.read

users.read

Learn more about OAuth 2.0 Authorization Code with PKCE

Path parameters

NameTypeDescription
dm_conversation_id
 Required 
stringThe dm_conversation_id of the conversation to add the Direct Message to. Supports both 1-1 and group conversations.


JSON body parameters

NameTypeDescription
attachments
 Optional 
arrayA single Media ID being attached to the Direct Message. This field is required if text is not present. For this launch, only 1 attachment is supported.

Example: {"text": "Sending a DM with media!", "attachments": [{"media_id": "1455952740635586573"}]
text
 Optional 
stringText of the Direct Message being created. This field is required if attachments is not present. Text messages support up to 10,000 characters.

Example: {"text": "Hello just you conversation participants!""}


Example code with offical SDKs

cURL
      curl -X POST "https://api.x.com/2/dm_conversations/:dm_conversation_id/messages" -d '{"text": "Adding a Direct Message to a conversation by referencing the conversation ID. This method supports both one-to-one and group conversations."}' -H "Authorization: Bearer $ACCESS_TOKEN"
    

Example responses

Successful response
      {
  "dm_conversation_id": "1346889436626259968",
  "dm_event_id": "128341038123"
}
    

Response fields

NameTypeDescription
dm_conversation_idstringContains the id of the Direct Message conversation the Direct Message was added to.
dm_event_idstringContains the id of the event created by this request.