Chat Messages
List of valid attributes:
Attribute | Description | Specifics |
---|---|---|
author_id | ID of the user who wrote the message | Cannot be set |
chat_id | ID of the chat the message belongs to | Cannot be set |
content | Content of the message | Must not be empty, Type text |
created_at | Timestamp the message was created | Cannot be set |
Create
Example request:
{ "data": { "type": "message", "attributes": { "content": "Hello World" } }}
Example response:
{ "data": [ { "id": "f5139073-dc7d-434e-989e-99786b7535a1", "type": "message", "attributes": { ... } } ]}
This endpoint creates a message in a chat.
HTTP Request
POST /api/v1/chats/:chat_id/messages
URL Parameters
Parameter | Description |
---|---|
chat_id | ID of the chat where the message was written |
Update
Example request:
{ "data": { "type": "message", "attributes": { "content": "edited chat message" } }}
Example response:
{ "data": { "id": "67ac4d91-1883-47f8-a9a1-f379bbd29cce", "type": "message", "attributes": { ... } }}
This endpoint updates a chat message. Each user can only update their own chat messages.
HTTP Request
PUT /api/v1/chats/:chat_id/messages/:message_id
URL Parameters
Parameter | Description |
---|---|
chat_id | ID of the chat where the message was written |
message_id | ID of the message to edit |
List
Example response:
{ "data": [ { "id": "0e2eb81a-f952-4e8d-a6f8-9f757459a241", "type": "message", "attributes": { ... } }, { ... } ]}
This endpoint returns messages of a chat.
The sort
query parameter is not supported by this endpoint; messages are
always sorted by created_at
descending, i.e. the latest messages come first.
HTTP Request
GET /api/v1/chats/:chat_id/messages
URL Parameters
Parameter | Description |
---|---|
chat_id | The ID of the chat from which to return messages |
Delete
Example response
{ "data": { "id": "092ff7d2-abad-44e8-af38-d1c427a8b16d", "type": "message", "attributes": { ... } }}
This endpoint deletes a chat message, each user can only delete their own chat messages.
HTTP Request
DELETE /api/v1/chats/:chat_id/messages/:message_id
URL Parameters
Parameter | Description |
---|---|
chat_id | ID of the chat where the message was written |
message_id | ID of the message to delete |