import { PeriskopeApi } from '@periskope/periskope-client';
const client = new PeriskopeApi({
authToken: 'YOUR_API_KEY',
phone: 'YOUR_PHONE_NUMBER', // e.g., '919876543210'
});
async function getChatNotifications() {
const response = await client.chat.getChatNotifications({
chat_id: '< CHAT_ID >',
});
console.log(response);
}
getChatNotifications();{
"count": 5,
"from": 1,
"messages": [
{
"author": "[email protected]",
"body": null,
"chat_id": "[email protected]",
"id": {
"fromMe": true,
"id": "fa3c48a78cc64e139e5737f7057235ea",
"remote": "[email protected]",
"serialized": "[email protected][email protected]_remove"
},
"notification_id": "[email protected][email protected]_remove",
"org_id": "2997dd64-89bf-48d3-9a22-b314fca017e5",
"org_phone": "[email protected]",
"recipientids": [
"[email protected]"
],
"timestamp": "2025-01-11T11:52:27.231+00:00",
"type": "remove",
"unique_id": "fa3c48a78cc64e139e5737f7057235ea"
},
{
"author": "[email protected]",
"body": null,
"chat_id": "[email protected]",
"id": {
"fromMe": true,
"id": "fd73a0384afe4bc89991c3303cacab4b",
"remote": "[email protected]",
"serialized": "[email protected][email protected]_remove"
},
"notification_id": "[email protected][email protected]_remove",
"org_id": "2997dd64-89bf-48d3-9a22-b314fca017e5",
"org_phone": "[email protected]",
"recipientids": [
"[email protected]"
],
"timestamp": "2025-01-11T11:52:27.127+00:00",
"type": "remove",
"unique_id": "fd73a0384afe4bc89991c3303cacab4b"
},
{
"author": "[email protected]",
"body": null,
"chat_id": "[email protected]",
"id": {
"fromMe": true,
"id": "05f652baf6e54522b855d70ad43b813c",
"remote": "[email protected]",
"serialized": "[email protected][email protected]_add"
},
"notification_id": "[email protected][email protected]_add",
"org_id": "2997dd64-89bf-48d3-9a22-b314fca017e5",
"org_phone": "[email protected]",
"recipientids": [
"[email protected]"
],
"timestamp": "2025-01-11T11:52:16.859+00:00",
"type": "add",
"unique_id": "05f652baf6e54522b855d70ad43b813c"
},
{
"author": "[email protected]",
"body": null,
"chat_id": "[email protected]",
"id": {
"fromMe": true,
"id": "686bd17a4c3b4d7e9e84e5fe884de8bc",
"remote": "[email protected]",
"serialized": "[email protected][email protected]_memberaddmode_false"
},
"notification_id": "[email protected][email protected]_memberaddmode_false",
"org_id": "2997dd64-89bf-48d3-9a22-b314fca017e5",
"org_phone": "[email protected]",
"recipientids": null,
"timestamp": "2025-01-11T11:51:59.974+00:00",
"type": "memberaddmode_false",
"unique_id": "686bd17a4c3b4d7e9e84e5fe884de8bc"
},
{
"author": "[email protected]",
"body": null,
"chat_id": "[email protected]",
"id": {
"fromMe": true,
"id": "8c04cef4f58148ae91fc2654260bae55",
"remote": "[email protected]",
"serialized": "[email protected][email protected]_memberaddmode_true"
},
"notification_id": "[email protected][email protected]_memberaddmode_true",
"org_id": "2997dd64-89bf-48d3-9a22-b314fca017e5",
"org_phone": "[email protected]",
"recipientids": null,
"timestamp": "2025-01-11T11:51:51.177+00:00",
"type": "memberaddmode_true",
"unique_id": "8c04cef4f58148ae91fc2654260bae55"
}
],
"to": 5
}This endpoint retrieves a paginated list of all notifications for the specific chat_id (in descending order of timestamp)
import { PeriskopeApi } from '@periskope/periskope-client';
const client = new PeriskopeApi({
authToken: 'YOUR_API_KEY',
phone: 'YOUR_PHONE_NUMBER', // e.g., '919876543210'
});
async function getChatNotifications() {
const response = await client.chat.getChatNotifications({
chat_id: '< CHAT_ID >',
});
console.log(response);
}
getChatNotifications();{
"count": 5,
"from": 1,
"messages": [
{
"author": "[email protected]",
"body": null,
"chat_id": "[email protected]",
"id": {
"fromMe": true,
"id": "fa3c48a78cc64e139e5737f7057235ea",
"remote": "[email protected]",
"serialized": "[email protected][email protected]_remove"
},
"notification_id": "[email protected][email protected]_remove",
"org_id": "2997dd64-89bf-48d3-9a22-b314fca017e5",
"org_phone": "[email protected]",
"recipientids": [
"[email protected]"
],
"timestamp": "2025-01-11T11:52:27.231+00:00",
"type": "remove",
"unique_id": "fa3c48a78cc64e139e5737f7057235ea"
},
{
"author": "[email protected]",
"body": null,
"chat_id": "[email protected]",
"id": {
"fromMe": true,
"id": "fd73a0384afe4bc89991c3303cacab4b",
"remote": "[email protected]",
"serialized": "[email protected][email protected]_remove"
},
"notification_id": "[email protected][email protected]_remove",
"org_id": "2997dd64-89bf-48d3-9a22-b314fca017e5",
"org_phone": "[email protected]",
"recipientids": [
"[email protected]"
],
"timestamp": "2025-01-11T11:52:27.127+00:00",
"type": "remove",
"unique_id": "fd73a0384afe4bc89991c3303cacab4b"
},
{
"author": "[email protected]",
"body": null,
"chat_id": "[email protected]",
"id": {
"fromMe": true,
"id": "05f652baf6e54522b855d70ad43b813c",
"remote": "[email protected]",
"serialized": "[email protected][email protected]_add"
},
"notification_id": "[email protected][email protected]_add",
"org_id": "2997dd64-89bf-48d3-9a22-b314fca017e5",
"org_phone": "[email protected]",
"recipientids": [
"[email protected]"
],
"timestamp": "2025-01-11T11:52:16.859+00:00",
"type": "add",
"unique_id": "05f652baf6e54522b855d70ad43b813c"
},
{
"author": "[email protected]",
"body": null,
"chat_id": "[email protected]",
"id": {
"fromMe": true,
"id": "686bd17a4c3b4d7e9e84e5fe884de8bc",
"remote": "[email protected]",
"serialized": "[email protected][email protected]_memberaddmode_false"
},
"notification_id": "[email protected][email protected]_memberaddmode_false",
"org_id": "2997dd64-89bf-48d3-9a22-b314fca017e5",
"org_phone": "[email protected]",
"recipientids": null,
"timestamp": "2025-01-11T11:51:59.974+00:00",
"type": "memberaddmode_false",
"unique_id": "686bd17a4c3b4d7e9e84e5fe884de8bc"
},
{
"author": "[email protected]",
"body": null,
"chat_id": "[email protected]",
"id": {
"fromMe": true,
"id": "8c04cef4f58148ae91fc2654260bae55",
"remote": "[email protected]",
"serialized": "[email protected][email protected]_memberaddmode_true"
},
"notification_id": "[email protected][email protected]_memberaddmode_true",
"org_id": "2997dd64-89bf-48d3-9a22-b314fca017e5",
"org_phone": "[email protected]",
"recipientids": null,
"timestamp": "2025-01-11T11:51:51.177+00:00",
"type": "memberaddmode_true",
"unique_id": "8c04cef4f58148ae91fc2654260bae55"
}
],
"to": 5
}Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Please provide the number of the phone you want to call with this API in the header. The number must be in country code + number format without any characters or spaces, e.g. 919876543210; Alternatively, provide the phone_id (phone-xxxxxxxxxxxx) in the header
"{{orgPhone}}"
country_code + number (e.g., 918527184400). Optionally, you can add @c.us@g.us"0"
"10"
200 OK
The starting index of the returned notifications.
1
The ending index of the returned messages.
10
The total count of messages.
10
An array of notification objects. Refer to the notification object here
Was this page helpful?