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:340

Methods

createByConversationId

createByConversationId(dmConversationId, options): Promise<Response> 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 & { requestOptions: { raw: true } }-

Returns

Promise<Response> Promise resolving to the API response, or raw Response if requestOptions.raw is true

Defined in

direct_messages/client.ts:385 createByConversationId(dmConversationId, options?): Promise<CreateDmEventResponse>

Parameters

NameType
dmConversationIdstring
options?CreateByConversationIdOptions

Returns

Promise<CreateDmEventResponse>

Defined in

direct_messages/client.ts:398

getEventsByConversationId

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

Parameters

NameTypeDescription
idstringThe DM conversation ID.
optionsGetEventsByConversationIdOptions & { requestOptions: { raw: true } }-

Returns

Promise<Response> Promise resolving to the API response, or raw Response if requestOptions.raw is true

Defined in

direct_messages/client.ts:506 getEventsByConversationId(id, options?): Promise<Get2DmConversationsIdDmEventsResponse>

Parameters

NameType
idstring
options?GetEventsByConversationIdOptions

Returns

Promise<Get2DmConversationsIdDmEventsResponse>

Defined in

direct_messages/client.ts:519

createConversation

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

Parameters

NameType
optionsCreateConversationOptions & { requestOptions: { raw: true } }

Returns

Promise<Response> Promise resolving to the API response, or raw Response if requestOptions.raw is true

Defined in

direct_messages/client.ts:784 createConversation(options?): Promise<CreateDmEventResponse>

Parameters

NameType
options?CreateConversationOptions

Returns

Promise<CreateDmEventResponse>

Defined in

direct_messages/client.ts:793

getEventsByParticipantId

getEventsByParticipantId(participantId, options): Promise<Response> 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 & { requestOptions: { raw: true } }-

Returns

Promise<Response> Promise resolving to the API response, or raw Response if requestOptions.raw is true

Defined in

direct_messages/client.ts:889 getEventsByParticipantId(participantId, options?): Promise<Get2DmConversationsWithParticipantIdDmEventsResponse>

Parameters

NameType
participantIdstring
options?GetEventsByParticipantIdOptions

Returns

Promise<Get2DmConversationsWithParticipantIdDmEventsResponse>

Defined in

direct_messages/client.ts:902

getEvents

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

Parameters

NameType
optionsGetEventsOptions & { requestOptions: { raw: true } }

Returns

Promise<Response> Promise resolving to the API response, or raw Response if requestOptions.raw is true

Defined in

direct_messages/client.ts:1167 getEvents(options?): Promise<Get2DmEventsResponse>

Parameters

NameType
options?GetEventsOptions

Returns

Promise<Get2DmEventsResponse>

Defined in

direct_messages/client.ts:1176

getEventsById

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

Parameters

NameTypeDescription
eventIdstringdm event id.
optionsGetEventsByIdOptions & { requestOptions: { raw: true } }-

Returns

Promise<Response> Promise resolving to the API response, or raw Response if requestOptions.raw is true

Defined in

direct_messages/client.ts:1433 getEventsById(eventId, options?): Promise<Get2DmEventsEventIdResponse>

Parameters

NameType
eventIdstring
options?GetEventsByIdOptions

Returns

Promise<Get2DmEventsEventIdResponse>

Defined in

direct_messages/client.ts:1446

deleteEvents

deleteEvents(eventId, options): Promise<Response> 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.
optionsObject-
options.requestOptionsObject-
options.requestOptions.rawtrue-

Returns

Promise<Response> Promise resolving to the API response, or raw Response if requestOptions.raw is true

Defined in

direct_messages/client.ts:1656 deleteEvents(eventId): Promise<DeleteDmResponse>

Parameters

NameType
eventIdstring

Returns

Promise<DeleteDmResponse>

Defined in

direct_messages/client.ts:1669

createByParticipantId

createByParticipantId(participantId, options): Promise<Response> 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 & { requestOptions: { raw: true } }-

Returns

Promise<Response> Promise resolving to the API response, or raw Response if requestOptions.raw is true

Defined in

direct_messages/client.ts:1760 createByParticipantId(participantId, options?): Promise<CreateDmEventResponse>

Parameters

NameType
participantIdstring
options?CreateByParticipantIdOptions

Returns

Promise<CreateDmEventResponse>

Defined in

direct_messages/client.ts:1773