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

Authorization
string
header
required

API key authentication. Allowed headers-- "Authorization: ApiKey <api_key>".

Headers

idempotency-key
string

A header for idempotency purposes

Path Parameters

subscriberId
string
required
parameter
string
required

Body

application/json
channel
object

Optional preferences for each channel type in the assigned workflow.

enabled
boolean

Indicates whether the workflow is fully enabled for all channels for the subscriber.

Response

200
application/json
OK
template
object
required

The workflow information and if it is critical or not

preference
object
required

The preferences of the subscriber regarding the related workflow

Was this page helpful?