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

# DirectMessagesClient

> X API TypeScript SDK の DirectMessagesClient クラスのリファレンス。 X API v2 の direct messages エンドポイントのメソッド、パラメーター、戻り値の型。

direct messages 操作向けのクライアント

このクライアントは X API の direct messages エンドポイントと対話するためのメソッドを提供します。認証、リクエストの整形、direct messages に関連するすべての操作のレスポンス解析を扱います。

## コンストラクター

### コンストラクター

• **new DirectMessagesClient**(`client`): [`DirectMessagesClient`](/xdks/typescript/reference/classes/DirectMessagesClient)

新しい direct messages クライアントインスタンスを作成します

#### パラメーター

| 名前       | 型                                                     | 説明                      |
| :------- | :---------------------------------------------------- | :---------------------- |
| `client` | [`Client`](/xdks/typescript/reference/classes/Client) | メインの X API クライアントインスタンス |

#### 戻り値

[`DirectMessagesClient`](/xdks/typescript/reference/classes/DirectMessagesClient)

#### 定義場所

[direct\_messages/client.ts:340](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/direct_messages/client.ts#L340)

## メソッド

### createByConversationId

▸ **createByConversationId**(`dmConversationId`, `options`): `Promise`\<`Response`>

Create DM message by conversation ID
Sends a new direct message to a specific conversation by its ID.

#### パラメーター

| 名前                 | 型                                                                             | 説明                      |
| :----------------- | :---------------------------------------------------------------------------- | :---------------------- |
| `dmConversationId` | `string`                                                                      | The DM Conversation ID. |
| `options`          | `CreateByConversationIdOptions` & \{ `requestOptions`: \{ `raw`: `true`  }  } | -                       |

#### 戻り値

`Promise`\<`Response`>

API レスポンスに解決される Promise。requestOptions.raw が true の場合は生の Response を返します

#### 定義場所

[direct\_messages/client.ts:385](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/direct_messages/client.ts#L385)

▸ **createByConversationId**(`dmConversationId`, `options?`): `Promise`\<[`CreateDmEventResponse`](/xdks/typescript/reference/interfaces/Schemas.CreateDmEventResponse)>

#### パラメーター

| 名前                 | 型                               |
| :----------------- | :------------------------------ |
| `dmConversationId` | `string`                        |
| `options?`         | `CreateByConversationIdOptions` |

#### 戻り値

`Promise`\<[`CreateDmEventResponse`](/xdks/typescript/reference/interfaces/Schemas.CreateDmEventResponse)>

#### 定義場所

[direct\_messages/client.ts:398](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/direct_messages/client.ts#L398)

***

### getEventsByConversationId

▸ **getEventsByConversationId**(`id`, `options`): `Promise`\<`Response`>

Get DM events for a DM conversation
Retrieves direct message events for a specific conversation.

#### パラメーター

| 名前        | 型                                                                                | 説明                      |
| :-------- | :------------------------------------------------------------------------------- | :---------------------- |
| `id`      | `string`                                                                         | The DM conversation ID. |
| `options` | `GetEventsByConversationIdOptions` & \{ `requestOptions`: \{ `raw`: `true`  }  } | -                       |

#### 戻り値

`Promise`\<`Response`>

API レスポンスに解決される Promise。requestOptions.raw が true の場合は生の Response を返します

#### 定義場所

[direct\_messages/client.ts:506](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/direct_messages/client.ts#L506)

▸ **getEventsByConversationId**(`id`, `options?`): `Promise`\<[`Get2DmConversationsIdDmEventsResponse`](/xdks/typescript/reference/interfaces/Schemas.Get2DmConversationsIdDmEventsResponse)>

#### パラメーター

| 名前         | 型                                  |
| :--------- | :--------------------------------- |
| `id`       | `string`                           |
| `options?` | `GetEventsByConversationIdOptions` |

#### 戻り値

`Promise`\<[`Get2DmConversationsIdDmEventsResponse`](/xdks/typescript/reference/interfaces/Schemas.Get2DmConversationsIdDmEventsResponse)>

#### 定義場所

[direct\_messages/client.ts:519](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/direct_messages/client.ts#L519)

***

### createConversation

▸ **createConversation**(`options`): `Promise`\<`Response`>

Create DM conversation
Initiates a new direct message conversation with specified participants.

#### パラメーター

| 名前        | 型                                                                         |
| :-------- | :------------------------------------------------------------------------ |
| `options` | `CreateConversationOptions` & \{ `requestOptions`: \{ `raw`: `true`  }  } |

#### 戻り値

`Promise`\<`Response`>

API レスポンスに解決される Promise。requestOptions.raw が true の場合は生の Response を返します

#### 定義場所

[direct\_messages/client.ts:784](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/direct_messages/client.ts#L784)

▸ **createConversation**(`options?`): `Promise`\<[`CreateDmEventResponse`](/xdks/typescript/reference/interfaces/Schemas.CreateDmEventResponse)>

#### パラメーター

| 名前         | 型                           |
| :--------- | :-------------------------- |
| `options?` | `CreateConversationOptions` |

#### 戻り値

`Promise`\<[`CreateDmEventResponse`](/xdks/typescript/reference/interfaces/Schemas.CreateDmEventResponse)>

#### 定義場所

[direct\_messages/client.ts:793](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/direct_messages/client.ts#L793)

***

### getEventsByParticipantId

▸ **getEventsByParticipantId**(`participantId`, `options`): `Promise`\<`Response`>

Get DM events for a DM conversation
Retrieves direct message events for a specific conversation.

#### パラメーター

| 名前              | 型                                                                               | 説明                                                                 |
| :-------------- | :------------------------------------------------------------------------------ | :----------------------------------------------------------------- |
| `participantId` | `string`                                                                        | The ID of the participant user for the One to One DM conversation. |
| `options`       | `GetEventsByParticipantIdOptions` & \{ `requestOptions`: \{ `raw`: `true`  }  } | -                                                                  |

#### 戻り値

`Promise`\<`Response`>

API レスポンスに解決される Promise。requestOptions.raw が true の場合は生の Response を返します

#### 定義場所

[direct\_messages/client.ts:889](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/direct_messages/client.ts#L889)

▸ **getEventsByParticipantId**(`participantId`, `options?`): `Promise`\<[`Get2DmConversationsWithParticipantIdDmEventsResponse`](/xdks/typescript/reference/interfaces/Schemas.Get2DmConversationsWithParticipantIdDmEventsResponse)>

#### パラメーター

| 名前              | 型                                 |
| :-------------- | :-------------------------------- |
| `participantId` | `string`                          |
| `options?`      | `GetEventsByParticipantIdOptions` |

#### 戻り値

`Promise`\<[`Get2DmConversationsWithParticipantIdDmEventsResponse`](/xdks/typescript/reference/interfaces/Schemas.Get2DmConversationsWithParticipantIdDmEventsResponse)>

#### 定義場所

[direct\_messages/client.ts:902](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/direct_messages/client.ts#L902)

***

### getEvents

▸ **getEvents**(`options`): `Promise`\<`Response`>

Get DM events
次の一覧を取得します: recent direct message events across all conversations.

#### パラメーター

| 名前        | 型                                                                |
| :-------- | :--------------------------------------------------------------- |
| `options` | `GetEventsOptions` & \{ `requestOptions`: \{ `raw`: `true`  }  } |

#### 戻り値

`Promise`\<`Response`>

API レスポンスに解決される Promise。requestOptions.raw が true の場合は生の Response を返します

#### 定義場所

[direct\_messages/client.ts:1167](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/direct_messages/client.ts#L1167)

▸ **getEvents**(`options?`): `Promise`\<[`Get2DmEventsResponse`](/xdks/typescript/reference/interfaces/Schemas.Get2DmEventsResponse)>

#### パラメーター

| 名前         | 型                  |
| :--------- | :----------------- |
| `options?` | `GetEventsOptions` |

#### 戻り値

`Promise`\<[`Get2DmEventsResponse`](/xdks/typescript/reference/interfaces/Schemas.Get2DmEventsResponse)>

#### 定義場所

[direct\_messages/client.ts:1176](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/direct_messages/client.ts#L1176)

***

### getEventsById

▸ **getEventsById**(`eventId`, `options`): `Promise`\<`Response`>

Get DM event by ID
Retrieves details of a specific direct message event by its ID.

#### パラメーター

| 名前        | 型                                                                    | 説明           |
| :-------- | :------------------------------------------------------------------- | :----------- |
| `eventId` | `string`                                                             | dm event id. |
| `options` | `GetEventsByIdOptions` & \{ `requestOptions`: \{ `raw`: `true`  }  } | -            |

#### 戻り値

`Promise`\<`Response`>

API レスポンスに解決される Promise。requestOptions.raw が true の場合は生の Response を返します

#### 定義場所

[direct\_messages/client.ts:1433](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/direct_messages/client.ts#L1433)

▸ **getEventsById**(`eventId`, `options?`): `Promise`\<[`Get2DmEventsEventIdResponse`](/xdks/typescript/reference/interfaces/Schemas.Get2DmEventsEventIdResponse)>

#### パラメーター

| 名前         | 型                      |
| :--------- | :--------------------- |
| `eventId`  | `string`               |
| `options?` | `GetEventsByIdOptions` |

#### 戻り値

`Promise`\<[`Get2DmEventsEventIdResponse`](/xdks/typescript/reference/interfaces/Schemas.Get2DmEventsEventIdResponse)>

#### 定義場所

[direct\_messages/client.ts:1446](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/direct_messages/client.ts#L1446)

***

### deleteEvents

▸ **deleteEvents**(`eventId`, `options`): `Promise`\<`Response`>

Delete DM event
Deletes a specific direct message event by its ID, if owned by the authenticated user.

#### パラメーター

| 名前                           | 型        | 説明                                            |
| :--------------------------- | :------- | :-------------------------------------------- |
| `eventId`                    | `string` | The ID of the direct-message event to delete. |
| `options`                    | `Object` | -                                             |
| `options.requestOptions`     | `Object` | -                                             |
| `options.requestOptions.raw` | `true`   | -                                             |

#### 戻り値

`Promise`\<`Response`>

API レスポンスに解決される Promise。requestOptions.raw が true の場合は生の Response を返します

#### 定義場所

[direct\_messages/client.ts:1656](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/direct_messages/client.ts#L1656)

▸ **deleteEvents**(`eventId`): `Promise`\<[`DeleteDmResponse`](/xdks/typescript/reference/interfaces/Schemas.DeleteDmResponse)>

#### パラメーター

| 名前        | 型        |
| :-------- | :------- |
| `eventId` | `string` |

#### 戻り値

`Promise`\<[`DeleteDmResponse`](/xdks/typescript/reference/interfaces/Schemas.DeleteDmResponse)>

#### 定義場所

[direct\_messages/client.ts:1669](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/direct_messages/client.ts#L1669)

***

### createByParticipantId

▸ **createByParticipantId**(`participantId`, `options`): `Promise`\<`Response`>

Create DM message by participant ID
Sends a new direct message to a specific participant by their ID.

#### パラメーター

| 名前              | 型                                                                            | 説明                                                     |
| :-------------- | :--------------------------------------------------------------------------- | :----------------------------------------------------- |
| `participantId` | `string`                                                                     | The ID of the recipient user that will receive the DM. |
| `options`       | `CreateByParticipantIdOptions` & \{ `requestOptions`: \{ `raw`: `true`  }  } | -                                                      |

#### 戻り値

`Promise`\<`Response`>

API レスポンスに解決される Promise。requestOptions.raw が true の場合は生の Response を返します

#### 定義場所

[direct\_messages/client.ts:1760](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/direct_messages/client.ts#L1760)

▸ **createByParticipantId**(`participantId`, `options?`): `Promise`\<[`CreateDmEventResponse`](/xdks/typescript/reference/interfaces/Schemas.CreateDmEventResponse)>

#### パラメーター

| 名前              | 型                              |
| :-------------- | :----------------------------- |
| `participantId` | `string`                       |
| `options?`      | `CreateByParticipantIdOptions` |

#### 戻り値

`Promise`\<[`CreateDmEventResponse`](/xdks/typescript/reference/interfaces/Schemas.CreateDmEventResponse)>

#### 定義場所

[direct\_messages/client.ts:1773](https://github.com/xdevplatform/xdk-typescript/blob/81aacb165e0802e188f608bdf462b60fc4e713a2/src/direct_messages/client.ts#L1773)
