import { PeriskopeApi } from '@periskope/periskope-client';
const client = new PeriskopeApi({
authToken: 'YOUR_API_KEY',
});
async function main() {
const response = await client.chats.updateChatLabels({
labels: 'priority,follow-up',
chat_ids: [
'120363000000000000@g.us',
'922222222222@c.us',
],
});
console.log(response);
}
main();curl -X PATCH 'https://api.periskope.app/v1/chats/labels' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"labels": "priority,follow-up",
"chat_ids": [
"120363000000000000@g.us",
"922222222222@c.us"
]
}'{
"code": "UNAUTHORIZED_ERROR",
"message": "Invalid bearer auth token",
"status": 401
}{
"code": "VALIDATION_ERROR",
"message": "Request validation failed",
"status": 422,
"fields": {
"body.chat_id": {
"message": "chat_id is required"
}
}
}{
"code": "RATE_LIMIT_ERROR",
"message": "You can only make 100 requests per second",
"status": 429
}{
"code": "UNKNOWN_ERROR",
"message": "Internal server error",
"status": 500
}Update Chat Labels
Applies labels to one or more chats; unknown label names are created automatically. Replaces the current labels unless replace is false.
import { PeriskopeApi } from '@periskope/periskope-client';
const client = new PeriskopeApi({
authToken: 'YOUR_API_KEY',
});
async function main() {
const response = await client.chats.updateChatLabels({
labels: 'priority,follow-up',
chat_ids: [
'120363000000000000@g.us',
'922222222222@c.us',
],
});
console.log(response);
}
main();curl -X PATCH 'https://api.periskope.app/v1/chats/labels' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"labels": "priority,follow-up",
"chat_ids": [
"120363000000000000@g.us",
"922222222222@c.us"
]
}'{
"code": "UNAUTHORIZED_ERROR",
"message": "Invalid bearer auth token",
"status": 401
}{
"code": "VALIDATION_ERROR",
"message": "Request validation failed",
"status": 422,
"fields": {
"body.chat_id": {
"message": "chat_id is required"
}
}
}{
"code": "RATE_LIMIT_ERROR",
"message": "You can only make 100 requests per second",
"status": 429
}{
"code": "UNKNOWN_ERROR",
"message": "Internal server error",
"status": 500
}Authorizations
Your Periskope API token, sent as Authorization: Bearer <token>. Generate one from the Periskope dashboard under Settings → API & Webhooks. API access requires an active Pro or Enterprise plan.
Body
Comma-separated label names to apply. Matched case-insensitively against existing chat labels; labels that do not exist are created automatically.
1"priority,follow-up"
Ids of the chats to update. 1-1 chat ids may omit the @c.us suffix — it is added automatically.
1[
"120363000000000000@g.us",
"922222222222@c.us"
]
When true (the default), the given labels replace all current labels of each chat. Pass false to append to the existing labels instead.
true
Response
Labels updated — no content
Was this page helpful?