You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

662 lines
23 KiB

  1. # API v1 Documentation
  2. - [Constants](#constants)
  3. * [Room types](#room-types)
  4. * [Participant types](#participant-types)
  5. - [Room management](#room-management)
  6. * [Creating a new room](#creating-a-new-room)
  7. * [Get user´s rooms](#get-user-s-rooms)
  8. * [Get single room (also for guests)](#get-single-room-also-for-guests)
  9. * [Rename a room](#rename-a-room)
  10. * [Delete a room](#delete-a-room)
  11. * [Allow guests in a room (public room)](#allow-guests-in-a-room-public-room)
  12. * [Disallow guests in a room (group room)](#disallow-guests-in-a-room-group-room)
  13. * [Add room to favorites](#add-room-to-favorites)
  14. * [Remove room from favorites](#remove-room-from-favorites)
  15. * [Set notification level](#set-notification-level)
  16. - [Participant management](#participant-management)
  17. * [Get list of participants in a room](#get-list-of-participants-in-a-room)
  18. * [Add a participant to a room](#add-a-participant-to-a-room)
  19. * [Delete a participant from a room](#delete-a-participant-from-a-room)
  20. * [Remove yourself from a room](#remove-yourself-from-a-room)
  21. * [Promote a user to a moderator](#promote-a-user-to-a-moderator)
  22. * [Demote a moderator to a user](#demote-a-moderator-to-a-user)
  23. - [Call management](#call-management)
  24. * [Get list of connected participants](#get-list-of-connected-participants)
  25. * [Join a call](#join-a-call)
  26. * [Send ping to keep the call alive](#send-ping-to-keep-the-call-alive)
  27. * [Leave a call (but staying in the room for future calls)](#leave-a-call-but-staying-in-the-room-for-future-calls)
  28. - [Chat](#chat)
  29. * [Receive chat messages of a room](#receive-chat-messages-of-a-room)
  30. * [Sending a new chat message](#sending-a-new-chat-message)
  31. - [Guests](#guests)
  32. * [Set display name](#set-display-name)
  33. - [Signaling](#signaling)
  34. * [Get signaling settings](#get-signaling-settings)
  35. * [External signaling API](#external-signaling-api)
  36. Base endpoint is: `/ocs/v2.php/apps/spreed/api/v1`
  37. ## Constants
  38. ### Room types
  39. * `1` "one to one"
  40. * `2` group
  41. * `3` public
  42. ### Read-only states
  43. * `0` read-write
  44. * `1` read-only
  45. ### Participant types
  46. * `1` owner
  47. * `2` moderator
  48. * `3` user
  49. * `4` guest
  50. * `5` user following a public link
  51. ## Capabilities
  52. ### 3.0 (Initial Talk release)
  53. * `audio` - audio is supported
  54. * `video` - video + screensharing is supported
  55. * `chat` - simple text chat is supported, superseded by `chat-v2`
  56. ### 3.1
  57. * `guest-signaling` - Guests can do signaling via api endpoints
  58. * `empty-group-room` - Group rooms can be created without inviting a Nextcloud user group by default
  59. ### 3.2
  60. * `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.
  61. * `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.
  62. * `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.
  63. ### 4.0
  64. * `favorites` - Rooms can be marked as favorites which will pin them to the top of the room list.
  65. * `last-room-activity` - Rooms have the `lastActivity` attribute and should be sorted by that instead of the last ping of the user.
  66. * `no-ping` - The ping endpoint has been removed. Ping is updated with a call to fetch the signaling or chat messages instead.
  67. * `system-messages` - Chat messages have a `systemMessage` attribute and can be generated by the system
  68. * `mention-flag` - The room list populates the boolean `unreadMention` when the user was mentioned since their last visit
  69. * `in-call-flags` - A new flag `participantFlags` has been introduced and is replacing the `participantInCall` boolean.
  70. ### 5.0
  71. * `invite-by-mail` - *Replaced by `invite-groups-and-mails`* Guests can be invited with their email address
  72. * `notification-levels` - Users can select when they want to be notified in conversations
  73. * `invite-groups-and-mails` - Groups can be added to existing conversations via the add participant endpoint
  74. ### 6.0
  75. * `locked-one-to-one-rooms` - One-to-one conversations are now locked to the users. Neither guests nor other participants can be added, so the options to do that should be hidden as well. Also a user can only leave a one-to-one room (not delete). It will be deleted when the other participant left too. If the other participant posts a new chat message or starts a call, the left-participant will be re-added.
  76. * `read-only-rooms` - Rooms can be in `read-only` mode which means people can not do calls or write chat messages.
  77. ## Room management
  78. ### Creating a new room
  79. * Method: `POST`
  80. * Endpoint: `/room`
  81. * Data:
  82. field | type | Description
  83. ------|------|------------
  84. `roomType` | int |
  85. `invite` | string | user id (`roomType = 1`), group id (`roomType = 2` - optional)
  86. `roomName` | string | room name (Not available for `roomType = 1`)
  87. * Response:
  88. - Header:
  89. + `200 OK` when the "one to one" room already exists
  90. + `201 Created` when the room was created
  91. + `400 Bad Request` when an invalid room type was given
  92. + `401 Unauthorized` when the user is not logged in
  93. + `404 Not Found` when the user or group does not exist
  94. - Data:
  95. field | type | Description
  96. ------|------|------------
  97. `token` | string | Token identifier of the room which is used for further interaction
  98. `name` | string | Name of the room (can also be empty)
  99. `displayName` | string | `name` if non empty, otherwise it falls back to a list of participants
  100. ### Get user´s rooms
  101. * Method: `GET`
  102. * Endpoint: `/room`
  103. * Response:
  104. - Header:
  105. + `200 OK`
  106. + `401 Unauthorized` when the user is not logged in
  107. - Data:
  108. Array of rooms, each room has at least:
  109. field | type | Description
  110. ------|------|------------
  111. `token` | string | Token identifier of the room which is used for further interaction
  112. `type` | int |
  113. `name` | string | Name of the room (can also be empty)
  114. `displayName` | string | `name` if non empty, otherwise it falls back to a list of participants
  115. `participantType` | int | Permissions level of the current user
  116. `participantInCall` | bool | Flag if the current user is in the call (deprecated, use `participantFlags` instead)
  117. `participantFlags` | int | Flags of the current user (only available with `in-call-flags` capability)
  118. `readOnly` | int | Read-only state for the current user (only available with `read-only-rooms` capability)
  119. `count` | int | Number of active users
  120. `numGuests` | int | Number of active guests
  121. `lastPing` | int | Timestamp of the last ping of the current user (should be used for sorting)
  122. `sessionId` | string | `'0'` if not connected, otherwise a 512 character long string
  123. `hasPassword` | bool | Flag if the room has a password
  124. `hasCall` | bool | Flag if the room has an active call
  125. `lastActivity` | int | Timestamp of the last activity in the room, in seconds and UTC time zone
  126. `isFavorite` | bool | Flag if the room is favorited by the user
  127. `notificationLevel` | int | The notification level for the user (one of `Participant::NOTIFY_*` (1-3))
  128. `unreadMessages` | int | Number of unread chat messages in the room (only available with `chat-v2` capability)
  129. `unreadMention` | bool | Flag if the user was mentioned since their last visit
  130. `lastMessage` | message | Last message in a room if available, otherwise empty
  131. `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
  132. `objectId` | string | Share token if "objectType" is "share:password", otherwise empty
  133. ### Get single room (also for guests)
  134. * Method: `GET`
  135. * Endpoint: `/room/{token}`
  136. * Response:
  137. - Header:
  138. + `200 OK`
  139. + `404 Not Found` When the room could not be found for the participant
  140. - Data: See array definition in `Get user´s rooms`
  141. ### Rename a room
  142. * Method: `PUT`
  143. * Endpoint: `/room/{token}`
  144. * Data:
  145. field | type | Description
  146. ------|------|------------
  147. `roomName` | string | New name for the room (1-200 characters)
  148. * Response:
  149. - Header:
  150. + `200 OK`
  151. + `400 Bad Request` When the name is too long or empty
  152. + `403 Forbidden` When the current user is not a moderator/owner
  153. + `404 Not Found` When the room could not be found for the participant
  154. + `405 Method Not Allowed` When the room is a one to one room
  155. ### Set password for a room
  156. * Method: `PUT`
  157. * Endpoint: `/room/{token}/password`
  158. * Data:
  159. field | type | Description
  160. ------|------|------------
  161. `password` | string | New password for the room
  162. * Response:
  163. - Header:
  164. + `200 OK`
  165. + `403 Forbidden` When the current user is not a moderator/owner or the room is not a public room
  166. + `404 Not Found` When the room could not be found for the participant
  167. ### Delete a room
  168. * Method: `DELETE`
  169. * Endpoint: `/room/{token}`
  170. * Response:
  171. - Header:
  172. + `200 OK`
  173. + `403 Forbidden` When the current user is not a moderator/owner
  174. + `404 Not Found` When the room could not be found for the participant
  175. ### Allow guests in a room (public room)
  176. * Method: `POST`
  177. * Endpoint: `/room/{token}/public`
  178. * Response:
  179. - Header:
  180. + `200 OK`
  181. + `403 Forbidden` When the current user is not a moderator/owner
  182. + `404 Not Found` When the room could not be found for the participant
  183. ### Disallow guests in a room (group room)
  184. * Method: `DELETE`
  185. * Endpoint: `/room/{token}/public`
  186. * Response:
  187. - Header:
  188. + `200 OK`
  189. + `403 Forbidden` When the current user is not a moderator/owner
  190. + `404 Not Found` When the room could not be found for the participant
  191. ### Set room password
  192. * Method: `PUT`
  193. * Endpoint: `/room/{token}/password`
  194. * Data:
  195. field | type | Description
  196. ------|------|------------
  197. `password` | string | Set a new password for the room
  198. * Response:
  199. - Header:
  200. + `200 OK`
  201. + `403 Forbidden` When the current user is not a moderator/owner
  202. + `403 Forbidden` When the room is not a public room
  203. + `404 Not Found` When the room could not be found for the participant
  204. ### Add room to favorites
  205. * Method: `POST`
  206. * Endpoint: `/room/{token}/favorite`
  207. * Response:
  208. - Header:
  209. + `200 OK`
  210. + `404 Not Found` When the room could not be found for the participant or the participant is a guest
  211. ### Remove room from favorites
  212. * Method: `DELETE`
  213. * Endpoint: `/room/{token}/favorite`
  214. * Response:
  215. - Header:
  216. + `200 OK`
  217. + `404 Not Found` When the room could not be found for the participant or the participant is a guest
  218. ### Set notification level
  219. * Method: `POST`
  220. * Endpoint: `/room/{token}/notify`
  221. * Data:
  222. field | type | Description
  223. ------|------|------------
  224. `level` | int | The notification level (one of `Participant::NOTIFY_*` (1-3))
  225. * Response:
  226. - Header:
  227. + `200 OK`
  228. + `400 Bad Request` When the the given level is invalid
  229. + `404 Not Found` When the room could not be found for the participant or the participant is a guest
  230. ## Participant management
  231. ### Get list of participants in a room
  232. * Method: `GET`
  233. * Endpoint: `/room/{token}/participants`
  234. * Response:
  235. - Header:
  236. + `200 OK`
  237. + `404 Not Found` When the room could not be found for the participant
  238. - Data:
  239. Array of participants, each participant has at least:
  240. field | type | Description
  241. ------|------|------------
  242. `userId` | string | Is empty for guests
  243. `displayName` | string | Can be empty for guests
  244. `participantType` | int | Permissions level of the participant
  245. `lastPing` | int | Timestamp of the last ping of the user (should be used for sorting)
  246. `sessionId` | string | `'0'` if not connected, otherwise a 512 character long string
  247. ### Add a participant to a room
  248. * Method: `POST`
  249. * Endpoint: `/room/{token}/participants`
  250. * Data:
  251. field | type | Description
  252. ------|------|------------
  253. `newParticipant` | string | User, group or email to add
  254. `source` | string | Source of the participant(s) as returned by the autocomplete suggestion endpoint (default is `users`)
  255. * Response:
  256. - Header:
  257. + `200 OK`
  258. + `403 Forbidden` When the current user is not a moderator/owner
  259. + `400 Bad Request` When the source type is unknown
  260. + `404 Not Found` When the room could not be found for the participant
  261. + `404 Not Found` When the user or group to add could not be found
  262. - Data:
  263. field | type | Description
  264. ------|------|------------
  265. `type` | int | In case the room type changed, the new value is returned
  266. ### Delete a participant from a room
  267. * Method: `DELETE`
  268. * Endpoint: `/room/{token}/participants`
  269. * Data:
  270. field | type | Description
  271. ------|------|------------
  272. `participant` | string | User to remove
  273. * Response:
  274. - Header:
  275. + `200 OK`
  276. + `400 Bad Request` When the participant is a moderator/owner and there are no other moderators/owners left.
  277. + `403 Forbidden` When the current user is not a moderator/owner
  278. + `403 Forbidden` When the participant to remove is an owner
  279. + `404 Not Found` When the room could not be found for the participant
  280. + `404 Not Found` When the participant to remove could not be found
  281. ### Remove a guest from a room
  282. * Method: `DELETE`
  283. * Endpoint: `/room/{token}/participants/guests`
  284. * Data:
  285. field | type | Description
  286. ------|------|------------
  287. `participant` | string | Session ID of the guest to remove
  288. * Response:
  289. - Header:
  290. + `200 OK`
  291. + `403 Forbidden` When the current user is not a moderator/owner
  292. + `403 Forbidden` When the target participant is not a guest
  293. + `404 Not Found` When the room could not be found for the participant
  294. + `404 Not Found` When the target participant could not be found
  295. ### Remove yourself from a room
  296. * Method: `DELETE`
  297. * Endpoint: `/room/{token}/participants/self`
  298. * Response:
  299. - Header:
  300. + `200 OK`
  301. + `400 Bad Request` When the participant is a moderator/owner and there are no other moderators/owners left.
  302. + `404 Not Found` When the room could not be found for the participant
  303. ### Join a room (available for call and chat)
  304. * Method: `POST`
  305. * Endpoint: `/room/{token}/participants/active`
  306. * Data:
  307. field | type | Description
  308. ------|------|------------
  309. `password` | string | Optional: Password is only required for users which are of type `4` or `5` and only when the room has `hasPassword` set to true.
  310. * Response:
  311. - Header:
  312. + `200 OK`
  313. + `403 Forbidden` When the password is required and didn't match
  314. + `404 Not Found` When the room could not be found for the participant
  315. - Data:
  316. field | type | Description
  317. ------|------|------------
  318. `sessionId` | string | 512 character long string
  319. ### Leave a room (not available for call and chat anymore)
  320. * Method: `DELETE`
  321. * Endpoint: `/room/{token}/participants/active`
  322. * Response:
  323. - Header:
  324. + `200 OK`
  325. + `404 Not Found` When the room could not be found for the participant
  326. ### Promote a user to a moderator
  327. * Method: `POST`
  328. * Endpoint: `/room/{token}/moderators`
  329. * Data:
  330. field | type | Description
  331. ------|------|------------
  332. `participant` | string | User to promote
  333. * Response:
  334. - Header:
  335. + `200 OK`
  336. + `400 Bad Request` When the participant to promote is not a normal user (type `3`)
  337. + `403 Forbidden` When the current user is not a moderator/owner
  338. + `403 Forbidden` When the participant to remove is an owner
  339. + `404 Not Found` When the room could not be found for the participant
  340. + `404 Not Found` When the participant to remove could not be found
  341. ### Demote a moderator to a user
  342. * Method: `DELETE`
  343. * Endpoint: `/room/{token}/moderators`
  344. * Data:
  345. field | type | Description
  346. ------|------|------------
  347. `participant` | string | User to promote
  348. * Response:
  349. - Header:
  350. + `200 OK`
  351. + `400 Bad Request` When the participant to demote is not a moderator (type `2`)
  352. + `403 Forbidden` When the current user is not a moderator/owner
  353. + `404 Not Found` When the room could not be found for the participant
  354. + `404 Not Found` When the participant to demote could not be found
  355. ## Call management
  356. ### Get list of connected participants
  357. * Method: `GET`
  358. * Endpoint: `/call/{token}`
  359. * Response:
  360. - Header:
  361. + `200 OK`
  362. + `404 Not Found` When the room could not be found for the participant
  363. - Data:
  364. Array of participants, each participant has at least:
  365. field | type | Description
  366. ------|------|------------
  367. `userId` | string | Is empty for guests
  368. `lastPing` | int | Timestamp of the last ping of the user (should be used for sorting)
  369. `sessionId` | string | 512 character long string
  370. ### Join a call
  371. * Method: `POST`
  372. * Endpoint: `/call/{token}`
  373. * Response:
  374. - Header:
  375. + `200 OK`
  376. + `404 Not Found` When the room could not be found for the participant
  377. ### Leave a call (but staying in the room for future calls and chat)
  378. * Method: `DELETE`
  379. * Endpoint: `/call/{token}`
  380. * Response:
  381. - Header:
  382. + `200 OK`
  383. + `404 Not Found` When the room could not be found for the participant
  384. ## Chat
  385. ### Receive chat messages of a room
  386. * Method: `GET`
  387. * Endpoint: `/chat/{token}`
  388. * Data:
  389. field | type | Description
  390. ------|------|------------
  391. `lookIntoFuture` | int | `1` Poll and wait for new message or `0` get history of a room
  392. `limit` | int | Number of chat messages to receive (100 by default, 200 at most)
  393. `timeout` | int | `$lookIntoFuture = 1` only, Number of seconds to wait for new messages (30 by default, 60 at most)
  394. `lastKnownMessageId` | int | Serves as an offset for the query. The lastKnownMessageId for the next page is available in the `X-Chat-Last-Given` header.
  395. * Response:
  396. - Status code:
  397. + `200 OK`
  398. + `304 Not Modified` When there were no older/newer messages
  399. + `404 Not Found` When the room could not be found for the participant
  400. - Header:
  401. field | type | Description
  402. ------|------|------------
  403. `X-Chat-Last-Given` | int | Offset (lastKnownMessageId) for the next page.
  404. - Data:
  405. Array of messages, each message has at least:
  406. field | type | Description
  407. ------|------|------------
  408. `id` | int | ID of the comment
  409. `token` | string | Room token
  410. `actorType` | string | `guests` or `users`
  411. `actorId` | string | User id of the message author
  412. `actorDisplayName` | string | Display name of the message author
  413. `timestamp` | int | Timestamp in seconds and UTC time zone
  414. `systemMessage` | string | empty for normal chat message or the type of the system message (untranslated)
  415. `message` | string | Message string with placeholders (see [Rich Object String](https://github.com/nextcloud/server/issues/1706))
  416. `messageParameters` | array | Message parameters for `message` (see [Rich Object String](https://github.com/nextcloud/server/issues/1706))
  417. ### Sending a new chat message
  418. * Method: `POST`
  419. * Endpoint: `/chat/{token}`
  420. * Data:
  421. field | type | Description
  422. ------|------|------------
  423. `message` | string | The message the user wants to say
  424. `actorDisplayName` | string | Guest display name (ignored for logged in users)
  425. * Response:
  426. - Header:
  427. + `201 Created`
  428. + `400 Bad Request` In case of any other error
  429. + `404 Not Found` When the room could not be found for the participant
  430. + `413 Payload Too Large` When the message was longer than the allowed limit of 1000 characters
  431. - Data:
  432. The full message array of the new message, as defined in [Receive chat messages of a room](#receive-chat-messages-of-a-room)
  433. ### Get mention autocomplete suggestions
  434. * Method: `GET`
  435. * Endpoint: `/chat/{token}/mentions`
  436. * Data:
  437. field | type | Description
  438. ------|------|------------
  439. `search` | string | Search term for name suggestions (should at least be 1 character)
  440. `limit` | int | Number of suggestions to receive (20 by default)
  441. * Response:
  442. - Status code:
  443. + `200 OK`
  444. + `404 Not Found` When the room could not be found for the participant
  445. - Data:
  446. Array of suggestions, each suggestion has at least:
  447. field | type | Description
  448. ------|------|------------
  449. `id` | string | The user id which should be sent as `@<id>` in the message
  450. `label` | string | The displayname of the user
  451. `source` | string | The type of the user, currently only `users`
  452. ### System messages
  453. * `conversation_created` - {actor} created the conversation
  454. * `conversation_renamed` - {actor} renamed the conversation from "foo" to "bar"
  455. * `call_started` - {actor} started a call
  456. * `call_joined` - {actor} joined the call
  457. * `call_left` - {actor} left the call
  458. * `call_ended` - Call with {user1}, {user2}, {user3}, {user4} and {user5} (Duration 30:23)
  459. * `guests_allowed` - {actor} allowed guests in the conversation
  460. * `guests_disallowed` - {actor} disallowed guests in the conversation
  461. * `password_set` - {actor} set a password for the conversation
  462. * `password_removed` - {actor} removed the password for the conversation
  463. * `user_added` - {actor} added {user} to the conversation
  464. * `user_removed` - {actor} removed {user} from the conversation
  465. * `moderator_promoted` - {actor} promoted {user} to moderator
  466. * `moderator_demoted` - {actor} demoted {user} from moderator
  467. * `guest_moderator_promoted` - {actor} promoted {user} to moderator
  468. * `guest_moderator_demoted` - {actor} demoted {user} from moderator
  469. ## Guests
  470. ### Set display name
  471. * Method: `POST`
  472. * Endpoint: `/guest/{token}/name`
  473. * Data:
  474. field | type | Description
  475. ------|------|------------
  476. `displayName` | string | The new display name
  477. * Response:
  478. - Header:
  479. + `200 OK`
  480. + `404 Not Found` When the room is not found or the session does not exist in the room
  481. + `403 Forbidden` When the user is logged in
  482. ## Signaling
  483. ### Get signaling settings
  484. * Method: `GET`
  485. * Endpoint: `/signaling/settings`
  486. * Data:
  487. field | type | Description
  488. ------|------|------------
  489. `stunservers` | array | STUN servers
  490. `turnservers` | array | TURN servers
  491. `server` | string | URL of the external signaling server
  492. `ticket` | string | Ticket for the external signaling server
  493. - STUN server
  494. field | type | Description
  495. ------|------|------------
  496. `url` | string | STUN server URL
  497. - TURN server
  498. field | type | Description
  499. ------|------|------------
  500. `url` | array | One element array with TURN server URL
  501. `urls` | array | One element array with TURN server URL
  502. `username` | string | User name for the TURN server
  503. `credential` | string | User password for the TURN server
  504. * Response:
  505. - Header:
  506. + `200 OK`
  507. + `404 Not Found`
  508. ### External signaling API
  509. See External Signaling API [Draft](https://github.com/nextcloud/spreed/wiki/Signaling-API) in the wiki…