POST
/webpush-campaign/:id/send/Send webpush campaign
You can send a previously created webpush campaign. The campaign must already have a name, messages, and a target segment assigned during creation. No request body is needed — the endpoint triggers the send using the campaign's existing configuration.
| Attributes | Type | Required | Description |
|---|---|---|---|
| id | integer | yes | A unique identifier for the campaign which is given by User.com automatically. Passed in the URL path. |
Request
- CURL
- JavaScript
- PHP
- Python
curl -X POST \
"https://<your_app_subdomain>.user.com/api/public/webpush-campaign/3/send/" \
-H "Authorization: Token <your_64_char_api_key>" \
-H "Accept: */*; version=2" \
-H "Content-Type: application/json" \
-d '{}'
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function() {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://<your_app_subdomain>.user.com/api/public/webpush-campaign/3/send/");
xhr.setRequestHeader("Accept", "*/*; version=2");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Token <your_64_char_api_key>");
xhr.send(JSON.stringify({}));
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://<your_app_subdomain>.user.com/api/public/webpush-campaign/3/send/',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => '{}',
CURLOPT_HTTPHEADER => array(
'Accept: */*; version=2',
'Content-Type: application/json',
'Authorization: Token <your_64_char_api_key>'
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
import requests
import json
url = "https://<your_app_subdomain>.user.com/api/public/webpush-campaign/3/send/"
headers = {
'Accept': '*/*; version=2',
'Content-Type': 'application/json',
'Authorization': 'Token <your_64_char_api_key>'
}
response = requests.post(url, headers=headers, data=json.dumps({}))
print(response.text)
Response (200 OK)
["Campaign sent successfully"]
Error Response (400 — campaign already sent)
["Campaign already sent"]