Cancel Campaign
Cancel a campaign that is scheduled, queued, or actively sending.
Endpoint
POST /push/campaigns/:id/cancel
Returns: 200 OK
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | Campaign ID |
Headers
| Header | Value | Required |
|---|---|---|
Authorization | Bearer <your-api-key> | Yes |
Idempotency-Key | Any unique string, max 256 chars | No — makes a retry safe; see Idempotency |
Which campaigns can be cancelled
| Status | Cancellable |
|---|---|
Scheduled | Yes |
Queued | Yes |
Sending | Yes — remaining batches stop |
Draft | No — it was never sent; delete it instead |
Sent, Failed, Cancelled | No — already terminal |
Cancelling mid-send does not recall what already went
Cancelling a Sending campaign stops the batches that have not started yet. Notifications already handed to FCM or the browser's push service cannot be recalled — they will still arrive.
Cancel as a way to stop the rest, not to undo the beginning.
Response
The cancelled campaign, with status: "Cancelled".
Examples
- cURL
- JavaScript
- Python
- C#
- PHP
curl -X POST "https://api.arsel.sa/v1/push/campaigns/0192a1b2-c3d4-7e5f-9000-abcdef123456/cancel" \
-H "Authorization: Bearer $ARSEL_API_KEY"
const response = await fetch("https://api.arsel.sa/v1/push/campaigns/0192a1b2-c3d4-7e5f-9000-abcdef123456/cancel", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.ARSEL_API_KEY}`,
},
});
const data = await response.json();
if (!response.ok) {
throw new Error(`${data.name}: ${data.message}`);
}
console.log(data);
import os
import requests
response = requests.post(
"https://api.arsel.sa/v1/push/campaigns/0192a1b2-c3d4-7e5f-9000-abcdef123456/cancel",
headers={"Authorization": f"Bearer {os.environ['ARSEL_API_KEY']}"},
)
response.raise_for_status()
print(response.json())
using System.Net.Http.Headers;
var client = new HttpClient(); // share one instance across requests
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(
"Bearer", Environment.GetEnvironmentVariable("ARSEL_API_KEY"));
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.arsel.sa/v1/push/campaigns/0192a1b2-c3d4-7e5f-9000-abcdef123456/cancel");
var response = await client.SendAsync(request);
var body = await response.Content.ReadAsStringAsync();
if (!response.IsSuccessStatusCode)
throw new HttpRequestException($"{(int)response.StatusCode}: {body}");
Console.WriteLine(body);
<?php
$ch = curl_init("https://api.arsel.sa/v1/push/campaigns/0192a1b2-c3d4-7e5f-9000-abcdef123456/cancel");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer " . getenv("ARSEL_API_KEY"),
],
]);
$data = json_decode(curl_exec($ch), true);
if (curl_getinfo($ch, CURLINFO_HTTP_CODE) >= 400) {
throw new Exception("{$data['name']}: {$data['message']}");
}
print_r($data);
Error Responses
- 400 Not Cancellable
- 404 Not Found
- 401 Unauthorized
{
"status_code": 400,
"name": "bad_request",
"message": "Cannot cancel a campaign with status \"Sent\""
}
{
"status_code": 404,
"name": "not_found",
"message": "Campaign not found"
}
{
"status_code": 401,
"name": "unauthorized",
"message": "Invalid API Key"
}