Update subscriber preference
API Reference
Notifications
Integrations
Subscribers
- GETGet subscribers
- POSTBulk create subscribers
- PUTUpdate subscriber credentials
- PATCHModify subscriber credentials
- DELDelete subscriber credentials by providerId
- PATCHUpdate subscriber online status
- GETGet in-app notification feed for a particular subscriber
- GETGet the unseen in-app notifications count for subscribers feed
- POSTMark a subscriber messages as seen, read, unseen or unread
- POSTMarks all the subscriber messages as read, unread, seen or unseen. Optionally you can pass feed id (or array) to mark messages of a particular feed.
- POSTMark message action as seen
- GETHandle providers oauth redirect
- GETHandle chat oauth
- GETSearch for subscribers
- POSTCreate subscriber
- GETGet subscriber
- DELDelete subscriber
- PATCHPatch subscriber
- GETGet subscriber preferences
- PATCHUpdate subscriber global or workflow specific preferences
Update subscriber preference
PATCH
/
v1
/
subscribers
/
{subscriberId}
/
preferences
/
{parameter}
import { Novu } from "@novu/api";
const novu = new Novu({
secretKey: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await novu.subscribers.preferences.updateLegacy({
subscriberId: "<id>",
workflowId: "<id>",
updateSubscriberPreferenceRequestDto: {},
});
// Handle the result
console.log(result);
}
run();
{
"template": {
"_id": "<string>",
"name": "<string>",
"critical": true,
"triggers": [
{
"type": "event",
"identifier": "<string>",
"variables": [
{
"name": "<string>",
"value": {},
"type": "String"
}
],
"subscriberVariables": [
{
"name": "<string>",
"value": {},
"type": "String"
}
],
"reservedVariables": [
{
"type": "tenant",
"variables": [
"<string>"
]
}
]
}
]
},
"preference": {
"enabled": true,
"channels": {
"email": true,
"sms": true,
"in_app": true,
"chat": true,
"push": true
}
}
}
Authorizations
API key authentication. Allowed headers-- "Authorization: ApiKey <api_key>".
Headers
A header for idempotency purposes
Body
application/json
Indicates whether the workflow is fully enabled for all channels for the subscriber.
Response
200
application/json
OK
The workflow information and if it is critical or not
Unique identifier of the workflow
Name of the workflow
Critical templates will always be delivered to the end user and should be hidden from the subscriber preferences screen
Triggers are the events that will trigger the workflow.
The type of the trigger
Available options:
event
The identifier of the trigger
The subscriber variables of the trigger
The preferences of the subscriber regarding the related workflow
Sets if the workflow is fully enabled for all channels or not for the subscriber.
Was this page helpful?
import { Novu } from "@novu/api";
const novu = new Novu({
secretKey: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await novu.subscribers.preferences.updateLegacy({
subscriberId: "<id>",
workflowId: "<id>",
updateSubscriberPreferenceRequestDto: {},
});
// Handle the result
console.log(result);
}
run();
{
"template": {
"_id": "<string>",
"name": "<string>",
"critical": true,
"triggers": [
{
"type": "event",
"identifier": "<string>",
"variables": [
{
"name": "<string>",
"value": {},
"type": "String"
}
],
"subscriberVariables": [
{
"name": "<string>",
"value": {},
"type": "String"
}
],
"reservedVariables": [
{
"type": "tenant",
"variables": [
"<string>"
]
}
]
}
]
},
"preference": {
"enabled": true,
"channels": {
"email": true,
"sms": true,
"in_app": true,
"chat": true,
"push": true
}
}
}