Skip to main content

Unlisted page
This page is unlisted. Search engines will not index it, and only users having a direct link can access it.

Set metadata

Set a single custom key-value pair in a specific open channel. You must provide a user ID as the owner of the entry.

Metadata is destroyed when the open channel is destroyed.

Enable the service

Before using this feature, enable open channel metadata for your App Key. See Open channel metadata overview.

If the service is not enabled, the API returns error 1009. If you exceed the rate limit while the service is disabled, the API returns HTTP 429 (error code 1008).

Request

POST: https://[Base URL](/platform-chat-api/base-url)/chatroom/entry/set.json

Rate limit: 100 metadata operations per second, shared with the batch set endpoint (/chatroom/entry/batch/set.json). If you only use this single-set endpoint, you can call it 100 times per second.

Signature: Required. See API request signature.

Request body

Content type: application/x-www-form-urlencoded

ParameterTypeRequiredDescription
chatroomIdStringYesThe open channel ID.
userIdStringYesThe user ID performing the operation. The user does not need to be in the open channel when using the server API.
keyStringYesMetadata key. Supports letters, numbers, and +, =, -, _. Case-sensitive. Max 128 characters. Each open channel supports up to 100 key-value pairs.
valueStringYesMetadata value. Max 4,096 characters.
autoDeleteIntNoWhether to delete this key when the owner user leaves the open channel. 1: delete. 0: keep (default).
objectNameStringNoMessage type for the metadata change notification. Typically the built-in RC:chrmKVNotiMsg, or a custom message type. When provided, a notification message is sent when the metadata changes.
contentStringNoContent of the notification message, as a JSON string. When objectName is RC:chrmKVNotiMsg, the content must include type, key, and value fields.

Request example

HTTP
POST /chatroom/entry/set.json HTTP/1.1
Host: api.sg-light-api.com
App-Key: uwd1c0sxdlx2
Nonce: 14314
Timestamp: 1408710653491
Signature: 45beb7cc7307889a8e711219a47b7cf6a5b000e8
Content-Type: application/x-www-form-urlencoded

chatroomId=kvchatroom2&userId=Lnq9MJsPY&key=huihui&value=555&autoDelete=0&objectName=RC%3AchrmKVNotiMsg&content=%7B%22key%22%3A%22keyli%22%2C%22value%22%3A%225%22%2C%22type%22%3A%221%22%7D&extra=111111

Response

FieldTypeDescription
codeNumberReturn code. 200 indicates success.

Response example

HTTP
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8

{"code":200}