Zum Inhalt springen

Direct Conversations

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

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:

AttributeDescriptionSpecifics
user_idID of the user to start a conversation withMust be set
first_user_idID of the first user in the conversationCannot be set
second_user_idID of the second user in the conversationCannot be set

The following relationships can be included in requests:

RelationshipType
chathas_one
first_userbelongs_to
second_userbelongs_to

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

POST /api/v1/direct_conversations

Show

This endpoint retrieves a specific direct conversation by ID.

HTTP Request

GET /api/v1/direct_conversations/:direct_conversation_id

Response

{
"data": {
"id": "d65305b3-9914-4929-9ebf-cbc9a4494ec5",
"type": "direct_conversation",
"attributes": {
...
}
}
}

List

This endpoint retrieves a list of direct conversations for the authenticated user.

HTTP Request

GET /api/v1/direct_conversations

Response

{
"data": [
{
"id": "d65305b3-9914-4929-9ebf-cbc9a4494ec5",
"type": "direct_conversation",
"attributes": {
...
}
}
]
}

Query Parameters

The following query parameters are supported:

ParameterDescription
search_peerFilter direct conversations by the user name of the other participant.

Example: GET /api/v1/direct_conversations?search_peer=johndoe

Sorting

On top of the existing attribute sorts, the following sorting options are supported:

ParameterDescription
sort=-chat_updated_atSort by last updated date (descending)

Example: GET /api/v1/direct_conversations?sort=-chat_updated_at