Direct Conversations
Direct conversations are a special type of chat between only two users. Starting a direct conversation with a user creates a direct-conversation record as well as a chat record and two chat-membership records.
List of valid attributes:
| Attribute | Description | Specifics |
|---|---|---|
| user_id | ID of the user to start a conversation with | Must be set |
| first_user_id | ID of the first user in the conversation | Cannot be set |
| second_user_id | ID of the second user in the conversation | Cannot be set |
The following relationships can be included in requests:
| Relationship | Type |
|---|---|
| chat | has_one |
| first_user | belongs_to |
| second_user | belongs_to |
Create
Section titled “Create”Example request:
{ "data": { "type": "direct_conversation", "attributes": { ... } }}Example response:
{ "data": { "id": "d65305b3-9914-4929-9ebf-cbc9a4494ec5", "type": "direct_conversation", "attributes": { ... } }}This endpoint creates a direct conversation.
HTTP Request
Section titled “HTTP Request”POST /api/v1/direct_conversations
This endpoint retrieves a specific direct conversation by ID.
HTTP Request
Section titled “HTTP Request”GET /api/v1/direct_conversations/:direct_conversation_id
Response
Section titled “Response”{ "data": { "id": "d65305b3-9914-4929-9ebf-cbc9a4494ec5", "type": "direct_conversation", "attributes": { ... } }}This endpoint retrieves a list of direct conversations for the authenticated user.
HTTP Request
Section titled “HTTP Request”GET /api/v1/direct_conversations
Response
Section titled “Response”{ "data": [ { "id": "d65305b3-9914-4929-9ebf-cbc9a4494ec5", "type": "direct_conversation", "attributes": { ... } } ]}Query Parameters
Section titled “Query Parameters”The following query parameters are supported:
| Parameter | Description |
|---|---|
| search_peer | Filter direct conversations by the user name of the other participant. |
Example:
GET /api/v1/direct_conversations?search_peer=johndoe
Sorting
Section titled “Sorting”On top of the existing attribute sorts, the following sorting options are supported:
| Parameter | Description |
|---|---|
| sort=-chat_updated_at | Sort by last updated date (descending) |
Example:
GET /api/v1/direct_conversations?sort=-chat_updated_at