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

PATCH
/v2/subscribers/{subscriberId}/preferences

Authorization

Authorization<token>

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

In: header

Request Body

application/jsonRequired
channelsRequiredobject

Channel-specific preference settings

workflowIdstring

Workflow internal _id, identifier or slug. If provided, update workflow specific preferences, otherwise update global preferences

Path Parameters

subscriberIdRequiredstring

Header Parameters

idempotency-keystring

A header for idempotency purposes

Response Body

OK

globalRequiredobject

Global preference settings

workflowsRequiredarray<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;
}
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 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
    }
  },
  "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"
      }
    }
  ]
}