Batch set metadata
Set multiple custom key-value pairs in a specific open channel in one request (up to 20). If a key already exists, this endpoint force-overwrites the existing owner user ID and value.
Metadata is destroyed when the open channel is destroyed.
Request
POST: https://[Base URL](/platform-chat-api/base-url)/v4/open-channel/metadata/batch/set
Rate limit: 100 metadata operations per second. For example, setting 1 pair allows 100 calls/sec; setting 20 pairs allows 5 calls/sec.
Signature: Required. See API request signature.
Request body
Content type: application/json
| Parameter | Type | Required | Description |
|---|---|---|---|
channelId | String | Yes | The open channel ID. |
shouldAutoDelete | Number | No | Whether to delete these keys when the owner user (metadataOwnerId) leaves the open channel. 1: delete. 0: keep (default). |
metadataOwnerId | String | Yes | User ID that owns the metadata entries. |
metadata | JSON | Yes | Key-value pairs to set, as a JSON object. Maximum 20 per request. Key: supports letters, numbers, and +, =, -, _. Case-sensitive. Max 128 characters. Value: max 4,096 characters. |
Request example
HTTP
POST /v4/open-channel/metadata/batch/set HTTP/1.1
Host: api.sg-light-api.com
App-Key: uwd1c0sxdlx2
Nonce: 14314
Timestamp: 1408710653491
Signature: 45beb7cc7307889a8e711219a47b7cf6a5b000e8
Content-Type: application/json
{
"channelId": "gid1",
"shouldAutoDelete": 0,
"metadataOwnerId": "test",
"metadata": {
"key1": "value1",
"key2": "value2"
}
}
Response
| Field | Type | Description |
|---|---|---|
code | Number | Return code. 0 indicates success. |
Response example
HTTP
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
{"code":0}