Skip to content

Latest commit

 

History

History
169 lines (142 loc) · 6.71 KB

File metadata and controls

169 lines (142 loc) · 6.71 KB

Save Room Settings

This endpoint allows you to save the settings of a room.

URL Requires Auth HTTP Method
/api/v1/rooms.saveRoomSettings yes POST

Payload

ArgumentExampleRequiredDescription
ridJZ8Y2dLfYhsg323RfRequiredThe room id.
roomNameTest-Save-RoomOptionalThe name of the room.
roomDescriptionThis is a test room.OptionalThe description of the room.
roomAvatarhttps://example.com/imageOptionalThe URL of the room avatar image.
featuredtrueOptionalWhether the room is featured or not.
roomTopicDiscussion TopicOptionalThe topic of the room.
roomAnnouncementImportant AnnouncementOptionalThe announcement of the room.
roomCustomFields{ "field1": "value1" }OptionalThe custom fields of the room.
roomType"c"OptionalThe type of the room.
readOnlytrueOptionalWhether the room is read-only or not.
reactWhenReadOnlytrueOptionalWhether users can react when the room is read-only.
systemMessages["changed-room-name"]OptionalThe system messages that the room supports.
defaulttrueOptionalWhether the room is the default room or not.
joinCode"123456"OptionalThe join code of the room.
streamingOptions{ "type": "live" }OptionalThe streaming options of the room.
retentionEnabledtrueOptionalWhether retention is enabled for the room or not.
retentionMaxAge30OptionalThe maximum age (in days) of messages to be retained in the room.
retentionExcludePinnedtrueOptionalWhether to exclude pinned messages from retention or not.
retentionFilesOnlytrueOptionalWhether to retain only files in the room or not.
retentionIgnoreThreadstrueOptionalWhether to ignore threads when retaining messages or not.
retentionOverrideGlobaltrueOptionalWhether to override the global retention settings for the room or not.
encryptedtrueOptionalWhether the room is encrypted or not.
favorite{ "favorite": true, "defaultValue": false }OptionalThe favorite settings of the room. Whether the room is marked as favorite and whether it is set as the default room.

Example Payload

{
    "rid": "JZ8Y2dLfYhsg323Rf",
    "roomName": "Test-Save-Room",
    "roomDescription": "This is a test for save-room settings."
}

Example Call

{% tabs %} {% tab title="Curl" %}

curl -L -X POST 'http://localhost:3000/api/v1/rooms.saveRoomSettings' \
-H 'X-User-Id: d26x6zSkaPSe5gCyy' \
-H 'X-Auth-Token: Zu-Z6eKzIIz7MCCRGeHi29bYkXZCJ4SxFC0JAasqm92' \
-H 'Content-Type: application/json' \
--data-raw '{
    "rid": "JZ8Y2dLfYhsg323Rf",
    "roomName": "Test-Save-Room",
    "roomDescription": "This is a test room."
}'

{% endtab %}

{% tab title="Node.js" %}

var request = require('request');
var options = {
  'method': 'POST',
  'url': 'http://localhost:3000/api/v1/rooms.saveRoomSettings',
  'headers': {
    'X-User-Id': 'd26x6zSkaPSe5gCyy',
    'X-Auth-Token': 'Zu-Z6eKzIIz7MCCRGeHi29bYkXZCJ4SxFC0JAasqm92',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({"rid":"JZ8Y2dLfYhsg323Rf"})

};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

{% endtab %}

{% tab title="Python" %}

import requests

url = "http://localhost:3000/api/v1/rooms.saveRoomSettings"

payload="{\n    \"rid\": \"JZ8Y2dLfYhsg323Rf\"\n}"
headers = {
  'X-User-Id': 'd26x6zSkaPSe5gCyy',
  'X-Auth-Token': 'Zu-Z6eKzIIz7MCCRGeHi29bYkXZCJ4SxFC0JAasqm92',
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

{% endtab %}

{% tab title="PHP" %}

<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('http://localhost:3000/api/v1/rooms.saveRoomSettings');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setHeader(array(
  'X-User-Id' => 'd26x6zSkaPSe5gCyy',
  'X-Auth-Token' => 'Zu-Z6eKzIIz7MCCRGeHi29bYkXZCJ4SxFC0JAasqm92',
  'Content-Type' => 'application/json'
));
$request->setBody('{\n    "rid": "JZ8Y2dLfYhsg323Rf"\n}');
try {
  $response = $request->send();
  if ($response->getStatus() == 200) {
    echo $response->getBody();
  }
  else {
    echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
    $response->getReasonPhrase();
  }
}
catch(HTTP_Request2_Exception $e) {
  echo 'Error: ' . $e->getMessage();
}

{% endtab %}

{% tab title="Java" %}

Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.post("http://localhost:3000/api/v1/rooms.saveRoomSettings")
  .header("X-User-Id", "d26x6zSkaPSe5gCyy")
  .header("X-Auth-Token", "Zu-Z6eKzIIz7MCCRGeHi29bYkXZCJ4SxFC0JAasqm92")
  .header("Content-Type", "application/json")
  .body("{\n    \"rid\": \"JZ8Y2dLfYhsg323Rf\"\n}")
  .asString();

{% endtab %} {% endtabs %}

Example Result

Success

{
    "rid": "JZ8Y2dLfYhsg323Rf",
    "success": true
}

Error

Any of the following errors can occur on the endpoint.

  • Authorization: Requires an authentication token for the request to be made.
  • Invalid Room: Occurs when the given rid is invalid.

{% tabs %} {% tab title=" Authorization" %}

{
    "success": false,
    "error": "unauthorized"
}

{% endtab %}

{% tab title="Invalid Room ID" %}

{
    "success": false,
    "error": "The required \"roomId\" or \"roomName\" param provided does not match any group [error-room-not-found]",
    "errorType": "error-room-not-found"
}
}

{% endtab %} {% endtabs %}

Change Log

Version Description
3.13.0 Added