Doku durchsuchen
Menü
Geändert am Auf GitHub bearbeiten

Server-API: chat

Als Markdown kopieren

Diese Routen liegen auf der Server-API, Port 21114 (21121 in Docker). Sie nehmen einen API-Schlüssel in X-API-Key oder ein Anmelde-Token; siehe Die HTTP-API. Die Beschreibungen stehen auf Englisch, wie in der OpenAPI-Beschreibung.

The chat store of the server API: messages, read marks, contacts and groups, which the console's chat reads and writes. Each route needs chat.support or chat.team. Errors come as {"error": "..."} with the content type text/plain.

GET /api/chat/contacts/{rest}

List whom a device can chat with.

Gives the devices it shares a chat group with and every account that has chat.support or chat.team, with the messages from each it has not read. With panel after the slash it gives every device; the console narrows that list to the account's device scope. The route itself does not check the scope.

On the server API, port 21114. Needs chat.support or chat.team.

Parameter In Type Required What it is
rest path string yes The device ID, or panel for every device; the route takes the rest of the path

200: Done (application/json)

Field Type Required What it is
contacts array of object yes
contacts[].id string yes A device ID, or operator:<name> for an account
contacts[].name string yes The host name, else the device ID; the user name for an account
contacts[].hostname string yes Console for an account
contacts[].online boolean yes Always true for an account
contacts[].last_seen string (date-time) yes Null for an account
contacts[].unread integer yes
contacts[].avatar_color string yes A CSS hsl() colour
contacts[].role string, one of device, operator yes
Error When
401 No credential, or one that is not valid
403 The credential's role lacks the permission

POST /api/chat/groups

Make a chat group.

A caller other than the console itself is recorded as the creator. Only the creator or a super admin may change or delete the group.

On the server API, port 21114. Needs chat.support or chat.team.

Request body, application/json:

Field Type Required What it is
name string yes
members array of string yes Device IDs or operator:<name>
created_by string Only read from the console

200: Made (application/json)

ServerChatGroup.

Error When
400 The body is no JSON, or name or members is missing
401 No credential, or one that is not valid
403 The credential's role lacks the permission

GET /api/chat/groups/{rest}

List the chat groups of a member.

The member is looked for anywhere in a group's member list, so a part of an ID matches too.

On the server API, port 21114. Needs chat.support or chat.team.

Parameter In Type Required What it is
rest path string yes The member: a device ID or operator:<name>; the route takes the rest of the path

200: Done (application/json)

Field Type Required
groups array of ServerChatGroup yes
Error When
400 No member after the slash
401 No credential, or one that is not valid
403 The credential's role lacks the permission

PUT /api/chat/groups/{rest}

Rename a chat group or change its members.

Writes both fields: a field left out becomes empty. Only the creator or a super admin may change it.

On the server API, port 21114. Needs chat.support or chat.team.

Parameter In Type Required What it is
rest path string yes The group: group:<id>; the route takes the rest of the path

Request body, application/json:

Field Type What it is
name string
members array of string Device IDs or operator:<name>

200: Done (application/json)

Field Type Required
ok true yes
Error When
400 No group after the slash, or the body is no JSON
401 No credential, or one that is not valid
403 The role lacks the permission, or the caller is neither the group's creator nor a super admin
404 There is no such group

DELETE /api/chat/groups/{rest}

Delete a chat group with its messages.

Only the creator or a super admin may delete it.

On the server API, port 21114. Needs chat.support or chat.team.

Parameter In Type Required What it is
rest path string yes The group: group:<id>; the route takes the rest of the path

200: Done (application/json)

Field Type Required
ok true yes
Error When
400 No group after the slash
401 No credential, or one that is not valid
403 The role lacks the permission, or the caller is neither the group's creator nor a super admin
404 There is no such group

GET /api/chat/history/{rest}

Show the messages of a chat conversation.

Gives the newest messages, oldest first. The route checks neither the device scope nor group membership.

On the server API, port 21114. Needs chat.support or chat.team.

Parameter In Type Required What it is
rest path string yes The conversation: a device ID, or group:<id> for a chat group; the route takes the rest of the path
limit query integer default 100, at least 1, at most 500
before query integer

200: Done (application/json)

Field Type Required
conversation_id string yes
messages array of ServerChatMessage yes
Error When
400 No conversation after the slash
401 No credential, or one that is not valid
403 The credential's role lacks the permission

POST /api/chat/messages

Save a chat message and send it to a computer.

Stores the message and tells the console. With to_id the message also goes to that computer over CDAP when it is connected; a failed delivery does not fail the call. A caller other than the console itself writes as itself: from_id and from_name become its user name.

On the server API, port 21114. Needs chat.support or chat.team.

Request body, application/json:

Field Type Required What it is
conversation_id string yes A device ID, or group:<id> for a group
to_id string The computer to send it to
text string yes Cut to 4096 bytes
from_id string Only read from the console
from_name string Only read from the console

200: Saved (application/json)

ServerChatMessage.

Error When
400 The body is no JSON, or conversation_id or text is missing
401 No credential, or one that is not valid
403 The credential's role lacks the permission

POST /api/chat/read

Mark the messages of a conversation as read.

Marks every unread message in the conversation that someone else sent. A group conversation must be a group that exists, a device's conversation a device in the caller's organization and scope. A caller other than the console itself reads as itself.

On the server API, port 21114. Needs chat.support or chat.team.

Request body, application/json:

Field Type Required What it is
conversation_id string yes A device ID, or group:<id> for a group
reader_id string Only read from the console

200: Done (application/json)

Field Type Required
ok true yes
Error When
400 The body is no JSON, or conversation_id is missing
401 No credential, or one that is not valid
403 The role lacks the permission, or the device is outside the caller's organization or scope
404 There is no such group

GET /api/chat/unread/{rest}

Count the unread chat messages of a device.

Counts the unread messages in its conversation or sent to it that it did not send itself. The route does not check the device scope.

On the server API, port 21114. Needs chat.support or chat.team.

Parameter In Type Required What it is
rest path string yes The device ID; the route takes the rest of the path

200: Done (application/json)

Field Type Required
device_id string yes
unread integer yes
Error When
400 No device after the slash
401 No credential, or one that is not valid
403 The credential's role lacks the permission

Durchsucht Seiten, Abschnitte, Befehle und Einstellungen.