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

> Referência para a classe DirectMessagesClient no SDK TypeScript da X API. Métodos, parâmetros e tipos de retorno para os endpoints direct messages da X API v2.

Client para operações de direct messages

Este client fornece métodos para interagir com os endpoints direct messages
da X API. Ele cuida da autenticação, formatação de requisição e análise
de resposta para todas as operações relacionadas a direct messages.

## Construtores

### constructor

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

Cria uma nova instância do client direct messages

#### Parâmetros

| Nome     | Tipo                                                  | Descrição                                |
| :------- | :---------------------------------------------------- | :--------------------------------------- |
| `client` | [`Client`](/xdks/typescript/reference/classes/Client) | A instância principal do client da X API |

#### Retorna

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

#### Definido em

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

## Métodos

### createByConversationId

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

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

#### Parâmetros

| Nome               | Tipo                                                                          | Descrição               |
| :----------------- | :---------------------------------------------------------------------------- | :---------------------- |
| `dmConversationId` | `string`                                                                      | The DM Conversation ID. |
| `options`          | `CreateByConversationIdOptions` & \{ `requestOptions`: \{ `raw`: `true`  }  } | -                       |

#### Retorna

`Promise`\<`Response`>

Promise que resolve para a resposta da API, ou Response bruto se requestOptions.raw for true

#### Definido em

[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)>

#### Parâmetros

| Nome               | Tipo                            |
| :----------------- | :------------------------------ |
| `dmConversationId` | `string`                        |
| `options?`         | `CreateByConversationIdOptions` |

#### Retorna

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

#### Definido em

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

#### Parâmetros

| Nome      | Tipo                                                                             | Descrição               |
| :-------- | :------------------------------------------------------------------------------- | :---------------------- |
| `id`      | `string`                                                                         | The DM conversation ID. |
| `options` | `GetEventsByConversationIdOptions` & \{ `requestOptions`: \{ `raw`: `true`  }  } | -                       |

#### Retorna

`Promise`\<`Response`>

Promise que resolve para a resposta da API, ou Response bruto se requestOptions.raw for true

#### Definido em

[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)>

#### Parâmetros

| Nome       | Tipo                               |
| :--------- | :--------------------------------- |
| `id`       | `string`                           |
| `options?` | `GetEventsByConversationIdOptions` |

#### Retorna

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

#### Definido em

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

#### Parâmetros

| Nome      | Tipo                                                                      |
| :-------- | :------------------------------------------------------------------------ |
| `options` | `CreateConversationOptions` & \{ `requestOptions`: \{ `raw`: `true`  }  } |

#### Retorna

`Promise`\<`Response`>

Promise que resolve para a resposta da API, ou Response bruto se requestOptions.raw for true

#### Definido em

[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)>

#### Parâmetros

| Nome       | Tipo                        |
| :--------- | :-------------------------- |
| `options?` | `CreateConversationOptions` |

#### Retorna

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

#### Definido em

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

#### Parâmetros

| Nome            | Tipo                                                                            | Descrição                                                          |
| :-------------- | :------------------------------------------------------------------------------ | :----------------------------------------------------------------- |
| `participantId` | `string`                                                                        | The ID of the participant user for the One to One DM conversation. |
| `options`       | `GetEventsByParticipantIdOptions` & \{ `requestOptions`: \{ `raw`: `true`  }  } | -                                                                  |

#### Retorna

`Promise`\<`Response`>

Promise que resolve para a resposta da API, ou Response bruto se requestOptions.raw for true

#### Definido em

[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)>

#### Parâmetros

| Nome            | Tipo                              |
| :-------------- | :-------------------------------- |
| `participantId` | `string`                          |
| `options?`      | `GetEventsByParticipantIdOptions` |

#### Retorna

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

#### Definido em

[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
Retrieves a list of recent direct message events across all conversations.

#### Parâmetros

| Nome      | Tipo                                                             |
| :-------- | :--------------------------------------------------------------- |
| `options` | `GetEventsOptions` & \{ `requestOptions`: \{ `raw`: `true`  }  } |

#### Retorna

`Promise`\<`Response`>

Promise que resolve para a resposta da API, ou Response bruto se requestOptions.raw for true

#### Definido em

[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)>

#### Parâmetros

| Nome       | Tipo               |
| :--------- | :----------------- |
| `options?` | `GetEventsOptions` |

#### Retorna

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

#### Definido em

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

#### Parâmetros

| Nome      | Tipo                                                                 | Descrição    |
| :-------- | :------------------------------------------------------------------- | :----------- |
| `eventId` | `string`                                                             | dm event id. |
| `options` | `GetEventsByIdOptions` & \{ `requestOptions`: \{ `raw`: `true`  }  } | -            |

#### Retorna

`Promise`\<`Response`>

Promise que resolve para a resposta da API, ou Response bruto se requestOptions.raw for true

#### Definido em

[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)>

#### Parâmetros

| Nome       | Tipo                   |
| :--------- | :--------------------- |
| `eventId`  | `string`               |
| `options?` | `GetEventsByIdOptions` |

#### Retorna

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

#### Definido em

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

#### Parâmetros

| Nome                         | Tipo     | Descrição                                     |
| :--------------------------- | :------- | :-------------------------------------------- |
| `eventId`                    | `string` | The ID of the direct-message event to delete. |
| `options`                    | `Object` | -                                             |
| `options.requestOptions`     | `Object` | -                                             |
| `options.requestOptions.raw` | `true`   | -                                             |

#### Retorna

`Promise`\<`Response`>

Promise que resolve para a resposta da API, ou Response bruto se requestOptions.raw for true

#### Definido em

[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)>

#### Parâmetros

| Nome      | Tipo     |
| :-------- | :------- |
| `eventId` | `string` |

#### Retorna

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

#### Definido em

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

#### Parâmetros

| Nome            | Tipo                                                                         | Descrição                                              |
| :-------------- | :--------------------------------------------------------------------------- | :----------------------------------------------------- |
| `participantId` | `string`                                                                     | The ID of the recipient user that will receive the DM. |
| `options`       | `CreateByParticipantIdOptions` & \{ `requestOptions`: \{ `raw`: `true`  }  } | -                                                      |

#### Retorna

`Promise`\<`Response`>

Promise que resolve para a resposta da API, ou Response bruto se requestOptions.raw for true

#### Definido em

[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)>

#### Parâmetros

| Nome            | Tipo                           |
| :-------------- | :----------------------------- |
| `participantId` | `string`                       |
| `options?`      | `CreateByParticipantIdOptions` |

#### Retorna

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

#### Definido em

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