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:

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

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.

POST /api/v1/direct_conversations

This endpoint retrieves a specific direct conversation by ID.

GET /api/v1/direct_conversations/:direct_conversation_id

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

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

GET /api/v1/direct_conversations

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

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

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