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
Authorization
Authorization
<token>API key authentication. Allowed headers-- "Authorization: ApiKey <api_key>".
In: header
Request Body
application/json
Requiredchannels
RequiredobjectChannel-specific preference settings
workflowId
stringWorkflow internal _id, identifier or slug. If provided, update workflow specific preferences, otherwise update global preferences
Path Parameters
subscriberId
RequiredstringHeader Parameters
idempotency-key
stringA header for idempotency purposes
Response Body
OK
global
RequiredobjectGlobal preference settings
workflows
Requiredarray<object>Workflow-specific preference settings
export interface Response {
/**
* Global preference settings
*/
global: SubscriberGlobalPreferenceDto;
/**
* Workflow-specific preference settings
*/
workflows: SubscriberWorkflowPreferenceDto[];
}
export interface SubscriberGlobalPreferenceDto {
/**
* Whether notifications are enabled globally
*/
enabled: boolean;
/**
* Channel-specific preference settings
*/
channels: SubscriberPreferenceChannels;
/**
* Subscriber schedule
*/
schedule?: ScheduleDto;
}
export interface SubscriberPreferenceChannels {
/**
* Email channel preference
*/
email?: boolean;
/**
* SMS channel preference
*/
sms?: boolean;
/**
* In-app channel preference
*/
in_app?: boolean;
/**
* Chat channel preference
*/
chat?: boolean;
/**
* Push notification channel preference
*/
push?: boolean;
}
export interface ScheduleDto {
/**
* Schedule enabled
*/
isEnabled: boolean;
/**
* Weekly schedule
*/
weeklySchedule?: WeeklyScheduleDto;
}
export interface WeeklyScheduleDto {
/**
* Monday schedule
*/
monday?: DayScheduleDto;
/**
* Tuesday schedule
*/
tuesday?: DayScheduleDto1;
/**
* Wednesday schedule
*/
wednesday?: DayScheduleDto2;
/**
* Thursday schedule
*/
thursday?: DayScheduleDto3;
/**
* Friday schedule
*/
friday?: DayScheduleDto4;
/**
* Saturday schedule
*/
saturday?: DayScheduleDto5;
/**
* Sunday schedule
*/
sunday?: DayScheduleDto6;
}
export interface DayScheduleDto {
/**
* Day schedule enabled
*/
isEnabled: boolean;
/**
* Hours
*/
hours?: TimeRangeDto[];
}
export interface TimeRangeDto {
/**
* Start time
*/
start: string;
/**
* End time
*/
end: string;
}
export interface DayScheduleDto1 {
/**
* Day schedule enabled
*/
isEnabled: boolean;
/**
* Hours
*/
hours?: TimeRangeDto[];
}
export interface DayScheduleDto2 {
/**
* Day schedule enabled
*/
isEnabled: boolean;
/**
* Hours
*/
hours?: TimeRangeDto[];
}
export interface DayScheduleDto3 {
/**
* Day schedule enabled
*/
isEnabled: boolean;
/**
* Hours
*/
hours?: TimeRangeDto[];
}
export interface DayScheduleDto4 {
/**
* Day schedule enabled
*/
isEnabled: boolean;
/**
* Hours
*/
hours?: TimeRangeDto[];
}
export interface DayScheduleDto5 {
/**
* Day schedule enabled
*/
isEnabled: boolean;
/**
* Hours
*/
hours?: TimeRangeDto[];
}
export interface DayScheduleDto6 {
/**
* Day schedule enabled
*/
isEnabled: boolean;
/**
* Hours
*/
hours?: TimeRangeDto[];
}
export interface SubscriberWorkflowPreferenceDto {
/**
* Whether notifications are enabled for this workflow
*/
enabled: boolean;
/**
* Channel-specific preference settings for this workflow
*/
channels: SubscriberPreferenceChannels1;
/**
* List of preference overrides
*/
overrides: SubscriberPreferenceOverrideDto[];
/**
* Workflow information
*/
workflow: SubscriberPreferencesWorkflowInfoDto;
}
export interface SubscriberPreferenceChannels1 {
/**
* Email channel preference
*/
email?: boolean;
/**
* SMS channel preference
*/
sms?: boolean;
/**
* In-app channel preference
*/
in_app?: boolean;
/**
* Chat channel preference
*/
chat?: boolean;
/**
* Push notification channel preference
*/
push?: boolean;
}
export interface SubscriberPreferenceOverrideDto {
/**
* Channel type through which the message is sent
*/
channel: "in_app" | "email" | "sms" | "chat" | "push";
/**
* The source of overrides
*/
source: "subscriber" | "template" | "workflowOverride";
}
export interface SubscriberPreferencesWorkflowInfoDto {
/**
* Workflow slug
*/
slug: string;
/**
* Unique identifier of the workflow
*/
identifier: string;
/**
* Display name of the workflow
*/
name: string;
/**
* last updated date
*/
updatedAt?: string;
}
curl -X PATCH "https://api.novu.co/v2/subscribers/string/preferences" \
-H "idempotency-key: string" \
-H "Authorization: <token>" \
-H "Content-Type: application/json" \
-d '{
"channels": {
"email": true,
"sms": true,
"in_app": true,
"push": true,
"chat": true
},
"workflowId": "string"
}'
{
"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": [
{
"channel": "in_app",
"source": "subscriber"
}
],
"workflow": {
"slug": "string",
"identifier": "string",
"name": "string",
"updatedAt": "string"
}
}
]
}