import { PeriskopeApi } from '@periskope/periskope-client';

const client = new PeriskopeApi({
  authToken: 'YOUR_API_KEY',
  phone: 'YOUR_PHONE_NUMBER', // e.g., '919876543210'
});

client.on('org.phone.disconnected', (data) => {
  console.log(data);
});
{
    "org_id": "2997dd64-89bf-48d3-9a22-b314fca017e5",
    "org_phone": "918527184400@c.us",
    "created_at": "2024-12-15T11:47:26.668505+00:00",
    "updated_at": "2025-01-20T07:51:48.209+00:00",
    "wa_state": "CONNECTED",
    "phone_id": "phone-bqzvyibhmwkaergr",
    "qr_code": null,
    "phone_image": "https://storage.googleapis.com/periskope-images/2997dd64-89bf-48d3-9a22-b314fca017e5%2F918527184400%40c.us.jpg?timestamp=1737141384215",
    "phone_name": "Support",
    "first_connected_at": "2024-12-15T11:47:49.649+00:00",
    "is_ready": true,
    "label_ids": {
        "label-bflirzqiodgianfh": true,
        "label-rbdshklasmlbfczf": true
    },
    "labels": [
        "test1",
        "test2"
    ]
}
{
    "org_id": "2997dd64-89bf-48d3-9a22-b314fca017e5",
    "org_phone": "918527184400@c.us",
    "created_at": "2024-12-15T11:47:26.668505+00:00",
    "updated_at": "2025-01-20T07:51:48.209+00:00",
    "wa_state": "CONNECTED",
    "phone_id": "phone-bqzvyibhmwkaergr",
    "qr_code": null,
    "phone_image": "https://storage.googleapis.com/periskope-images/2997dd64-89bf-48d3-9a22-b314fca017e5%2F918527184400%40c.us.jpg?timestamp=1737141384215",
    "phone_name": "Support",
    "first_connected_at": "2024-12-15T11:47:49.649+00:00",
    "is_ready": true,
    "label_ids": {
        "label-bflirzqiodgianfh": true,
        "label-rbdshklasmlbfczf": true
    },
    "labels": [
        "test1",
        "test2"
    ]
}

Refer Phone object to find more details about phone object.

import { PeriskopeApi } from '@periskope/periskope-client';

const client = new PeriskopeApi({
  authToken: 'YOUR_API_KEY',
  phone: 'YOUR_PHONE_NUMBER', // e.g., '919876543210'
});

client.on('org.phone.disconnected', (data) => {
  console.log(data);
});

Event structure 📦

You’ll be receiving the data in the following format:

{
  "event": "<event-type>",
  "data": "<event-data>", // complete data object as mentioned in Objects section
  "org_id": "<your-organisation-id>",
  "previous_attributes": "<previous-attributes>", // attributes changes in new object. In case of an update event.
  "timestamp": "<timestamp>" // timestamp of the event creation
}