(subscribers.preferences)
- list - Get subscriber preferences
- updateGlobal - Update subscriber global preferences
- retrieveByLevel - Get subscriber preferences by level
- update - Update subscriber preference
Get subscriber preferences
import { Novu } from "@novu/api";
const novu = new Novu({
apiKey: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await novu.subscribers.preferences.list("<id>");
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { NovuCore } from "@novu/api/core.js";
import { subscribersPreferencesList } from "@novu/api/funcs/subscribersPreferencesList.js";
// Use `NovuCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const novu = new NovuCore({
apiKey: "<YOUR_API_KEY_HERE>",
});
async function run() {
const res = await subscribersPreferencesList(novu, "<id>");
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
subscriberId |
string | ✔️ | N/A |
idempotencyKey |
string | ➖ | A header for idempotency purposes |
includeInactiveChannels |
boolean | ➖ | A flag which specifies if the inactive workflow channels should be included in the retrieved preferences. Default is true |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<operations.SubscribersControllerListSubscriberPreferencesResponse>
Error Type | Status Code | Content Type |
---|---|---|
errors.ErrorDto | 400, 404, 409 | application/json |
errors.ValidationErrorDto | 422 | application/json |
errors.SDKError | 4XX, 5XX | */* |
Update subscriber global preferences
import { Novu } from "@novu/api";
const novu = new Novu({
apiKey: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await novu.subscribers.preferences.updateGlobal({}, "<id>");
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { NovuCore } from "@novu/api/core.js";
import { subscribersPreferencesUpdateGlobal } from "@novu/api/funcs/subscribersPreferencesUpdateGlobal.js";
// Use `NovuCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const novu = new NovuCore({
apiKey: "<YOUR_API_KEY_HERE>",
});
async function run() {
const res = await subscribersPreferencesUpdateGlobal(novu, {}, "<id>");
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
subscriberId |
string | ✔️ | N/A |
updateSubscriberGlobalPreferencesRequestDto |
components.UpdateSubscriberGlobalPreferencesRequestDto | ✔️ | N/A |
idempotencyKey |
string | ➖ | A header for idempotency purposes |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<operations.SubscribersControllerUpdateSubscriberGlobalPreferencesResponse>
Error Type | Status Code | Content Type |
---|---|---|
errors.ErrorDto | 400, 404, 409 | application/json |
errors.ValidationErrorDto | 422 | application/json |
errors.SDKError | 4XX, 5XX | */* |
Get subscriber preferences by level
import { Novu } from "@novu/api";
const novu = new Novu({
apiKey: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await novu.subscribers.preferences.retrieveByLevel({
preferenceLevel: "global",
subscriberId: "<id>",
});
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { NovuCore } from "@novu/api/core.js";
import { subscribersPreferencesRetrieveByLevel } from "@novu/api/funcs/subscribersPreferencesRetrieveByLevel.js";
// Use `NovuCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const novu = new NovuCore({
apiKey: "<YOUR_API_KEY_HERE>",
});
async function run() {
const res = await subscribersPreferencesRetrieveByLevel(novu, {
preferenceLevel: "global",
subscriberId: "<id>",
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
operations.SubscribersControllerGetSubscriberPreferenceByLevelRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<operations.SubscribersControllerGetSubscriberPreferenceByLevelResponse>
Error Type | Status Code | Content Type |
---|---|---|
errors.ErrorDto | 400, 404, 409 | application/json |
errors.ValidationErrorDto | 422 | application/json |
errors.SDKError | 4XX, 5XX | */* |
Update subscriber preference
import { Novu } from "@novu/api";
const novu = new Novu({
apiKey: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await novu.subscribers.preferences.update({
subscriberId: "<id>",
workflowId: "exampleValue",
updateSubscriberPreferenceRequestDto: {},
});
// Handle the result
console.log(result);
}
run();
The standalone function version of this method:
import { NovuCore } from "@novu/api/core.js";
import { subscribersPreferencesUpdate } from "@novu/api/funcs/subscribersPreferencesUpdate.js";
// Use `NovuCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const novu = new NovuCore({
apiKey: "<YOUR_API_KEY_HERE>",
});
async function run() {
const res = await subscribersPreferencesUpdate(novu, {
subscriberId: "<id>",
workflowId: "exampleValue",
updateSubscriberPreferenceRequestDto: {},
});
if (!res.ok) {
throw res.error;
}
const { value: result } = res;
// Handle the result
console.log(result);
}
run();
Parameter | Type | Required | Description |
---|---|---|---|
request |
operations.SubscribersControllerUpdateSubscriberPreferenceRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body , are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<operations.SubscribersControllerUpdateSubscriberPreferenceResponse>
Error Type | Status Code | Content Type |
---|---|---|
errors.ErrorDto | 400, 404, 409 | application/json |
errors.ValidationErrorDto | 422 | application/json |
errors.SDKError | 4XX, 5XX | */* |