> ## Documentation Index
> Fetch the complete documentation index at: https://generaltranslation.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# ダイレクトメッセージを管理する

> ダイレクトメッセージの送信と削除

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

Manage Direct Messages エンドポイントを使用すると、認証済みのユーザーに代わってダイレクトメッセージを送信および削除できます。

<div id="overview">
  ## 概要
</div>

<CardGroup cols={2}>
  <Card title="メッセージを送信" icon="paper-plane">
    他のユーザーにDMを送信する
  </Card>

  <Card title="メッセージを削除" icon="trash">
    自分だけの表示からDMを削除する
  </Card>

  <Card title="会話を作成" icon="comments">
    新しい会話を開始する
  </Card>

  <Card title="グループメッセージ" icon="users">
    グループ会話にDMを送信する
  </Card>
</CardGroup>

***

<div id="endpoints">
  ## エンドポイント
</div>

| 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イベントを削除       |

***

<div id="example-send-a-message">
  ## 例：メッセージを送信する
</div>

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

<div id="example-response">
  ## レスポンスの例
</div>

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

***

<div id="message-types">
  ## メッセージの種類
</div>

テキストメッセージを送信し、メディアを添付できます。

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

***

<div id="getting-started">
  ## はじめに
</div>

<Note>
  **前提条件**

  * 承認済みの[開発者アカウント](https://developer.x.com/en/portal/petition/essential/basic-info)
  * 開発者コンソール内の[Project と App](/ja/resources/fundamentals/developer-apps)
  * [OAuth 2.0 PKCE](/ja/resources/fundamentals/authentication#oauth-2-0-authorization-code-flow-with-pkce-2) を利用して取得したユーザーアクセストークン
</Note>

<CardGroup cols={2}>
  <Card title="クイックスタート" icon="rocket" href="/ja/x-api/direct-messages/manage/quickstart">
    最初の DM を送信する
  </Card>

  <Card title="連携ガイド" icon="book" href="/ja/x-api/direct-messages/manage/integrate">
    主要な概念とベストプラクティス
  </Card>

  <Card title="DM ルックアップ" icon="messages" href="/ja/x-api/direct-messages/lookup/introduction">
    DM イベントを取得する
  </Card>

  <Card title="APIリファレンス" icon="code" href="/ja/x-api/direct-messages/send-new-message">
    エンドポイントの詳細ドキュメント
  </Card>
</CardGroup>
