<commit_before># API v1 Documentation

- [Constants](#constants)
  * [Room types](#room-types)
  * [Participant types](#participant-types)
- [Room management](#room-management)
  * [Creating a new room](#creating-a-new-room)
  * [Get user´s rooms](#get-user-s-rooms)
  * [Get single room (also for guests)](#get-single-room-also-for-guests)
  * [Rename a room](#rename-a-room)
  * [Delete a room](#delete-a-room)
  * [Allow guests in a room (public room)](#allow-guests-in-a-room-public-room)
  * [Disallow guests in a room (group room)](#disallow-guests-in-a-room-group-room)
  * [Add room to favorites](#add-room-to-favorites)
  * [Remove room from favorites](#remove-room-from-favorites)
- [Participant management](#participant-management)
  * [Get list of participants in a room](#get-list-of-participants-in-a-room)
  * [Add a participant to a room](#add-a-participant-to-a-room)
  * [Delete a participant from a room](#delete-a-participant-from-a-room)
  * [Remove yourself from a room](#remove-yourself-from-a-room)
  * [Promote a user to a moderator](#promote-a-user-to-a-moderator)
  * [Demote a moderator to a user](#demote-a-moderator-to-a-user)
- [Call management](#call-management)
  * [Get list of connected participants](#get-list-of-connected-participants)
  * [Join a call](#join-a-call)
  * [Send ping to keep the call alive](#send-ping-to-keep-the-call-alive)
  * [Leave a call (but staying in the room for future calls)](#leave-a-call-but-staying-in-the-room-for-future-calls)
- [Chat](#chat)
  * [Receive chat messages of a room](#receive-chat-messages-of-a-room)
  * [Sending a new chat message](#sending-a-new-chat-message)
- [Guests](#guests)
  * [Set display name](#set-display-name)
- [Signaling](#signaling)
  * [Get signaling settings](#get-signaling-settings)
  * [External signaling API](#external-signaling-api)


Base endpoint is: `/ocs/v2.php/apps/spreed/api/v1`

## Constants

### Room types
* `1` "one to one"
* `2` group
* `3` public

### Participant types
* `1` owner
* `2` moderator
* `3` user
* `4` guest
* `5` user following a public link


## Capabilities

### 3.0 (Initial Talk release)
* `audio` - audio is supported
* `video` - video + screensharing is supported
* `chat` - simple text chat is supported, superseded by `chat-v2`

### 3.1
* `guest-signaling` - Guests can do signaling via api endpoints
* `empty-group-room` - Group rooms can be created without inviting a Nextcloud user group by default

### 3.2
* `guest-display-names` - Display names of guests are stored in the database, can be set via API (not WebRTC only) and are used on returned comments/participants/etc.
* `multi-room-users` - Users can be in multiple rooms at the same time now, therefor signaling now also requires the room/call token on the URL.
* `chat-v2` - Chat messages are now [Rich Object Strings](https://github.com/nextcloud/server/issues/1706) and pagination is available, the previous `chat` is not available anymore.

### 3.3
* `favorites` - Rooms can be marked as favorites which will pin them to the top of the room list.
* `last-room-activity` - Rooms have the `lastActivity` attribute and should be sorted by that instead of the last ping of the user.
* `no-ping` - The ping endpoint has been removed. Ping is updated with a call to fetch the signaling or chat messages instead.
* `system-messages` - Chat messages have a `systemMessage` attribute and can be generated by the system
* `mention-flag` - The room list populates the boolean `unreadMention` when the user was mentioned since their last visit
* `in-call-flags` - A new flag `participantFlags` has been introduced and is replacing the `participantInCall` boolean.

## Room management

### Creating a new room

* Method: `POST`
* Endpoint: `/room`
* Data:

    field | type | Description
    ------|------|------------
    `roomType` | int |
    `invite` | string | user id (`roomType = 1`), group id (`roomType = 2` - optional)
    `roomName` | string | room name (Not available for `roomType = 1`)

* Response:
    - Header:
        + `200 OK` when the "one to one" room already exists
        + `201 Created` when the room was created
        + `400 Bad Request` when an invalid room type was given
        + `401 Unauthorized` when the user is not logged in
        + `404 Not Found` when the user or group does not exist

    - Data:

        field | type | Description
        ------|------|------------
        `token` | string | Token identifier of the room which is used for further interaction
        `name` | string | Name of the room (can also be empty)
        `displayName` | string | `name` if non empty, otherwise it falls back to a list of participants

### Get user´s rooms

* Method: `GET`
* Endpoint: `/room`

* Response:
    - Header:
        + `200 OK`
        + `401 Unauthorized` when the user is not logged in

    - Data:
        Array of rooms, each room has at least:

        field | type | Description
        ------|------|------------
        `token` | string | Token identifier of the room which is used for further interaction
        `type` | int |
        `name` | string | Name of the room (can also be empty)
        `displayName` | string | `name` if non empty, otherwise it falls back to a list of participants
        `participantType` | int | Permissions level of the current user
        `participantInCall` | bool | Flag if the current user is in the call (deprecated, use `participantFlags` instead)
        `participantFlags` | int | Flags of the current user (only available with `in-call-flags` capability)
        `count` | int | Number of active users
        `numGuests` | int | Number of active guests
        `lastPing` | int | Timestamp of the last ping of the current user (should be used for sorting)
        `sessionId` | string | `'0'` if not connected, otherwise a 512 character long string
        `hasPassword` | bool | Flag if the room has a password
        `hasCall` | bool | Flag if the room has an active call
        `lastActivity` | int | Timestamp of the last activity in the room, in seconds and UTC time zone
        `isFavorite` | bool | Flag if the room is favorited by the user
        `unreadMessages` | int | Number of unread chat messages in the room (only available with `chat-v2` capability)
        `unreadMention` | bool | Flag if the user was mentioned since their last visit
        `lastMessage` | message | Last message in a room if available, otherwise empty
       
### Get single room (also for guests)

* Method: `GET`
* Endpoint: `/room/{token}`

* Response:
    - Header:
        + `200 OK`
        + `404 Not Found` When the room could not be found for the participant

    - Data: See array definition in `Get user´s rooms`

### Rename a room

* Method: `PUT`
* Endpoint: `/room/{token}`
* Data:

    field | type | Description
    ------|------|------------
    `roomName` | string | New name for the room (1-200 characters)<commit_msg>Add API documentation for "objectType" and "objectId"<commit_after># API v1 Documentation

- [Constants](#constants)
  * [Room types](#room-types)
  * [Participant types](#participant-types)
- [Room management](#room-management)
  * [Creating a new room](#creating-a-new-room)
  * [Get user´s rooms](#get-user-s-rooms)
  * [Get single room (also for guests)](#get-single-room-also-for-guests)
  * [Rename a room](#rename-a-room)
  * [Delete a room](#delete-a-room)
  * [Allow guests in a room (public room)](#allow-guests-in-a-room-public-room)
  * [Disallow guests in a room (group room)](#disallow-guests-in-a-room-group-room)
  * [Add room to favorites](#add-room-to-favorites)
  * [Remove room from favorites](#remove-room-from-favorites)
- [Participant management](#participant-management)
  * [Get list of participants in a room](#get-list-of-participants-in-a-room)
  * [Add a participant to a room](#add-a-participant-to-a-room)
  * [Delete a participant from a room](#delete-a-participant-from-a-room)
  * [Remove yourself from a room](#remove-yourself-from-a-room)
  * [Promote a user to a moderator](#promote-a-user-to-a-moderator)
  * [Demote a moderator to a user](#demote-a-moderator-to-a-user)
- [Call management](#call-management)
  * [Get list of connected participants](#get-list-of-connected-participants)
  * [Join a call](#join-a-call)
  * [Send ping to keep the call alive](#send-ping-to-keep-the-call-alive)
  * [Leave a call (but staying in the room for future calls)](#leave-a-call-but-staying-in-the-room-for-future-calls)
- [Chat](#chat)
  * [Receive chat messages of a room](#receive-chat-messages-of-a-room)
  * [Sending a new chat message](#sending-a-new-chat-message)
- [Guests](#guests)
  * [Set display name](#set-display-name)
- [Signaling](#signaling)
  * [Get signaling settings](#get-signaling-settings)
  * [External signaling API](#external-signaling-api)


Base endpoint is: `/ocs/v2.php/apps/spreed/api/v1`

## Constants

### Room types
* `1` "one to one"
* `2` group
* `3` public

### Participant types
* `1` owner
* `2` moderator
* `3` user
* `4` guest
* `5` user following a public link


## Capabilities

### 3.0 (Initial Talk release)
* `audio` - audio is supported
* `video` - video + screensharing is supported
* `chat` - simple text chat is supported, superseded by `chat-v2`

### 3.1
* `guest-signaling` - Guests can do signaling via api endpoints
* `empty-group-room` - Group rooms can be created without inviting a Nextcloud user group by default

### 3.2
* `guest-display-names` - Display names of guests are stored in the database, can be set via API (not WebRTC only) and are used on returned comments/participants/etc.
* `multi-room-users` - Users can be in multiple rooms at the same time now, therefor signaling now also requires the room/call token on the URL.
* `chat-v2` - Chat messages are now [Rich Object Strings](https://github.com/nextcloud/server/issues/1706) and pagination is available, the previous `chat` is not available anymore.

### 3.3
* `favorites` - Rooms can be marked as favorites which will pin them to the top of the room list.
* `last-room-activity` - Rooms have the `lastActivity` attribute and should be sorted by that instead of the last ping of the user.
* `no-ping` - The ping endpoint has been removed. Ping is updated with a call to fetch the signaling or chat messages instead.
* `system-messages` - Chat messages have a `systemMessage` attribute and can be generated by the system
* `mention-flag` - The room list populates the boolean `unreadMention` when the user was mentioned since their last visit
* `in-call-flags` - A new flag `participantFlags` has been introduced and is replacing the `participantInCall` boolean.

## Room management

### Creating a new room

* Method: `POST`
* Endpoint: `/room`
* Data:

    field | type | Description
    ------|------|------------
    `roomType` | int |
    `invite` | string | user id (`roomType = 1`), group id (`roomType = 2` - optional)
    `roomName` | string | room name (Not available for `roomType = 1`)

* Response:
    - Header:
        + `200 OK` when the "one to one" room already exists
        + `201 Created` when the room was created
        + `400 Bad Request` when an invalid room type was given
        + `401 Unauthorized` when the user is not logged in
        + `404 Not Found` when the user or group does not exist

    - Data:

        field | type | Description
        ------|------|------------
        `token` | string | Token identifier of the room which is used for further interaction
        `name` | string | Name of the room (can also be empty)
        `displayName` | string | `name` if non empty, otherwise it falls back to a list of participants

### Get user´s rooms

* Method: `GET`
* Endpoint: `/room`

* Response:
    - Header:
        + `200 OK`
        + `401 Unauthorized` when the user is not logged in

    - Data:
        Array of rooms, each room has at least:

        field | type | Description
        ------|------|------------
        `token` | string | Token identifier of the room which is used for further interaction
        `type` | int |
        `name` | string | Name of the room (can also be empty)
        `displayName` | string | `name` if non empty, otherwise it falls back to a list of participants
        `participantType` | int | Permissions level of the current user
        `participantInCall` | bool | Flag if the current user is in the call (deprecated, use `participantFlags` instead)
        `participantFlags` | int | Flags of the current user (only available with `in-call-flags` capability)
        `count` | int | Number of active users
        `numGuests` | int | Number of active guests
        `lastPing` | int | Timestamp of the last ping of the current user (should be used for sorting)
        `sessionId` | string | `'0'` if not connected, otherwise a 512 character long string
        `hasPassword` | bool | Flag if the room has a password
        `hasCall` | bool | Flag if the room has an active call
        `lastActivity` | int | Timestamp of the last activity in the room, in seconds and UTC time zone
        `isFavorite` | bool | Flag if the room is favorited by the user
        `unreadMessages` | int | Number of unread chat messages in the room (only available with `chat-v2` capability)
        `unreadMention` | bool | Flag if the user was mentioned since their last visit
        `lastMessage` | message | Last message in a room if available, otherwise empty
        `objectType` | string | The type of object that the room is associated with; "share:password" if the room is used to request a password for a share, otherwise empty
        `objectId` | string | Share token if "objectType" is "share:password", otherwise empty
       
### Get single room (also for guests)

* Method: `GET`
* Endpoint: `/room/{token}`

* Response:
    - Header:
        + `200 OK`
        + `404 Not Found` When the room could not be found for the participant

    - Data: See array definition in `Get user´s rooms`

### Rename a room

* Method: `PUT`
* Endpoint: `/room/{token}`
* Data:

    field | type | Description
    ------|------|------------
    `roomName` | string | New name for the room (1-200 characters)
{'fraction_non_alphanumeric': 0.12560011296244, 'fraction_numerical': 0.009036995199096301, 'mean_word_length': 3.1153399186519466, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2794733', 'n_tokens_mistral': 4387, 'n_tokens_neox': 4153, 'n_words': 1648}