Subscribers
Update subscriber preferences
Update subscriber preferences by its unique key identifier subscriberId. workflowId is optional field, if provided, this API will update that workflow preference, otherwise it will update global preferences
PATCH
/
v2
/
subscribers
/
{subscriberId}
/
preferences
PHP
declare(strict_types=1);
require 'vendor/autoload.php';
use novu;
use novu\Models\Components;
$sdk = novu\Novu::builder()
->setSecurity(
'YOUR_SECRET_KEY_HERE'
)
->build();
$patchSubscriberPreferencesDto = new Components\PatchSubscriberPreferencesDto(
schedule: new Components\ScheduleDto(
isEnabled: true,
weeklySchedule: new Components\WeeklySchedule(
monday: new Components\Monday(
isEnabled: true,
hours: [
new Components\TimeRangeDto(
start: '09:00 AM',
end: '05:00 PM',
),
],
),
tuesday: new Components\Tuesday(
isEnabled: true,
hours: [
new Components\TimeRangeDto(
start: '09:00 AM',
end: '05:00 PM',
),
],
),
wednesday: new Components\Wednesday(
isEnabled: true,
hours: [
new Components\TimeRangeDto(
start: '09:00 AM',
end: '05:00 PM',
),
],
),
thursday: new Components\Thursday(
isEnabled: true,
hours: [
new Components\TimeRangeDto(
start: '09:00 AM',
end: '05:00 PM',
),
],
),
friday: new Components\Friday(
isEnabled: true,
hours: [
new Components\TimeRangeDto(
start: '09:00 AM',
end: '05:00 PM',
),
],
),
saturday: new Components\Saturday(
isEnabled: true,
hours: [
new Components\TimeRangeDto(
start: '09:00 AM',
end: '05:00 PM',
),
],
),
sunday: new Components\Sunday(
isEnabled: true,
hours: [
new Components\TimeRangeDto(
start: '09:00 AM',
end: '05:00 PM',
),
],
),
),
),
context: [
'key' => 'org-acme',
],
);
$response = $sdk->subscribers->updatePreferences(
subscriberId: '<id>',
patchSubscriberPreferencesDto: $patchSubscriberPreferencesDto
);
if ($response->getSubscriberPreferencesDto !== null) {
// handle response
}{
"global": {
"enabled": true,
"channels": {
"email": true,
"sms": false,
"in_app": true,
"chat": false,
"push": true
},
"schedule": {
"isEnabled": true,
"weeklySchedule": {
"monday": {
"isEnabled": true,
"hours": [
{
"start": "09:00 AM",
"end": "05:00 PM"
}
]
},
"tuesday": {
"isEnabled": true,
"hours": [
{
"start": "09:00 AM",
"end": "05:00 PM"
}
]
},
"wednesday": {
"isEnabled": true,
"hours": [
{
"start": "09:00 AM",
"end": "05:00 PM"
}
]
},
"thursday": {
"isEnabled": true,
"hours": [
{
"start": "09:00 AM",
"end": "05:00 PM"
}
]
},
"friday": {
"isEnabled": true,
"hours": [
{
"start": "09:00 AM",
"end": "05:00 PM"
}
]
},
"saturday": {
"isEnabled": true,
"hours": [
{
"start": "09:00 AM",
"end": "05:00 PM"
}
]
},
"sunday": {
"isEnabled": true,
"hours": [
{
"start": "09:00 AM",
"end": "05:00 PM"
}
]
}
}
}
},
"workflows": [
{
"enabled": true,
"channels": {
"email": true,
"sms": false,
"in_app": true,
"chat": false,
"push": true
},
"overrides": [
{}
],
"workflow": {
"slug": "<string>",
"identifier": "<string>",
"name": "<string>",
"updatedAt": "<string>"
},
"updatedAt": "<string>"
}
]
}Authorizations
API key authentication. Allowed headers-- "Authorization: ApiKey <novu_secret_key>".
Headers
A header for idempotency purposes
Path Parameters
The identifier of the subscriber
Body
application/json
Channel-specific preference settings
Show child attributes
Show child attributes
Workflow internal _id, identifier or slug. If provided, update workflow specific preferences, otherwise update global preferences
Subscriber schedule
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Was this page helpful?
⌘I
PHP
declare(strict_types=1);
require 'vendor/autoload.php';
use novu;
use novu\Models\Components;
$sdk = novu\Novu::builder()
->setSecurity(
'YOUR_SECRET_KEY_HERE'
)
->build();
$patchSubscriberPreferencesDto = new Components\PatchSubscriberPreferencesDto(
schedule: new Components\ScheduleDto(
isEnabled: true,
weeklySchedule: new Components\WeeklySchedule(
monday: new Components\Monday(
isEnabled: true,
hours: [
new Components\TimeRangeDto(
start: '09:00 AM',
end: '05:00 PM',
),
],
),
tuesday: new Components\Tuesday(
isEnabled: true,
hours: [
new Components\TimeRangeDto(
start: '09:00 AM',
end: '05:00 PM',
),
],
),
wednesday: new Components\Wednesday(
isEnabled: true,
hours: [
new Components\TimeRangeDto(
start: '09:00 AM',
end: '05:00 PM',
),
],
),
thursday: new Components\Thursday(
isEnabled: true,
hours: [
new Components\TimeRangeDto(
start: '09:00 AM',
end: '05:00 PM',
),
],
),
friday: new Components\Friday(
isEnabled: true,
hours: [
new Components\TimeRangeDto(
start: '09:00 AM',
end: '05:00 PM',
),
],
),
saturday: new Components\Saturday(
isEnabled: true,
hours: [
new Components\TimeRangeDto(
start: '09:00 AM',
end: '05:00 PM',
),
],
),
sunday: new Components\Sunday(
isEnabled: true,
hours: [
new Components\TimeRangeDto(
start: '09:00 AM',
end: '05:00 PM',
),
],
),
),
),
context: [
'key' => 'org-acme',
],
);
$response = $sdk->subscribers->updatePreferences(
subscriberId: '<id>',
patchSubscriberPreferencesDto: $patchSubscriberPreferencesDto
);
if ($response->getSubscriberPreferencesDto !== null) {
// handle response
}{
"global": {
"enabled": true,
"channels": {
"email": true,
"sms": false,
"in_app": true,
"chat": false,
"push": true
},
"schedule": {
"isEnabled": true,
"weeklySchedule": {
"monday": {
"isEnabled": true,
"hours": [
{
"start": "09:00 AM",
"end": "05:00 PM"
}
]
},
"tuesday": {
"isEnabled": true,
"hours": [
{
"start": "09:00 AM",
"end": "05:00 PM"
}
]
},
"wednesday": {
"isEnabled": true,
"hours": [
{
"start": "09:00 AM",
"end": "05:00 PM"
}
]
},
"thursday": {
"isEnabled": true,
"hours": [
{
"start": "09:00 AM",
"end": "05:00 PM"
}
]
},
"friday": {
"isEnabled": true,
"hours": [
{
"start": "09:00 AM",
"end": "05:00 PM"
}
]
},
"saturday": {
"isEnabled": true,
"hours": [
{
"start": "09:00 AM",
"end": "05:00 PM"
}
]
},
"sunday": {
"isEnabled": true,
"hours": [
{
"start": "09:00 AM",
"end": "05:00 PM"
}
]
}
}
}
},
"workflows": [
{
"enabled": true,
"channels": {
"email": true,
"sms": false,
"in_app": true,
"chat": false,
"push": true
},
"overrides": [
{}
],
"workflow": {
"slug": "<string>",
"identifier": "<string>",
"name": "<string>",
"updatedAt": "<string>"
},
"updatedAt": "<string>"
}
]
}