import { PeriskopeApi } from '@periskope/periskope-client';
const client = new PeriskopeApi({
authToken: 'YOUR_API_KEY',
phone: 'YOUR_PHONE_NUMBER', // e.g., '919876543210'
});
async function broadcastMessage() {
const response = await client.message.broadcast({
chat_ids: ['919537851844'],
message: 'Hi from Periskope'
});
console.log(response);
}
broadcastMessage();curl -X POST \
https://api.periskope.app/v1/message/broadcast \
-H 'Authorization: Bearer <token>' \
-H 'Content-Type: application/json' \
-H 'x-phone: YOUR_PHONE_NUMBER' \
-d '{
"chat_ids": ["919537851844@c.us"],
"message": "Hi from Periskope"
}'{
"broadcast_id": "b25192d5-2370-4a69-b844-aae5e2bfae92",
"hint": "Track broadcast status: POST /messages/queues with { \"broadcast_id\": \"<id>\" }"
}Broadcast Message
This endpoint is used to send bulk messages to many chats
import { PeriskopeApi } from '@periskope/periskope-client';
const client = new PeriskopeApi({
authToken: 'YOUR_API_KEY',
phone: 'YOUR_PHONE_NUMBER', // e.g., '919876543210'
});
async function broadcastMessage() {
const response = await client.message.broadcast({
chat_ids: ['919537851844'],
message: 'Hi from Periskope'
});
console.log(response);
}
broadcastMessage();curl -X POST \
https://api.periskope.app/v1/message/broadcast \
-H 'Authorization: Bearer <token>' \
-H 'Content-Type: application/json' \
-H 'x-phone: YOUR_PHONE_NUMBER' \
-d '{
"chat_ids": ["919537851844@c.us"],
"message": "Hi from Periskope"
}'{
"broadcast_id": "b25192d5-2370-4a69-b844-aae5e2bfae92",
"hint": "Track broadcast status: POST /messages/queues with { \"broadcast_id\": \"<id>\" }"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Headers
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
"918527184400"
Body
- Array of all the recipients
- For groups, enter the chat_id of the group. This will be a string that ends with @g.us
- For 1-1 chats, enter the country_code + number of the recipient e.g. 919537851844@c.us (The @c.us is optional)
"919537851844@c.us"
- The text body or caption. You can use basic markdown formatting supported by WhatsApp e.g. * for bold, and _ for italic, etc.
"Hello World"
- UTC date and time when the message should be sent, in ISO 8601 format (YYYY-MM-DDTHH:mm:ss.sssZ). Example: 2025-02-06T11:21:00Z
"2025-02-06T11:21:00Z"
- Time interval between each broadcasted message in seconds. Defaults to
1 second
10
- Required to send a media object. You can send a public URL of the media content, or the base64 data of the media
- Media can be a document, image, video or audio
url- public URL that hosts the content to be sentfiledata- Raw bytes of the file, represented in base64type- The type of the media. Can be image, video, document or audiofilename- The filename of the media. Only applicable for document messages
pollName- The question or title of the pollpollOptions- Raw bytes of the file, represented in base64options- Additional options to be sent with the pollallowMultipleAnswers- Boolean. When set to true, respondents can select multiple optionspollId- Optional unique identifier of the poll. Useful when sending it across multiple chats
- To reply to a message, add the message_id in this field
- Array of variable objects for dynamic message personalization
- Each variable can replace placeholders in the message body written in the format
{{var}} - Note: This parameter is required if
{{var}}placeholders are present in the message
Show child attributes
Show child attributes
Response
200 OK
The response object contains the broadcast_id
You can check the status and logs of the broadcast jobs from the /queue/jobs endpoint
Alternatively, to get all individual message queue jobs for this broadcast, call POST /message/queues with { "broadcast_id": "<id>" } in the request body
The broadcast_id can also be mapped in the message object against the broadcast_id (same key)
Was this page helpful?