Preferences
Retrieve subscriber preferences
Retrieve subscriber channel preferences by its unique key identifier subscriberId. This API returns all five channels preferences for all workflows and global preferences.
GET
/
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.list({
subscriberId: "<id>",
contextKeys: [
"tenant:acme",
],
});
console.log(result);
}
run();using Novu;
using Novu.Models.Components;
using Novu.Models.Requests;
using System.Collections.Generic;
var sdk = new NovuSDK(secretKey: "YOUR_SECRET_KEY_HERE");
var res = await sdk.SubscribersPreferences.ListAsync(
subscriberId: "<id>",
criticality: Criticality.NonCritical,
contextKeys: new List<string>() {
"tenant:acme",
}
);
// handle responsedeclare(strict_types=1);
require 'vendor/autoload.php';
use novu;
use novu\Models\Operations;
$sdk = novu\Novu::builder()
->setSecurity(
'YOUR_SECRET_KEY_HERE'
)
->build();
$response = $sdk->subscribersPreferences->list(
subscriberId: '<id>',
criticality: Operations\Criticality::NonCritical,
contextKeys: [
'tenant:acme',
]
);
if ($response->getSubscriberPreferencesDto !== null) {
// handle response
}import novu_py
from novu_py import Novu
with Novu(
secret_key="YOUR_SECRET_KEY_HERE",
) as novu:
res = novu.subscribers.preferences.list(subscriber_id="<id>", criticality=novu_py.Criticality.NON_CRITICAL, context_keys=[
"tenant:acme",
])
# Handle response
print(res)package main
import(
"context"
"github.com/novuhq/novu-go/v3"
"github.com/novuhq/novu-go/v3/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := v3.New(
v3.WithSecurity("YOUR_SECRET_KEY_HERE"),
)
res, err := s.Subscribers.Preferences.List(ctx, "<id>", operations.CriticalityNonCritical.ToPointer(), []string{
"tenant:acme",
}, nil)
if err != nil {
log.Fatal(err)
}
if res.GetSubscriberPreferencesDto != nil {
// handle response
}
}curl --request GET \
--url https://api.novu.co/v2/subscribers/{subscriberId}/preferences \
--header 'Authorization: <api-key>'const options = {method: 'GET', headers: {Authorization: '<api-key>'}};
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.get("https://api.novu.co/v2/subscribers/{subscriberId}/preferences")
.header("Authorization", "<api-key>")
.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::Get.new(url)
request["Authorization"] = '<api-key>'
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
Query Parameters
Available options:
critical, nonCritical, all Context keys for filtering preferences (e.g., ["tenant:acme"])
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.list({
subscriberId: "<id>",
contextKeys: [
"tenant:acme",
],
});
console.log(result);
}
run();using Novu;
using Novu.Models.Components;
using Novu.Models.Requests;
using System.Collections.Generic;
var sdk = new NovuSDK(secretKey: "YOUR_SECRET_KEY_HERE");
var res = await sdk.SubscribersPreferences.ListAsync(
subscriberId: "<id>",
criticality: Criticality.NonCritical,
contextKeys: new List<string>() {
"tenant:acme",
}
);
// handle responsedeclare(strict_types=1);
require 'vendor/autoload.php';
use novu;
use novu\Models\Operations;
$sdk = novu\Novu::builder()
->setSecurity(
'YOUR_SECRET_KEY_HERE'
)
->build();
$response = $sdk->subscribersPreferences->list(
subscriberId: '<id>',
criticality: Operations\Criticality::NonCritical,
contextKeys: [
'tenant:acme',
]
);
if ($response->getSubscriberPreferencesDto !== null) {
// handle response
}import novu_py
from novu_py import Novu
with Novu(
secret_key="YOUR_SECRET_KEY_HERE",
) as novu:
res = novu.subscribers.preferences.list(subscriber_id="<id>", criticality=novu_py.Criticality.NON_CRITICAL, context_keys=[
"tenant:acme",
])
# Handle response
print(res)package main
import(
"context"
"github.com/novuhq/novu-go/v3"
"github.com/novuhq/novu-go/v3/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := v3.New(
v3.WithSecurity("YOUR_SECRET_KEY_HERE"),
)
res, err := s.Subscribers.Preferences.List(ctx, "<id>", operations.CriticalityNonCritical.ToPointer(), []string{
"tenant:acme",
}, nil)
if err != nil {
log.Fatal(err)
}
if res.GetSubscriberPreferencesDto != nil {
// handle response
}
}curl --request GET \
--url https://api.novu.co/v2/subscribers/{subscriberId}/preferences \
--header 'Authorization: <api-key>'const options = {method: 'GET', headers: {Authorization: '<api-key>'}};
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.get("https://api.novu.co/v2/subscribers/{subscriberId}/preferences")
.header("Authorization", "<api-key>")
.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::Get.new(url)
request["Authorization"] = '<api-key>'
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."