Preferences
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
TypeScript
import { Novu } from "@novu/api";
const novu = new Novu({
secretKey: "YOUR_SECRET_KEY_HERE",
});
async function run() {
const result = await novu.subscribers.preferences.update({
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",
},
],
},
},
},
context: {
"key": "org-acme",
},
}, "<id>");
console.log(result);
}
run();using Novu;
using Novu.Models.Components;
using System.Collections.Generic;
var sdk = new NovuSDK(secretKey: "YOUR_SECRET_KEY_HERE");
var res = await sdk.SubscribersPreferences.UpdateAsync(
subscriberId: "<id>",
patchSubscriberPreferencesDto: new PatchSubscriberPreferencesDto() {
Schedule = new ScheduleDto() {
IsEnabled = true,
WeeklySchedule = new WeeklySchedule() {
Monday = new Monday() {
IsEnabled = true,
Hours = new List<TimeRangeDto>() {
new TimeRangeDto() {
Start = "09:00 AM",
End = "05:00 PM",
},
},
},
Tuesday = new Tuesday() {
IsEnabled = true,
Hours = new List<TimeRangeDto>() {
new TimeRangeDto() {
Start = "09:00 AM",
End = "05:00 PM",
},
},
},
Wednesday = new Wednesday() {
IsEnabled = true,
Hours = new List<TimeRangeDto>() {
new TimeRangeDto() {
Start = "09:00 AM",
End = "05:00 PM",
},
},
},
Thursday = new Thursday() {
IsEnabled = true,
Hours = new List<TimeRangeDto>() {
new TimeRangeDto() {
Start = "09:00 AM",
End = "05:00 PM",
},
},
},
Friday = new Friday() {
IsEnabled = true,
Hours = new List<TimeRangeDto>() {
new TimeRangeDto() {
Start = "09:00 AM",
End = "05:00 PM",
},
},
},
Saturday = new Saturday() {
IsEnabled = true,
Hours = new List<TimeRangeDto>() {
new TimeRangeDto() {
Start = "09:00 AM",
End = "05:00 PM",
},
},
},
Sunday = new Sunday() {
IsEnabled = true,
Hours = new List<TimeRangeDto>() {
new TimeRangeDto() {
Start = "09:00 AM",
End = "05:00 PM",
},
},
},
},
},
Context = new Dictionary<string, Context>() {
{ "key", Context.CreateStr(
"org-acme"
) },
},
}
);
// handle responsedeclare(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
}from novu_py import Novu
with Novu(
secret_key="YOUR_SECRET_KEY_HERE",
) as novu:
res = novu.subscribers.preferences.update(subscriber_id="<id>", patch_subscriber_preferences_dto={
"schedule": {
"is_enabled": True,
"weekly_schedule": {
"monday": {
"is_enabled": True,
"hours": [
{
"start": "09:00 AM",
"end": "05:00 PM",
},
],
},
"tuesday": {
"is_enabled": True,
"hours": [
{
"start": "09:00 AM",
"end": "05:00 PM",
},
],
},
"wednesday": {
"is_enabled": True,
"hours": [
{
"start": "09:00 AM",
"end": "05:00 PM",
},
],
},
"thursday": {
"is_enabled": True,
"hours": [
{
"start": "09:00 AM",
"end": "05:00 PM",
},
],
},
"friday": {
"is_enabled": True,
"hours": [
{
"start": "09:00 AM",
"end": "05:00 PM",
},
],
},
"saturday": {
"is_enabled": True,
"hours": [
{
"start": "09:00 AM",
"end": "05:00 PM",
},
],
},
"sunday": {
"is_enabled": True,
"hours": [
{
"start": "09:00 AM",
"end": "05:00 PM",
},
],
},
},
},
"context": {
"key": "org-acme",
},
})
# Handle response
print(res)package main
import(
"context"
"github.com/novuhq/novu-go/v3"
"github.com/novuhq/novu-go/v3/models/components"
"log"
)
func main() {
ctx := context.Background()
s := v3.New(
v3.WithSecurity("YOUR_SECRET_KEY_HERE"),
)
res, err := s.Subscribers.Preferences.Update(ctx, "<id>", components.PatchSubscriberPreferencesDto{
Schedule: &components.ScheduleDto{
IsEnabled: true,
WeeklySchedule: &components.WeeklySchedule{
Monday: &components.Monday{
IsEnabled: true,
Hours: []components.TimeRangeDto{
components.TimeRangeDto{
Start: "09:00 AM",
End: "05:00 PM",
},
},
},
Tuesday: &components.Tuesday{
IsEnabled: true,
Hours: []components.TimeRangeDto{
components.TimeRangeDto{
Start: "09:00 AM",
End: "05:00 PM",
},
},
},
Wednesday: &components.Wednesday{
IsEnabled: true,
Hours: []components.TimeRangeDto{
components.TimeRangeDto{
Start: "09:00 AM",
End: "05:00 PM",
},
},
},
Thursday: &components.Thursday{
IsEnabled: true,
Hours: []components.TimeRangeDto{
components.TimeRangeDto{
Start: "09:00 AM",
End: "05:00 PM",
},
},
},
Friday: &components.Friday{
IsEnabled: true,
Hours: []components.TimeRangeDto{
components.TimeRangeDto{
Start: "09:00 AM",
End: "05:00 PM",
},
},
},
Saturday: &components.Saturday{
IsEnabled: true,
Hours: []components.TimeRangeDto{
components.TimeRangeDto{
Start: "09:00 AM",
End: "05:00 PM",
},
},
},
Sunday: &components.Sunday{
IsEnabled: true,
Hours: []components.TimeRangeDto{
components.TimeRangeDto{
Start: "09:00 AM",
End: "05:00 PM",
},
},
},
},
},
Context: map[string]components.Context{
"key": components.CreateContextStr(
"org-acme",
),
},
}, nil)
if err != nil {
log.Fatal(err)
}
if res.GetSubscriberPreferencesDto != nil {
// handle response
}
}curl --request PATCH \
--url https://api.novu.co/v2/subscribers/{subscriberId}/preferences \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"channels": {
"email": true,
"sms": true,
"in_app": true,
"push": true,
"chat": true
},
"workflowId": "<string>",
"context": {}
}
'const options = {
method: 'PATCH',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
channels: {email: true, sms: true, in_app: true, push: true, chat: true},
workflowId: '<string>',
context: {}
})
};
fetch('https://api.novu.co/v2/subscribers/{subscriberId}/preferences', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));HttpResponse<String> response = Unirest.patch("https://api.novu.co/v2/subscribers/{subscriberId}/preferences")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"channels\": {\n \"email\": true,\n \"sms\": true,\n \"in_app\": true,\n \"push\": true,\n \"chat\": true\n },\n \"workflowId\": \"<string>\",\n \"context\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.novu.co/v2/subscribers/{subscriberId}/preferences")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"channels\": {\n \"email\": true,\n \"sms\": true,\n \"in_app\": true,\n \"push\": true,\n \"chat\": true\n },\n \"workflowId\": \"<string>\",\n \"context\": {}\n}"
response = http.request(request)
puts response.read_body{
"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>"
}
]
}{
"statusCode": 404,
"timestamp": "2024-12-12T13:00:00Z",
"path": "/api/v1/resource",
"message": "xx xx xx ",
"ctx": {
"workflowId": "some_wf_id",
"stepId": "some_wf_id"
},
"errorId": "abc123"
}{
"statusCode": 404,
"timestamp": "2024-12-12T13:00:00Z",
"path": "/api/v1/resource",
"message": "xx xx xx ",
"ctx": {
"workflowId": "some_wf_id",
"stepId": "some_wf_id"
},
"errorId": "abc123"
}{
"statusCode": 404,
"timestamp": "2024-12-12T13:00:00Z",
"path": "/api/v1/resource",
"message": "xx xx xx ",
"ctx": {
"workflowId": "some_wf_id",
"stepId": "some_wf_id"
},
"errorId": "abc123"
}{
"statusCode": 404,
"timestamp": "2024-12-12T13:00:00Z",
"path": "/api/v1/resource",
"message": "xx xx xx ",
"ctx": {
"workflowId": "some_wf_id",
"stepId": "some_wf_id"
},
"errorId": "abc123"
}{
"statusCode": 404,
"timestamp": "2024-12-12T13:00:00Z",
"path": "/api/v1/resource",
"message": "xx xx xx ",
"ctx": {
"workflowId": "some_wf_id",
"stepId": "some_wf_id"
},
"errorId": "abc123"
}{
"statusCode": 404,
"timestamp": "2024-12-12T13:00:00Z",
"path": "/api/v1/resource",
"message": "xx xx xx ",
"ctx": {
"workflowId": "some_wf_id",
"stepId": "some_wf_id"
},
"errorId": "abc123"
}{
"statusCode": 404,
"timestamp": "2024-12-12T13:00:00Z",
"path": "/api/v1/resource",
"message": "xx xx xx ",
"ctx": {
"workflowId": "some_wf_id",
"stepId": "some_wf_id"
},
"errorId": "abc123"
}{
"statusCode": 404,
"timestamp": "2024-12-12T13:00:00Z",
"path": "/api/v1/resource",
"message": "xx xx xx ",
"ctx": {
"workflowId": "some_wf_id",
"stepId": "some_wf_id"
},
"errorId": "abc123"
}{
"statusCode": 404,
"timestamp": "2024-12-12T13:00:00Z",
"path": "/api/v1/resource",
"message": "xx xx xx ",
"ctx": {
"workflowId": "some_wf_id",
"stepId": "some_wf_id"
},
"errorId": "abc123"
}{
"statusCode": 404,
"timestamp": "2024-12-12T13:00:00Z",
"path": "/api/v1/resource",
"errors": {
"fieldName1": {
"messages": [
"Field is required",
"Must be a valid email address"
],
"value": "invalidEmail"
},
"fieldName2": {
"messages": [
"Must be at least 18 years old"
],
"value": 17
},
"fieldName3": {
"messages": [
"Must be a boolean value"
],
"value": true
},
"fieldName4": {
"messages": [
"Must be a valid object"
],
"value": {
"key": "value"
}
},
"fieldName5": {
"messages": [
"Field is missing"
],
"value": null
},
"fieldName6": {
"messages": [
"Undefined value"
]
}
},
"message": "xx xx xx ",
"ctx": {
"workflowId": "some_wf_id",
"stepId": "some_wf_id"
},
"errorId": "abc123"
}"API rate limit exceeded"{
"statusCode": 404,
"timestamp": "2024-12-12T13:00:00Z",
"path": "/api/v1/resource",
"message": "xx xx xx ",
"ctx": {
"workflowId": "some_wf_id",
"stepId": "some_wf_id"
},
"errorId": "abc123"
}"Please wait some time, then try again."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
TypeScript
import { Novu } from "@novu/api";
const novu = new Novu({
secretKey: "YOUR_SECRET_KEY_HERE",
});
async function run() {
const result = await novu.subscribers.preferences.update({
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",
},
],
},
},
},
context: {
"key": "org-acme",
},
}, "<id>");
console.log(result);
}
run();using Novu;
using Novu.Models.Components;
using System.Collections.Generic;
var sdk = new NovuSDK(secretKey: "YOUR_SECRET_KEY_HERE");
var res = await sdk.SubscribersPreferences.UpdateAsync(
subscriberId: "<id>",
patchSubscriberPreferencesDto: new PatchSubscriberPreferencesDto() {
Schedule = new ScheduleDto() {
IsEnabled = true,
WeeklySchedule = new WeeklySchedule() {
Monday = new Monday() {
IsEnabled = true,
Hours = new List<TimeRangeDto>() {
new TimeRangeDto() {
Start = "09:00 AM",
End = "05:00 PM",
},
},
},
Tuesday = new Tuesday() {
IsEnabled = true,
Hours = new List<TimeRangeDto>() {
new TimeRangeDto() {
Start = "09:00 AM",
End = "05:00 PM",
},
},
},
Wednesday = new Wednesday() {
IsEnabled = true,
Hours = new List<TimeRangeDto>() {
new TimeRangeDto() {
Start = "09:00 AM",
End = "05:00 PM",
},
},
},
Thursday = new Thursday() {
IsEnabled = true,
Hours = new List<TimeRangeDto>() {
new TimeRangeDto() {
Start = "09:00 AM",
End = "05:00 PM",
},
},
},
Friday = new Friday() {
IsEnabled = true,
Hours = new List<TimeRangeDto>() {
new TimeRangeDto() {
Start = "09:00 AM",
End = "05:00 PM",
},
},
},
Saturday = new Saturday() {
IsEnabled = true,
Hours = new List<TimeRangeDto>() {
new TimeRangeDto() {
Start = "09:00 AM",
End = "05:00 PM",
},
},
},
Sunday = new Sunday() {
IsEnabled = true,
Hours = new List<TimeRangeDto>() {
new TimeRangeDto() {
Start = "09:00 AM",
End = "05:00 PM",
},
},
},
},
},
Context = new Dictionary<string, Context>() {
{ "key", Context.CreateStr(
"org-acme"
) },
},
}
);
// handle responsedeclare(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
}from novu_py import Novu
with Novu(
secret_key="YOUR_SECRET_KEY_HERE",
) as novu:
res = novu.subscribers.preferences.update(subscriber_id="<id>", patch_subscriber_preferences_dto={
"schedule": {
"is_enabled": True,
"weekly_schedule": {
"monday": {
"is_enabled": True,
"hours": [
{
"start": "09:00 AM",
"end": "05:00 PM",
},
],
},
"tuesday": {
"is_enabled": True,
"hours": [
{
"start": "09:00 AM",
"end": "05:00 PM",
},
],
},
"wednesday": {
"is_enabled": True,
"hours": [
{
"start": "09:00 AM",
"end": "05:00 PM",
},
],
},
"thursday": {
"is_enabled": True,
"hours": [
{
"start": "09:00 AM",
"end": "05:00 PM",
},
],
},
"friday": {
"is_enabled": True,
"hours": [
{
"start": "09:00 AM",
"end": "05:00 PM",
},
],
},
"saturday": {
"is_enabled": True,
"hours": [
{
"start": "09:00 AM",
"end": "05:00 PM",
},
],
},
"sunday": {
"is_enabled": True,
"hours": [
{
"start": "09:00 AM",
"end": "05:00 PM",
},
],
},
},
},
"context": {
"key": "org-acme",
},
})
# Handle response
print(res)package main
import(
"context"
"github.com/novuhq/novu-go/v3"
"github.com/novuhq/novu-go/v3/models/components"
"log"
)
func main() {
ctx := context.Background()
s := v3.New(
v3.WithSecurity("YOUR_SECRET_KEY_HERE"),
)
res, err := s.Subscribers.Preferences.Update(ctx, "<id>", components.PatchSubscriberPreferencesDto{
Schedule: &components.ScheduleDto{
IsEnabled: true,
WeeklySchedule: &components.WeeklySchedule{
Monday: &components.Monday{
IsEnabled: true,
Hours: []components.TimeRangeDto{
components.TimeRangeDto{
Start: "09:00 AM",
End: "05:00 PM",
},
},
},
Tuesday: &components.Tuesday{
IsEnabled: true,
Hours: []components.TimeRangeDto{
components.TimeRangeDto{
Start: "09:00 AM",
End: "05:00 PM",
},
},
},
Wednesday: &components.Wednesday{
IsEnabled: true,
Hours: []components.TimeRangeDto{
components.TimeRangeDto{
Start: "09:00 AM",
End: "05:00 PM",
},
},
},
Thursday: &components.Thursday{
IsEnabled: true,
Hours: []components.TimeRangeDto{
components.TimeRangeDto{
Start: "09:00 AM",
End: "05:00 PM",
},
},
},
Friday: &components.Friday{
IsEnabled: true,
Hours: []components.TimeRangeDto{
components.TimeRangeDto{
Start: "09:00 AM",
End: "05:00 PM",
},
},
},
Saturday: &components.Saturday{
IsEnabled: true,
Hours: []components.TimeRangeDto{
components.TimeRangeDto{
Start: "09:00 AM",
End: "05:00 PM",
},
},
},
Sunday: &components.Sunday{
IsEnabled: true,
Hours: []components.TimeRangeDto{
components.TimeRangeDto{
Start: "09:00 AM",
End: "05:00 PM",
},
},
},
},
},
Context: map[string]components.Context{
"key": components.CreateContextStr(
"org-acme",
),
},
}, nil)
if err != nil {
log.Fatal(err)
}
if res.GetSubscriberPreferencesDto != nil {
// handle response
}
}curl --request PATCH \
--url https://api.novu.co/v2/subscribers/{subscriberId}/preferences \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"channels": {
"email": true,
"sms": true,
"in_app": true,
"push": true,
"chat": true
},
"workflowId": "<string>",
"context": {}
}
'const options = {
method: 'PATCH',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
channels: {email: true, sms: true, in_app: true, push: true, chat: true},
workflowId: '<string>',
context: {}
})
};
fetch('https://api.novu.co/v2/subscribers/{subscriberId}/preferences', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));HttpResponse<String> response = Unirest.patch("https://api.novu.co/v2/subscribers/{subscriberId}/preferences")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"channels\": {\n \"email\": true,\n \"sms\": true,\n \"in_app\": true,\n \"push\": true,\n \"chat\": true\n },\n \"workflowId\": \"<string>\",\n \"context\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.novu.co/v2/subscribers/{subscriberId}/preferences")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"channels\": {\n \"email\": true,\n \"sms\": true,\n \"in_app\": true,\n \"push\": true,\n \"chat\": true\n },\n \"workflowId\": \"<string>\",\n \"context\": {}\n}"
response = http.request(request)
puts response.read_body{
"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>"
}
]
}{
"statusCode": 404,
"timestamp": "2024-12-12T13:00:00Z",
"path": "/api/v1/resource",
"message": "xx xx xx ",
"ctx": {
"workflowId": "some_wf_id",
"stepId": "some_wf_id"
},
"errorId": "abc123"
}{
"statusCode": 404,
"timestamp": "2024-12-12T13:00:00Z",
"path": "/api/v1/resource",
"message": "xx xx xx ",
"ctx": {
"workflowId": "some_wf_id",
"stepId": "some_wf_id"
},
"errorId": "abc123"
}{
"statusCode": 404,
"timestamp": "2024-12-12T13:00:00Z",
"path": "/api/v1/resource",
"message": "xx xx xx ",
"ctx": {
"workflowId": "some_wf_id",
"stepId": "some_wf_id"
},
"errorId": "abc123"
}{
"statusCode": 404,
"timestamp": "2024-12-12T13:00:00Z",
"path": "/api/v1/resource",
"message": "xx xx xx ",
"ctx": {
"workflowId": "some_wf_id",
"stepId": "some_wf_id"
},
"errorId": "abc123"
}{
"statusCode": 404,
"timestamp": "2024-12-12T13:00:00Z",
"path": "/api/v1/resource",
"message": "xx xx xx ",
"ctx": {
"workflowId": "some_wf_id",
"stepId": "some_wf_id"
},
"errorId": "abc123"
}{
"statusCode": 404,
"timestamp": "2024-12-12T13:00:00Z",
"path": "/api/v1/resource",
"message": "xx xx xx ",
"ctx": {
"workflowId": "some_wf_id",
"stepId": "some_wf_id"
},
"errorId": "abc123"
}{
"statusCode": 404,
"timestamp": "2024-12-12T13:00:00Z",
"path": "/api/v1/resource",
"message": "xx xx xx ",
"ctx": {
"workflowId": "some_wf_id",
"stepId": "some_wf_id"
},
"errorId": "abc123"
}{
"statusCode": 404,
"timestamp": "2024-12-12T13:00:00Z",
"path": "/api/v1/resource",
"message": "xx xx xx ",
"ctx": {
"workflowId": "some_wf_id",
"stepId": "some_wf_id"
},
"errorId": "abc123"
}{
"statusCode": 404,
"timestamp": "2024-12-12T13:00:00Z",
"path": "/api/v1/resource",
"message": "xx xx xx ",
"ctx": {
"workflowId": "some_wf_id",
"stepId": "some_wf_id"
},
"errorId": "abc123"
}{
"statusCode": 404,
"timestamp": "2024-12-12T13:00:00Z",
"path": "/api/v1/resource",
"errors": {
"fieldName1": {
"messages": [
"Field is required",
"Must be a valid email address"
],
"value": "invalidEmail"
},
"fieldName2": {
"messages": [
"Must be at least 18 years old"
],
"value": 17
},
"fieldName3": {
"messages": [
"Must be a boolean value"
],
"value": true
},
"fieldName4": {
"messages": [
"Must be a valid object"
],
"value": {
"key": "value"
}
},
"fieldName5": {
"messages": [
"Field is missing"
],
"value": null
},
"fieldName6": {
"messages": [
"Undefined value"
]
}
},
"message": "xx xx xx ",
"ctx": {
"workflowId": "some_wf_id",
"stepId": "some_wf_id"
},
"errorId": "abc123"
}"API rate limit exceeded"{
"statusCode": 404,
"timestamp": "2024-12-12T13:00:00Z",
"path": "/api/v1/resource",
"message": "xx xx xx ",
"ctx": {
"workflowId": "some_wf_id",
"stepId": "some_wf_id"
},
"errorId": "abc123"
}"Please wait some time, then try again."