Comparing v1.1 and v2 Manage Direct Message endpoints
Both v1.1 and v2 versions of the Direct Messages endpoints provide methods for creating Direct Message messages. This guide is intended to help understand the differences and provide information for migrating to v2. A major difference between the two versions is that v1.1 supports only one-to-one conversations, while v2 introduces support for group conversations. One artifact of this is that v1.1 supports only “message created” events, while v2 also supports events associated with participants joining and leaving conversations. In fact, a fundamental v2 update is establishing dm_conversations as a core API object. With v1.1. there are two endpoints for managing Direct Messages:- POST direct_messages/events/new - Creates a one-to-one Direct Message. This v1.1 endpoint can only create one-to-one messages, and does not support group messages.
- DELETE direct_messages/events/destroy - Deletes a one-to-one message from the view of the authenticating user.
- POST /2/dm_conversations/with/:participant_id/messages - Creates a one-to-one Direct Message. This method either adds the message to an existing one-to-one conversation or creates a new one. The :participant_id path parameter is the User ID of the account receiving the message.
- POST /2/dm_conversations - Creates a new group conversation and adds a Direct Message to it. These requests require a list of conversation participants. Note that you can create multiple conversations with the same participant list. These requests will always return a new conversation ID.
- POST /2/dm_conversations/:dm_conversation_id/messages - Creates a Direct Message and adds it to an existing conversation. The :dm_conversation_id path parameter is the ID of the conversation that the message will be added to.
The following tables compare the v2 POST methods with version v1.1. Note that these v2 offerings expand the available capabilities by supporting group conversations.
Create a new one-to-one Direct Message
Path: POST /2/dm_conversations/with/:participant_id/messages
Create a new Direct Message group conversation and add a message to it
Path: POST /2/dm_conversations
Add a Direct Message to an existing conversation by ID
Path: POST /2/dm_conversations/:dm_conversation_id/messages