Chat API#
Base endpoint is: /ocs/v2.php/apps/spreed/api/v1
Receive chat messages of a conversation#
- Method:
GET
- Endpoint:
/chat/{token}
-
Data:
field type Description lookIntoFuture
int 1
Poll and wait for new message or0
get history of a conversationlimit
int Number of chat messages to receive (100 by default, 200 at most) timeout
int $lookIntoFuture = 1
only, Number of seconds to wait for new messages (30 by default, 60 at most)lastKnownMessageId
int Serves as an offset for the query. The lastKnownMessageId for the next page is available in the X-Chat-Last-Given
header.setReadMarker
int 1
to automatically set the read timer after fetching the messages, use0
when your client callsMark chat as read
manually. (Default:1
) -
Response:
-
Status code:
200 OK
304 Not Modified
When there were no older/newer messages404 Not Found
When the conversation could not be found for the participant
-
Header:
field type Description X-Chat-Last-Given
int Offset (lastKnownMessageId) for the next page. -
Data: Array of messages, each message has at least:
field type Description id
int ID of the comment token
string Conversation token actorType
string guests
orusers
actorId
string User id of the message author actorDisplayName
string Display name of the message author timestamp
int Timestamp in seconds and UTC time zone systemMessage
string empty for normal chat message or the type of the system message (untranslated) messageType
string Currently known types are comment
,system
andcommand
message
string Message string with placeholders (see Rich Object String) messageParameters
array Message parameters for message
(see Rich Object String)
-
Sending a new chat message#
- Method:
POST
- Endpoint:
/chat/{token}
-
Data:
field type Description message
string The message the user wants to say actorDisplayName
string Guest display name (ignored for logged in users) replyTo
int The message ID this message is a reply to (only allowed for messages from the same conversation and when the message type is not system
orcommand
) -
Response:
-
Header:
201 Created
400 Bad Request
In case of any other error404 Not Found
When the conversation could not be found for the participant413 Payload Too Large
When the message was longer than the allowed limit of 32000 characters (or 1000 until Nextcloud 16.0.1, check thespreed => config => chat => max-length
capability for the limit)
-
Data: The full message array of the new message, as defined in Receive chat messages of a conversation
-
Mark chat as read#
- Method:
POST
- Endpoint:
/chat/{token}/read
-
Data:
field type Description lastReadMessage
int The last read message ID -
Response:
- Header:
200 OK
404 Not Found
When the room could not be found for the participant, or the participant is a guest.
- Header:
Get mention autocomplete suggestions#
- Method:
GET
- Endpoint:
/chat/{token}/mentions
-
Data:
field type Description search
string Search term for name suggestions (should at least be 1 character) limit
int Number of suggestions to receive (20 by default) -
Response:
-
Status code:
200 OK
404 Not Found
When the conversation could not be found for the participant
-
Data: Array of suggestions, each suggestion has at least:
field type Description id
string The user id which should be sent as @<id>
in the messagelabel
string The displayname of the user source
string The type of the user, currently only users
-
System messages#
conversation_created
- {actor} created the conversationconversation_renamed
- {actor} renamed the conversation from "foo" to "bar"call_started
- {actor} started a callcall_joined
- {actor} joined the callcall_left
- {actor} left the callcall_ended
- Call with {user1}, {user2}, {user3}, {user4} and {user5} (Duration 30:23)guests_allowed
- {actor} allowed guests in the conversationguests_disallowed
- {actor} disallowed guests in the conversationpassword_set
- {actor} set a password for the conversationpassword_removed
- {actor} removed the password for the conversationuser_added
- {actor} added {user} to the conversationuser_removed
- {actor} removed {user} from the conversationmoderator_promoted
- {actor} promoted {user} to moderatormoderator_demoted
- {actor} demoted {user} from moderatorguest_moderator_promoted
- {actor} promoted {user} to moderatorguest_moderator_demoted
- {actor} demoted {user} from moderatorread_only_off
- {actor} unlocked the conversationread_only
- {actor} locked the conversation
Guests#
Signaling#
Get signaling settings#
- Method:
GET
- Endpoint:
/signaling/settings
-
Data:
field type Description stunservers
array STUN servers turnservers
array TURN servers server
string URL of the external signaling server ticket
string Ticket for the external signaling server - STUN server
field type Description url
string STUN server URL - TURN server
field type Description url
array One element array with TURN server URL urls
array One element array with TURN server URL username
string User name for the TURN server credential
string User password for the TURN server -
Response:
- Header:
200 OK
404 Not Found
- Header:
External signaling API#
See External Signaling API Draft in the wiki…