> ## 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 조회

> Direct Message 조회 endpoint를 사용하면 인증된 사용자의 DM 이벤트를 가져올 수 있습니다. 조회를 다루는 X API v2 standard 등급의 레퍼런스입니다.

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

Direct Message 조회 endpoint를 사용하면 인증된 사용자의 DM 이벤트를 가져올 수 있으며, 여기에는 1:1 대화와 그룹 대화의 메시지가 모두 포함됩니다.

## 개요

<CardGroup cols={2}>
  <Card title="모든 DM 이벤트" icon="messages">
    사용자의 모든 DM 이벤트 가져오기
  </Card>

  <Card title="1:1 대화" icon="https://mintcdn.com/x-preview/ygI6sSJPehlc0qNT/icons/xds/icon-chat.svg?fit=max&auto=format&n=ygI6sSJPehlc0qNT&q=85&s=9fde7d51b4f18c96d3a38a81d519761f" width="24" height="24" data-path="icons/xds/icon-chat.svg">
    특정 대화의 이벤트 가져오기
  </Card>

  <Card title="대화 ID로 조회" 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">
    대화 ID로 이벤트 가져오기
  </Card>

  <Card title="이벤트 유형" icon="https://mintcdn.com/x-preview/Vn2KEkZaPF9LiPi3/icons/xds/icon-bell.svg?fit=max&auto=format&n=Vn2KEkZaPF9LiPi3&q=85&s=5e0b3dcfbb39ba3d4619931d7cd927d1" width="24" height="24" data-path="icons/xds/icon-bell.svg">
    메시지, 참여, 나가기
  </Card>
</CardGroup>

***

## Endpoint

| Method | Endpoint                                                                                                            | 설명                  |
| :----- | :------------------------------------------------------------------------------------------------------------------ | :------------------ |
| GET    | [`/2/dm_events`](/x-api/direct-messages/get-dm-events)                                                              | 사용자의 모든 DM 이벤트 가져오기 |
| GET    | [`/2/dm_conversations/with/:participant_id/dm_events`](/x-api/direct-messages/get-dm-events-for-a-dm-conversation)  | 1:1 대화의 이벤트 가져오기    |
| GET    | [`/2/dm_conversations/:dm_conversation_id/dm_events`](/x-api/direct-messages/get-dm-events-for-a-dm-conversation-1) | 대화 ID로 이벤트 가져오기     |

***

## 이벤트 유형

| 이벤트                 | 설명            |
| :------------------ | :------------ |
| `MessageCreate`     | 대화에서 메시지가 전송됨 |
| `ParticipantsJoin`  | 사용자가 대화에 참여함  |
| `ParticipantsLeave` | 사용자가 대화에서 나감  |

***

## 데이터 보존

<Note>
  이 endpoint에서는 최대 **30일 전**까지의 이벤트를 사용할 수 있습니다.
</Note>

***

## 시작하기

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

  * 승인된 [developer account](https://developer.x.com/en/portal/petition/essential/basic-info)
  * Developer Console의 [Project 및 App](/resources/fundamentals/developer-apps)
  * [3-legged OAuth](/resources/fundamentals/authentication#obtaining-access-tokens-using-3-legged-oauth-flow)를 통한 사용자 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/lookup/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/lookup/integrate" width="24" height="24" data-path="icons/xds/icon-book.svg">
    핵심 개념 및 모범 사례
  </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/get-dm-events" width="24" height="24" data-path="icons/xds/icon-code.svg">
    전체 endpoint 문서
  </Card>

  <Card title="샘플 코드" icon="github" href="https://github.com/xdevplatform/Twitter-API-v2-sample-code">
    동작하는 코드 예제
  </Card>
</CardGroup>
