> ## 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.

# Manage Direct Messages

> Use the X API v2 Manage Direct Messages endpoints to create conversations, send new DMs, and delete DM events on behalf of authenticated users on X.

export const Button = ({href, children}) => {
  return <div className="not-prose group">
    <a href={href}>
      <button className="flex items-center space-x-2.5 py-1 px-4 bg-primary-dark dark:bg-white text-white dark:text-gray-950 rounded-full group-hover:opacity-[0.9] font-medium">
        <span>
          {children}
        </span>
        <svg width="3" height="24" viewBox="0 -9 3 24" class="h-6 rotate-0 overflow-visible"><path d="M0 0L3 3L0 6" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"></path></svg>
      </button>
    </a>
  </div>;
};

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

## Overview

<CardGroup cols={2}>
  <Card title="Send message" icon="paper-plane">
    Send a DM to another user
  </Card>

  <Card title="Delete message" icon="trash">
    Delete a DM for yourself
  </Card>

  <Card title="Create conversation" icon="comments">
    Start a new conversation
  </Card>

  <Card title="Group messages" icon="users">
    Send to group conversations
  </Card>
</CardGroup>

***

## Endpoints

| Method | Endpoint                                            | Description                     |
| :----- | :-------------------------------------------------- | :------------------------------ |
| POST   | `/2/dm_conversations`                               | Create a new conversation       |
| POST   | `/2/dm_conversations/with/:participant_id/messages` | Send to one-to-one conversation |
| POST   | `/2/dm_conversations/:dm_conversation_id/messages`  | Send to existing conversation   |
| DELETE | `/2/dm_events/:id`                                  | Delete a DM event               |

***

## Example: Send a message

```bash theme={null}
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

```json theme={null}
{
  "data": {
    "dm_conversation_id": "1234567890-0987654321",
    "dm_event_id": "1122334455667788990"
  }
}
```

***

## Message types

You can send text messages and attach media:

```json theme={null}
{
  "text": "Check out this photo!",
  "attachments": [{
    "media_id": "1234567890123456789"
  }]
}
```

***

## Getting started

<Note>
  **Prerequisites**

  * An approved [developer account](https://developer.x.com/en/portal/petition/essential/basic-info)
  * A [Project and App](/resources/fundamentals/developer-apps) in the Developer Console
  * User Access Tokens via [OAuth 2.0 PKCE](/resources/fundamentals/authentication#oauth-2-0-authorization-code-flow-with-pkce-2)
</Note>

<CardGroup cols={2}>
  <Card title="Quickstart" icon="rocket" href="/x-api/direct-messages/manage/quickstart">
    Send your first DM
  </Card>

  <Card title="Integration guide" icon="book" href="/x-api/direct-messages/manage/integrate">
    Key concepts and best practices
  </Card>

  <Card title="DM lookup" icon="messages" href="/x-api/direct-messages/lookup/introduction">
    Retrieve DM events
  </Card>

  <Card title="API Reference" icon="code" href="/x-api/direct-messages/create-dm-message-by-conversation-id">
    Full endpoint documentation
  </Card>
</CardGroup>
