Skip to main content
Client for direct messages operations This client provides methods for interacting with the direct messages endpoints of the X API. It handles authentication, request formatting, and response parsing for all direct messages related operations.

Constructors

constructor

new DirectMessagesClient(client): DirectMessagesClient Creates a new direct messages client instance

Parameters

NameTypeDescription
clientClientThe main X API client instance

Returns

DirectMessagesClient

Defined in

direct_messages/client.ts:211

Methods

getEvents

getEvents(options?): Promise<Get2DmEventsResponse> Get DM events Retrieves a list of recent direct message events across all conversations.

Parameters

NameType
optionsGetEventsOptions

Returns

Promise<Get2DmEventsResponse> Promise resolving to the API response

Defined in

direct_messages/client.ts:224

getEventsByParticipantId

getEventsByParticipantId(participantId, options?): Promise<Get2DmConversationsWithParticipantIdDmEventsResponse> Get DM events for a DM conversation Retrieves direct message events for a specific conversation.

Parameters

NameTypeDescription
participantIdstringThe ID of the participant user for the One to One DM conversation.
optionsGetEventsByParticipantIdOptions-

Returns

Promise<Get2DmConversationsWithParticipantIdDmEventsResponse> Promise resolving to the API response

Defined in

direct_messages/client.ts:311

createByConversationId

createByConversationId(dmConversationId, options?): Promise<CreateDmEventResponse> Create DM message by conversation ID Sends a new direct message to a specific conversation by its ID.

Parameters

NameTypeDescription
dmConversationIdstringThe DM Conversation ID.
optionsCreateByConversationIdOptions-

Returns

Promise<CreateDmEventResponse> Promise resolving to the API response

Defined in

direct_messages/client.ts:406

createByParticipantId

createByParticipantId(participantId, options?): Promise<CreateDmEventResponse> Create DM message by participant ID Sends a new direct message to a specific participant by their ID.

Parameters

NameTypeDescription
participantIdstringThe ID of the recipient user that will receive the DM.
optionsCreateByParticipantIdOptions-

Returns

Promise<CreateDmEventResponse> Promise resolving to the API response

Defined in

direct_messages/client.ts:457

getEventsByConversationId

getEventsByConversationId(id, options?): Promise<Get2DmConversationsIdDmEventsResponse> Get DM events for a DM conversation Retrieves direct message events for a specific conversation.

Parameters

NameTypeDescription
idstringThe DM conversation ID.
optionsGetEventsByConversationIdOptions-

Returns

Promise<Get2DmConversationsIdDmEventsResponse> Promise resolving to the API response

Defined in

direct_messages/client.ts:508

getEventsById

getEventsById(eventId, options?): Promise<Get2DmEventsEventIdResponse> Get DM event by ID Retrieves details of a specific direct message event by its ID.

Parameters

NameTypeDescription
eventIdstringdm event id.
optionsGetEventsByIdOptions-

Returns

Promise<Get2DmEventsEventIdResponse> Promise resolving to the API response

Defined in

direct_messages/client.ts:600

deleteEvents

deleteEvents(eventId): Promise<DeleteDmResponse> Delete DM event Deletes a specific direct message event by its ID, if owned by the authenticated user.

Parameters

NameTypeDescription
eventIdstringThe ID of the direct-message event to delete.

Returns

Promise<DeleteDmResponse> Promise resolving to the API response

Defined in

direct_messages/client.ts:674

createConversation

createConversation(options?): Promise<CreateDmEventResponse> Create DM conversation Initiates a new direct message conversation with specified participants.

Parameters

NameType
optionsCreateConversationOptions

Returns

Promise<CreateDmEventResponse> Promise resolving to the API response

Defined in

direct_messages/client.ts:708