Skip to main content
PATCH
/
v2
/
subscribers
/
{subscriberId}
/
preferences
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();

$patchSubscriberPreferencesDto = new Components\PatchSubscriberPreferencesDto(
    schedule: new Components\ScheduleDto(
        isEnabled: true,
        weeklySchedule: new Components\WeeklySchedule(
            monday: new Components\Monday(
                isEnabled: true,
                hours: [
                    new Components\TimeRangeDto(
                        start: '09:00 AM',
                        end: '05:00 PM',
                    ),
                ],
            ),
            tuesday: new Components\Tuesday(
                isEnabled: true,
                hours: [
                    new Components\TimeRangeDto(
                        start: '09:00 AM',
                        end: '05:00 PM',
                    ),
                ],
            ),
            wednesday: new Components\Wednesday(
                isEnabled: true,
                hours: [
                    new Components\TimeRangeDto(
                        start: '09:00 AM',
                        end: '05:00 PM',
                    ),
                ],
            ),
            thursday: new Components\Thursday(
                isEnabled: true,
                hours: [
                    new Components\TimeRangeDto(
                        start: '09:00 AM',
                        end: '05:00 PM',
                    ),
                ],
            ),
            friday: new Components\Friday(
                isEnabled: true,
                hours: [
                    new Components\TimeRangeDto(
                        start: '09:00 AM',
                        end: '05:00 PM',
                    ),
                ],
            ),
            saturday: new Components\Saturday(
                isEnabled: true,
                hours: [
                    new Components\TimeRangeDto(
                        start: '09:00 AM',
                        end: '05:00 PM',
                    ),
                ],
            ),
            sunday: new Components\Sunday(
                isEnabled: true,
                hours: [
                    new Components\TimeRangeDto(
                        start: '09:00 AM',
                        end: '05:00 PM',
                    ),
                ],
            ),
        ),
    ),
    context: [
        'key' => 'org-acme',
    ],
);

$response = $sdk->subscribers->updatePreferences(
    subscriberId: '<id>',
    patchSubscriberPreferencesDto: $patchSubscriberPreferencesDto

);

if ($response->getSubscriberPreferencesDto !== null) {
    // handle response
}
{
  "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>"
    }
  ]
}

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
channels
object

Channel-specific preference settings

workflowId
string

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

schedule
object

Subscriber schedule

context
object

Response

OK

global
object
required

Global preference settings

workflows
object[]
required

Workflow-specific preference settings