TypeScript
import { PeriskopeApi } from '@periskope/periskope-client';
const client = new PeriskopeApi({
authToken: 'YOUR_API_KEY',
});
async function main() {
const response = await client.chats.updateChatAiSettings({
chat_id: '120363000000000000@g.us',
is_agent_allowed: true,
});
console.log(response);
}
main();curl -X PATCH 'https://api.periskope.app/v1/chats/120363000000000000@g.us/ai' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"is_agent_allowed": true
}'{
"chat_id": "120363000000000000@g.us",
"is_agent_allowed": true,
"is_flagging_allowed": true
}{
"code": "UNAUTHORIZED_ERROR",
"message": "Invalid bearer auth token",
"status": 401
}{
"code": "NOT_FOUND_ERROR",
"message": "Chat not found",
"status": 404
}{
"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
}Chat APIs
Update Chat AI Settings
Toggles the AI permissions of this chat: whether the AI agent may reply to messages and whether AI flagging may flag them. At least one flag is required; omitted flags are unchanged.
TypeScript
import { PeriskopeApi } from '@periskope/periskope-client';
const client = new PeriskopeApi({
authToken: 'YOUR_API_KEY',
});
async function main() {
const response = await client.chats.updateChatAiSettings({
chat_id: '120363000000000000@g.us',
is_agent_allowed: true,
});
console.log(response);
}
main();curl -X PATCH 'https://api.periskope.app/v1/chats/120363000000000000@g.us/ai' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"is_agent_allowed": true
}'{
"chat_id": "120363000000000000@g.us",
"is_agent_allowed": true,
"is_flagging_allowed": true
}{
"code": "UNAUTHORIZED_ERROR",
"message": "Invalid bearer auth token",
"status": 401
}{
"code": "NOT_FOUND_ERROR",
"message": "Chat not found",
"status": 404
}{
"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.
Path Parameters
Unique id of the chat. For 1-1 chats, country code + number optionally suffixed with @c.us (e.g. 922222222222@c.us — the suffix is added automatically when omitted); for groups, the id ending with @g.us.
Minimum string length:
1Example:
"120363000000000000@g.us"
Body
application/json
Was this page helpful?