import { PeriskopeApi } from '@periskope/periskope-client';
const client = new PeriskopeApi({
authToken: 'YOUR_API_KEY',
phone: '919876543210', // the phone to act with (x-phone)
});
async function main() {
const response = await client.messages.purgeMessageQueues({
queue_ids: [
'00000000-0000-0000-0000-000000000000',
],
});
console.log(response);
}
main();curl -X POST 'https://api.periskope.app/v1/message/queues/purge' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'x-phone: 919876543210' \
-H 'Content-Type: application/json' \
-d '{
"queue_ids": [
"00000000-0000-0000-0000-000000000000"
]
}'{
"purged": true,
"mode": "queue_ids",
"queue_ids": [
"00000000-0000-0000-0000-000000000000"
],
"broadcast_id": null
}{
"code": "ERROR",
"message": "The phone is off or its server is unreachable",
"status": 400
}{
"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
}Purge Message Queues
Removes unsubmitted jobs from the send queue of the phone, by queue_ids or broadcast_id. Warning: an empty body purges the entire queue.
import { PeriskopeApi } from '@periskope/periskope-client';
const client = new PeriskopeApi({
authToken: 'YOUR_API_KEY',
phone: '919876543210', // the phone to act with (x-phone)
});
async function main() {
const response = await client.messages.purgeMessageQueues({
queue_ids: [
'00000000-0000-0000-0000-000000000000',
],
});
console.log(response);
}
main();curl -X POST 'https://api.periskope.app/v1/message/queues/purge' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'x-phone: 919876543210' \
-H 'Content-Type: application/json' \
-d '{
"queue_ids": [
"00000000-0000-0000-0000-000000000000"
]
}'{
"purged": true,
"mode": "queue_ids",
"queue_ids": [
"00000000-0000-0000-0000-000000000000"
],
"broadcast_id": null
}{
"code": "ERROR",
"message": "The phone is off or its server is unreachable",
"status": 400
}{
"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.
Headers
Phone to act with: country code + number without symbols or spaces (e.g. 911111111111), or a phone_id (phone-xxxxxxxxxxxx). The phone must be connected to the org and accessible by the API token.
1"919876543210"
Body
Response
Confirmation of the purge
Always true when the purge request was accepted
true What was purged: 'queue_ids' when specific jobs were targeted, 'broadcast' when a broadcast's jobs were targeted, 'all' when neither filter was given and the entire queue was purged
all, queue_ids, broadcast "queue_ids"
Echo of the queue_ids filter, present only when it was sent
["00000000-0000-0000-0000-000000000000"]
Echo of the broadcast_id filter, present only when it was sent
Was this page helpful?