Sending notifications
To send notifications via the API, send an HTTP POST to this endpoint:https://app.prompty.io/api/[SITE_ID]/send?api_token=[API_TOKEN]
Your POST must include a payload in JSON format:
{
"recipients": {
"all": true
},
"title": "Your title",
"message": "Your message",
"icon": "https://example.com/img.png",
"link": "https://www.prompty.io/"
}
Important notes
- Replace [SITE_ID] in the endpoint URL with your actual Site ID (found on your dashboard).
- Replace [API_TOKEN] in the endpoint URL with your actual API Token.
- Be sure to send a
Content-Type: application/jsonheader with your request. - Title is limited to a maximum of 200 characters.
- Message is limited to a maximum of 2000 characters.
- Icon & Link are optional.
CURL example
curl -d '{"recipients":{"all":true}, "title":"Your title", "message":"Your message", "icon":"https://example.com/img.png", "link":"https://www.prompty.io/"}' -H "Content-Type: application/json" -X POST "https://app.prompty.io/api/[SITE_ID]/send?api_token=[API_TOKEN]"
PHP example
<?php
$site_id = '[SITE_ID]';
$api_token = '[API_TOKEN]';
$payload = array(
'recipients' => array(
'all' => true
),
'title' => 'Your title',
'message' => 'Your message',
'icon' => 'https://example.com/img.png',
'link' => 'https://www.prompty.io/'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://app.prompty.io/api/' . $site_id . '/send?api_token=' . $api_token);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload))
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
?>
Changing recipients
To limit a notification to your test list, replace the value of the recipients array like this:
"recipients": {
"test": true
},
To send to one or more subscribers, use a comma-delimited list of Subscriber IDs:
"recipients": {
"subscriber": "1,2"
},
You may also send notifications based on an External ID value:
"recipients": {
"external_id": "313,612"
},
Error response
If there is an error processing your request, you’ll receive a response like this:
{
"status": "error",
"code": "NOT_AUTHORIZED",
"message": "..."
}
Success response
The Send ID (as seen on the Results page) will be returned upon a successful request.
{
"status": "success",
"code": "OK",
"message": "...",
"data": {
"id": 1
}
}