PATCH/ webpush-campaign/ :id/
Update webpush campaign
You can update a specific webpush campaign. This endpoint supports partial updates — only the fields you include in the request body will be modified.
Attributes
Optional unless marked required
- id
- A unique identifier for the campaign which is given by User automatically. Passed in the URL path.
- name
- A Webpush campaign name.
- eta
- A DateTime when the campaign should be sent. Delivery will start instantly if not provided.
- ttl
- The number of seconds that a message may be stored if the user is not immediately available (Time To Live).
- segment
- A unique identifier for the user segment which is given by User automatically.
- messages
- A list of objects. Each object is a valid web push message (check out the Webpush Message attributes). Replaces the existing messages when provided.
Message attributes
Optional unless marked required
- title
- A title of a web push message.
- body
- A content of a web push message.
- url
- A URL of a web push message.
- require_interaction
- A flag defining if a notification should remain active until the user clicks or dismisses it, rather than closing automatically.
- doughnut_title
- Action button 1 label.
- doughnut_url
- Action button 1 URL.
- coffee_title
- Action button 2 label.
- coffee_url
- Action button 2 URL.
- icon
- A URL of image inside a web push message.
- badge
- A URL of image inside a web push message (known as a Big photo). Only works on Windows.
Request
- cURL
- JavaScript
- PHP
- Python
curl -X PATCH "https://<your_app_subdomain>.user.com/api/public/webpush-campaign/:id/" \
-H "Authorization: Token <your_64_char_api_key>" \
-H "Accept: */*; version=2" \
-H "Content-Type: application/json" \
-d '{
"name": "Spring sale push, last day",
"messages": [
{
"title": "The spring sale ends today",
"body": "Save up to 30% on outdoor gear.",
"url": "https://example.com/sale",
"require_interaction": false
}
]
}'
const response = await fetch(
"https://<your_app_subdomain>.user.com/api/public/webpush-campaign/:id/",
{
method: "PATCH",
headers: {
Authorization: "Token <your_64_char_api_key>",
Accept: "*/*; version=2",
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "Spring sale push, last day",
messages: [
{
title: "The spring sale ends today",
body: "Save up to 30% on outdoor gear.",
url: "https://example.com/sale",
require_interaction: false,
},
],
}),
},
);
const data = await response.json();
console.log(data);
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://<your_app_subdomain>.user.com/api/public/webpush-campaign/:id/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_HTTPHEADER => [
"Authorization: Token <your_64_char_api_key>",
"Accept: */*; version=2",
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode([
"name" => "Spring sale push, last day",
"messages" => [
[
"title" => "The spring sale ends today",
"body" => "Save up to 30% on outdoor gear.",
"url" => "https://example.com/sale",
"require_interaction" => false,
],
],
]),
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
import requests
response = requests.patch(
"https://<your_app_subdomain>.user.com/api/public/webpush-campaign/:id/",
headers={
"Authorization": "Token <your_64_char_api_key>",
"Accept": "*/*; version=2",
},
json={
"name": "Spring sale push, last day",
"messages": [
{
"title": "The spring sale ends today",
"body": "Save up to 30% on outdoor gear.",
"url": "https://example.com/sale",
"require_interaction": False,
},
],
},
)
print(response.json())
Response examples
- 200 OK
- 404 Not Found
{
"id": 1,
"name": "string",
"category": null,
"eta": "2026-01-01T12:00:00Z",
"ttl": 1,
"folder": null
}
{
"detail": "No WebpushCampaign matches the given query."
}
Response fields
Fields returned in the 200 OK response body.
- id
- A unique identifier for the campaign.
- name
- A Webpush campaign name.
- category
- Deprecated (replaced by folders). Read-only. Existing campaigns may return a legacy category value; new campaigns always return
null. Folder assignment will be available in the next API version. - eta
- A DateTime when the campaign is scheduled to be sent.
nullif sent immediately. - ttl
- Time-to-live in seconds.
- folder
- ID of the folder the campaign is in, or
null.
note
Errors that can come from any endpoint (401, 429, 500, 502, 504) are described in HTTP response codes.