Skip to main content
This guide covers the key concepts you need to integrate the manage Direct Messages endpoints into your application.

Authentication

DM endpoints require user authentication:
App-Only authentication is not supported. All Direct Messages are private.

Required scopes (OAuth 2.0)


Endpoints overview


Sending messages

One-to-one message

Send a message to a specific user. Creates a new conversation if one doesn’t exist:
cURL

Group conversation

Create a new group and send the first message:
cURL
The conversation_type field must be set to "Group" (case sensitive).

Add to existing conversation

Send a message to any conversation you’re part of:
cURL

Media attachments

Attach one piece of media (photo, video, or GIF) per message.
1

Upload media

Use the Media Upload endpoint to upload your file and get a media_id.
2

Include in message

  • The authenticated user must have uploaded the media
  • Media is available for 24 hours after upload
  • Only one attachment per message is supported

Sharing posts

Include a Post in your message by adding the Post URL to the text:
The response will include a referenced_tweets field with the Post ID.

Message requirements

*At least one of text or attachments must be provided.

ID compatibility with v1.1

Conversation and event IDs are shared between v1.1 and v2 endpoints. This enables hybrid workflows:
  • Create messages with v2
  • Delete messages with v1.1 (not yet available in v2)
  • Reference conversation IDs from x.com URLs

Error handling

Common issues

The recipient may have DM settings that prevent messages from unknown users, or may have blocked you.
Ensure the media was uploaded by the same authenticated user and is less than 24 hours old.
Verify all participant IDs are valid and the users allow group DM invites.

Next steps

Quickstart

Send your first Direct Message

DM lookup

Retrieve DM conversations

Media upload

Upload media for attachments

API Reference

Full endpoint documentation