> ## Documentation Index
> Fetch the complete documentation index at: https://x-preview-mintlify-b4f5bfb1.mintlify.site/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">
    <a href={href}>
      <button className="x-btn">
        <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="https://mintcdn.com/x-preview-mintlify-b4f5bfb1/NEh9mjpH7RaTDEed/icons/xds/icon-chat-unread.svg?fit=max&auto=format&n=NEh9mjpH7RaTDEed&q=85&s=ceda6572fd2f0e9f586909c13ab6fbf5" width="24" height="24" data-path="icons/xds/icon-chat-unread.svg">
    Start a new conversation
  </Card>

  <Card title="Group messages" icon="https://mintcdn.com/x-preview-mintlify-b4f5bfb1/VFX2XSyPqtT4SVsH/icons/xds/icon-people.svg?fit=max&auto=format&n=VFX2XSyPqtT4SVsH&q=85&s=a87838641b92da2bd42d8ec4805b86c7" width="24" height="24" data-path="icons/xds/icon-people.svg">
    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="https://mintcdn.com/x-preview-mintlify-b4f5bfb1/CJEW78ZoFC_WB4AV/icons/xds/icon-rocket.svg?fit=max&auto=format&n=CJEW78ZoFC_WB4AV&q=85&s=c4d643f2a562a30abeccca3349337f50" href="/x-api/direct-messages/manage/quickstart" width="24" height="24" data-path="icons/xds/icon-rocket.svg">
    Send your first DM
  </Card>

  <Card title="Integration guide" icon="https://mintcdn.com/x-preview-mintlify-b4f5bfb1/E43Ep5Gv29gM6HJ6/icons/xds/icon-book.svg?fit=max&auto=format&n=E43Ep5Gv29gM6HJ6&q=85&s=58d2163a527af71742b049fc4dc92669" href="/x-api/direct-messages/manage/integrate" width="24" height="24" data-path="icons/xds/icon-book.svg">
    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="https://mintcdn.com/x-preview-mintlify-b4f5bfb1/NEh9mjpH7RaTDEed/icons/xds/icon-code.svg?fit=max&auto=format&n=NEh9mjpH7RaTDEed&q=85&s=07116236bb3000cffffbf6c9bac6d47e" href="/x-api/direct-messages/create-dm-message-by-conversation-id" width="24" height="24" data-path="icons/xds/icon-code.svg">
    Full endpoint documentation
  </Card>
</CardGroup>
