Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.x.com/llms.txt

Use this file to discover all available pages before exploring further.

The Manage Direct Messages endpoints let you send and delete Direct Messages on behalf of authenticated users.

Overview

Send message

Send a DM to another user

Delete message

Delete a DM for yourself

Create conversation

Start a new conversation

Group messages

Send to group conversations

Endpoints

MethodEndpointDescription
POST/2/dm_conversationsCreate a new conversation
POST/2/dm_conversations/with/:participant_id/messagesSend to one-to-one conversation
POST/2/dm_conversations/:dm_conversation_id/messagesSend to existing conversation
DELETE/2/dm_events/:idDelete a DM event

Example: Send a message

curl -X POST "https://api.x.com/2/dm_conversations/with/1234567890/messages" \
  -H "Authorization: Bearer $USER_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"text": "Hello! How are you?"}'

Example response

{
  "data": {
    "dm_conversation_id": "1234567890-0987654321",
    "dm_event_id": "1122334455667788990"
  }
}

Message types

You can send text messages and attach media:
{
  "text": "Check out this photo!",
  "attachments": [{
    "media_id": "1234567890123456789"
  }]
}

Getting started

Prerequisites

Quickstart

Send your first DM

Integration guide

Key concepts and best practices

DM lookup

Retrieve DM events

API Reference

Full endpoint documentation