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

# Direct Message 관리

> X API v2의 Manage Direct Messages endpoint를 사용하여 인증된 X 사용자를 대신해 대화를 생성하고, 새 DM을 전송하며, DM 이벤트를 삭제하세요.

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>;
};

Manage Direct Messages endpoint를 사용하면 인증된 사용자를 대신해 Direct Message를 전송하고 삭제할 수 있습니다.

## 개요

<CardGroup cols={2}>
  <Card title="메시지 전송" icon="paper-plane">
    다른 사용자에게 DM 보내기
  </Card>

  <Card title="메시지 삭제" icon="trash">
    본인에게서 DM 삭제
  </Card>

  <Card title="대화 생성" icon="https://mintcdn.com/x-preview/ygI6sSJPehlc0qNT/icons/xds/icon-chat-unread.svg?fit=max&auto=format&n=ygI6sSJPehlc0qNT&q=85&s=ce6313d8c0b7b4e5363f2ce80b89f7e4" width="24" height="24" data-path="icons/xds/icon-chat-unread.svg">
    새 대화 시작
  </Card>

  <Card title="그룹 메시지" icon="https://mintcdn.com/x-preview/SxzTbJaLjs3MidH1/icons/xds/icon-people.svg?fit=max&auto=format&n=SxzTbJaLjs3MidH1&q=85&s=9d5f3f82edcd2a4070364193436e7980" width="24" height="24" data-path="icons/xds/icon-people.svg">
    그룹 대화로 전송
  </Card>
</CardGroup>

***

## Endpoint

| Method | Endpoint                                            | 설명         |
| :----- | :-------------------------------------------------- | :--------- |
| POST   | `/2/dm_conversations`                               | 새 대화 생성    |
| POST   | `/2/dm_conversations/with/:participant_id/messages` | 1:1 대화로 전송 |
| POST   | `/2/dm_conversations/:dm_conversation_id/messages`  | 기존 대화로 전송  |
| DELETE | `/2/dm_events/:id`                                  | DM 이벤트 삭제  |

***

## 예시: 메시지 전송

```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?"}'
```

## 예시 응답

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

***

## 메시지 유형

텍스트 메시지를 보내고 미디어를 첨부할 수 있습니다:

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

***

## 시작하기

<Note>
  **사전 요구 사항**

  * 승인된 [developer account](https://developer.x.com/en/portal/petition/essential/basic-info)
  * Developer Console의 [Project 및 App](/resources/fundamentals/developer-apps)
  * [OAuth 2.0 PKCE](/resources/fundamentals/authentication#oauth-2-0-authorization-code-flow-with-pkce-2)를 통한 사용자 Access Token
</Note>

<CardGroup cols={2}>
  <Card title="빠른 시작" icon="https://mintcdn.com/x-preview/oR-aRNyj1BKPJtxM/icons/xds/icon-rocket.svg?fit=max&auto=format&n=oR-aRNyj1BKPJtxM&q=85&s=b978d7a9225de31709efbbed5b84e92d" href="/x-api/direct-messages/manage/quickstart" width="24" height="24" data-path="icons/xds/icon-rocket.svg">
    첫 DM 전송하기
  </Card>

  <Card title="통합 가이드" icon="https://mintcdn.com/x-preview/Vn2KEkZaPF9LiPi3/icons/xds/icon-book.svg?fit=max&auto=format&n=Vn2KEkZaPF9LiPi3&q=85&s=22ac564792481d14ae36a941546039c8" href="/x-api/direct-messages/manage/integrate" width="24" height="24" data-path="icons/xds/icon-book.svg">
    핵심 개념 및 모범 사례
  </Card>

  <Card title="DM 조회" icon="messages" href="/x-api/direct-messages/lookup/introduction">
    DM 이벤트 조회하기
  </Card>

  <Card title="API 레퍼런스" icon="https://mintcdn.com/x-preview/ygI6sSJPehlc0qNT/icons/xds/icon-code.svg?fit=max&auto=format&n=ygI6sSJPehlc0qNT&q=85&s=488e23401b19225b89acc0136d242219" href="/x-api/direct-messages/create-dm-message-by-conversation-id" width="24" height="24" data-path="icons/xds/icon-code.svg">
    전체 endpoint 문서
  </Card>
</CardGroup>
