Skip to main content
PATCH
/
v2
/
subscribers
/
{subscriberId}
/
preferences
/
bulk
PHP
declare(strict_types=1);

require 'vendor/autoload.php';

use novu;
use novu\Models\Components;

$sdk = novu\Novu::builder()
    ->setSecurity(
        'YOUR_SECRET_KEY_HERE'
    )
    ->build();

$bulkUpdateSubscriberPreferencesDto = new Components\BulkUpdateSubscriberPreferencesDto(
    preferences: [],
    context: [
        'key' => 'org-acme',
    ],
);

$response = $sdk->subscribers->preferences->bulkUpdate(
    subscriberId: '<id>',
    bulkUpdateSubscriberPreferencesDto: $bulkUpdateSubscriberPreferencesDto

);

if ($response->getPreferencesResponseDtos !== null) {
    // handle response
}
[
  {
    "enabled": true,
    "channels": {
      "email": true,
      "sms": false,
      "in_app": true,
      "chat": false,
      "push": true
    },
    "workflow": {
      "id": "64a1b2c3d4e5f6g7h8i9j0k1",
      "identifier": "welcome-email",
      "name": "Welcome Email Workflow",
      "critical": false,
      "tags": [
        "user-onboarding",
        "email"
      ],
      "data": {
        "category": "onboarding",
        "priority": "high"
      }
    },
    "condition": {}
  }
]

Authorizations

Authorization
string
header
required

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

Headers

idempotency-key
string

A header for idempotency purposes

Path Parameters

subscriberId
string
required

The identifier of the subscriber

Body

application/json
preferences
object[]
required

Array of workflow preferences to update (maximum 100 items)

Maximum array length: 100
context
object

Response

OK

level
enum<string>
required

The level of the preference (global or template)

Available options:
global,
template
enabled
boolean
required

Whether the preference is enabled

Example:

true

channels
object
required

Channel-specific preference settings

workflow
object

Workflow information if this is a template-level preference

condition
object

Condition using JSON Logic rules