> ## 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 Messages エンドポイントの v1.1 と v2 の両バージョンには、Direct を作成するためのメソッドが用意されています。manage をカバーする X API v2 standard tier のリファレンスです。

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

## v1.1 と v2 の Manage Direct Message エンドポイントの比較

Direct Messages エンドポイントの v1.1 と v2 の両バージョンには、Direct Message を作成するためのメソッドが用意されています。このガイドは、両者の違いを理解し、v2 への移行に役立つ情報を提供することを目的としています。

両バージョン間の大きな違いは、v1.1 は 1 対 1 の会話のみをサポートしているのに対し、v2 ではグループ会話のサポートが導入されている点です。この結果として、v1.1 は「message created」イベントのみをサポートしていますが、v2 では会話への参加や退出に関連するイベントもサポートしています。実際、v2 の基本的な更新点として、dm\_conversations がコア API オブジェクトとして確立されています。

v1.1 には Direct Messages を管理するための 2 つのエンドポイントがあります。

* POST direct\_messages/events/new - 1 対 1 の Direct Message を作成します。この v1.1 エンドポイントは 1 対 1 のメッセージのみを作成でき、グループメッセージはサポートしていません。

* DELETE direct\_messages/events/destroy - 認証済みユーザーの視点から 1 対 1 のメッセージを削除します。

この v2 リリースでは、Direct Messages を作成するための POST メソッドが 3 つ用意されています。

* **POST /2/dm\_conversations/with/:participant\_id/messages** - 1 対 1 の Direct Message を作成します。このメソッドは、既存の 1 対 1 の会話にメッセージを追加するか、新しい会話を作成します。:participant\_id パスパラメータは、メッセージを受け取るアカウントの User ID です。

* **POST /2/dm\_conversations** - 新しいグループ会話を作成し、そこに Direct Message を追加します。これらのリクエストには会話参加者のリストが必要です。同じ参加者リストで複数の会話を作成できることに注意してください。これらのリクエストは常に新しい会話 ID を返します。

* **POST /2/dm\_conversations/:dm\_conversation\_id/messages** - Direct Message を作成し、既存の会話に追加します。:dm\_conversation\_id パスパラメータは、メッセージを追加する会話の ID です。

重要な点として、会話 ID とイベント ID は X Platform の v1.1 と v2 間で共有されます。つまり、両バージョンを併用することが可能です。例えば、Direct Messages v1.1 エンドポイントには単一のイベントを返すメソッドやイベントを削除するメソッド（v2 ではまだ利用不可）が用意されており、ID が v1.1 と v2 で共通のため、v2 が返した ID や X アプリケーションの会話 URL に表示される会話 ID を基に v1.1 リクエストを行うことができます。

次の表は、v1.1 と v2 の manage Direct Messages エンドポイントの基本的な側面を比較したものです。ここで示す X API v2 の特徴は、すべての Direct Message lookup エンドポイントに共通しています。

|                                                                                                                                       |                                                                                |                                                                                                                                                                                                                         |
| :------------------------------------------------------------------------------------------------------------------------------------ | :----------------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Description**                                                                                                                       | **Standard v1.1**                                                              | **X API v2**                                                                                                                                                                                                            |
| Host domain                                                                                                                           | [https://api.x.com](https://api.x.com)                                         | [https://api.x.com](https://api.x.com)                                                                                                                                                                                  |
| Endpoint root path                                                                                                                    | [/1.1/direct\_messages](https://api.x.com/1.1/direct_messages)                 | [/2/dm\_conversations](https://api.x.com/2/users/:id/dm_conversations)<br /><br />Direct Messages の会話は基本的な API オブジェクトとして導入されました。   <br /><br />これらのエンドポイントは MessageCreate、ParticipantsJoin、ParticipantLeave イベントを取得します。 |
| HTTP methods supported                                                                                                                | POST                                                                           | POST                                                                                                                                                                                                                    |
| Supports Group Direct Messages                                                                                                        |                                                                                | ✔                                                                                                                                                                                                                       |
| Event types supported                                                                                                                 | message\_create                                                                | MessageCreate, ParticipantsJoin, ParticipantsLeave                                                                                                                                                                      |
| [Authentication](/resources/fundamentals/authentication)                                                                              | OAuth 1.0a User Context                                                        | OAuth 1.0a User Context<br /><br />OAuth 2 User Context (scopes: dm.read, dm.write)                                                                                                                                     |
| X API v2 の [Project](/resources/fundamentals/developer-apps) に紐づく [developer App](/resources/fundamentals/authentication) の資格情報の使用が必要 |                                                                                | ✔                                                                                                                                                                                                                       |
| デフォルトのリクエスト [rate limits](/x-api/fundamentals/rate-limits)\*  <br />\*すべてのリクエストで user token が必要                                       | 1000 requests per user per 24 hours  <br />15000 requests per app per 24 hours | 200 requests per 15 minutes per user<br /><br />1000 requests per user per 24 hours<br /><br />15000 requests per app per 24 hours<br /><br />これらの rate limit は、すべての dm\_conversations POST エンドポイント間で共有されます。            |

以下の表は、v2 の各 POST メソッドを v1.1 と比較したものです。これらの v2 の機能は、グループ会話をサポートすることで利用可能な機能を拡張していることに注意してください。

**新しい 1 対 1 の Direct Message を作成**

Path: POST /2/dm\_conversations/with/:participant\_id/messages

|                                                            |                                                                                |                                                                                                                                                                                                              |
| :--------------------------------------------------------- | :----------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Description**                                            | **Standard v1.1**                                                              | **X API v2**                                                                                                                                                                                                 |
| Endpoint path                                              | POST direct\_messages/events/new (message\_create)                             | POST /2/dm\_conversations/with/:participant\_id/messages                                                                                                                                                     |
| デフォルトのリクエスト [rate limits](/x-api/fundamentals/rate-limits) | 1000 requests per user per 24 hours  <br />15000 requests per app per 24 hours | 200 requests per 15 minutes per user<br /><br />1000 requests per user per 24 hours<br /><br />15000 requests per app per 24 hours<br /><br />これらの rate limit は、すべての dm\_conversations POST エンドポイント間で共有されます。 |
| グループ Direct Messages をサポート                                 |                                                                                | ✔                                                                                                                                                                                                            |

**新しい Direct Message グループ会話を作成し、メッセージを追加**

Path: POST /2/dm\_conversations

|                                                            |                   |                                                                                                                                                                                                              |
| :--------------------------------------------------------- | :---------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Description**                                            | **Standard v1.1** | **X API v2**                                                                                                                                                                                                 |
| Endpoint path                                              | サポートされていません       | POST /2/dm\_conversations                                                                                                                                                                                    |
| デフォルトのリクエスト [rate limits](/x-api/fundamentals/rate-limits) |                   | 200 requests per 15 minutes per user<br /><br />1000 requests per user per 24 hours<br /><br />15000 requests per app per 24 hours<br /><br />これらの rate limit は、すべての dm\_conversations POST エンドポイント間で共有されます。 |
| グループ Direct Messages をサポート                                 |                   | ✔                                                                                                                                                                                                            |

**ID を指定して既存の会話に Direct Message を追加**

Path: POST /2/dm\_conversations/:dm\_conversation\_id/messages

|                                                            |                   |                                                                                                                                                                                                              |
| :--------------------------------------------------------- | :---------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Description**                                            | **Standard v1.1** | **X API v2**                                                                                                                                                                                                 |
| Endpoint path                                              | サポートされていません       | POST /2/dm\_conversations/:dm\_conversation\_id/messages                                                                                                                                                     |
| デフォルトのリクエスト [rate limits](/x-api/fundamentals/rate-limits) |                   | 200 requests per 15 minutes per user<br /><br />1000 requests per user per 24 hours<br /><br />15000 requests per app per 24 hours<br /><br />これらの rate limit は、すべての dm\_conversations POST エンドポイント間で共有されます。 |
| グループ Direct Messages をサポート                                 |                   | ✔                                                                                                                                                                                                            |
