> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bbrands.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Set Account Preferences (Admin)

> Admin write of the preferences of any account, with a mandatory `reason` recorded in the audit log. Rows record the source `horizon-enterprise-admin` and the admin as `user`. Requires `notification-preference:update`.

- Without `account` in the query: one `(channel, category)` cell, or an event × channel override with `notification_event`, of the `account` in the body. Answers the stored row.
- With `?account=`: a batch of up to 100 `changes` with one `reason`, as the Enterprise module sends it. Answers the new matrix of the account (category cells, event overrides and the preference history).

Only `marketing` can be switched off at category level; disabling a mandatory category, overriding an event that is not opt-out-able, or a `category` that does not match the event answers 400.



## OpenAPI

````yaml api-reference/notification/preference/openapi.yaml PUT /notification/preference
openapi: 3.0.1
info:
  title: Notification Preference API
  description: >
    Notification preferences (`notification_preference`): a user's override for
    one channel and category. Without a row a channel is enabled; `payment`,
    `system` and `transactional` cannot be opted out of. The `/me` routes act on
    the authenticated user.


    List paging and sorting read the camelCase keys `pageSize`,
    `maxPageSizeOverride` and `orderBy`. Every route requires the
    `notification-preference:<action>` permission named in its description.
  version: '2026-10-21'
servers:
  - description: Production
    url: https://api.bbrands.io/api/v3
  - description: Certification
    url: https://certification.api.bbrands.io/api/v3
  - description: Development
    url: https://development.api.bbrands.io/api/v3
security:
  - bearerAuth: []
  - apiKeyAuth: []
tags:
  - name: Notification Preference
    description: Per-user opt-out overrides by channel and category.
paths:
  /notification/preference:
    put:
      tags:
        - Notification Preference
      summary: Set preferences of an account (admin)
      description: >-
        Admin write of the preferences of any account, with a mandatory `reason`
        recorded in the audit log. Rows record the source
        `horizon-enterprise-admin` and the admin as `user`. Requires
        `notification-preference:update`.


        - Without `account` in the query: one `(channel, category)` cell, or an
        event × channel override with `notification_event`, of the `account` in
        the body. Answers the stored row.

        - With `?account=`: a batch of up to 100 `changes` with one `reason`, as
        the Enterprise module sends it. Answers the new matrix of the account
        (category cells, event overrides and the preference history).


        Only `marketing` can be switched off at category level; disabling a
        mandatory category, overriding an event that is not opt-out-able, or a
        `category` that does not match the event answers 400.
      operationId: notificationPreferenceAdminUpsert
      parameters:
        - name: account
          in: query
          description: Account whose matrix changes; switches the body to the batch form.
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              oneOf:
                - $ref: '#/components/schemas/NotificationPreferenceAdminUpsertBody'
                - $ref: '#/components/schemas/NotificationPreferenceAdminChangesBody'
            example:
              account: 6f1c2a9e-4b7d-4e1a-9c3f-2d8b5e7a1c40
              channel: email
              category: marketing
              is_enabled: false
              reason: Customer asked by phone to stop marketing emails
      responses:
        '200':
          description: >-
            Preference stored (single form) or the new matrix of the account
            (batch form)
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    oneOf:
                      - $ref: '#/components/schemas/NotificationPreference'
                      - $ref: >-
                          #/components/schemas/NotificationPreferenceAccountMatrix
                  message:
                    type: string
                  meta:
                    $ref: '#/components/schemas/Meta'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
components:
  schemas:
    NotificationPreferenceAdminUpsertBody:
      type: object
      additionalProperties: false
      description: Single form (no `account` in the query).
      required:
        - account
        - category
        - channel
        - is_enabled
        - reason
      properties:
        account:
          type: string
          format: uuid
        category:
          type: string
          enum:
            - marketing
            - payment
            - security
            - system
            - transactional
        channel:
          type: string
          enum:
            - email
            - in_app
            - live_activity
            - push
            - sms
        is_enabled:
          type: boolean
        notification_event:
          type: string
          format: uuid
          nullable: true
          description: Opt-out-able catalog event of an event × channel override.
        reason:
          type: string
          minLength: 3
          maxLength: 500
          description: Why the admin changes it; recorded in the audit log.
    NotificationPreferenceAdminChangesBody:
      type: object
      additionalProperties: false
      description: Batch form (`?account=`).
      required:
        - changes
        - reason
      properties:
        changes:
          type: array
          minItems: 1
          maxItems: 100
          items:
            type: object
            additionalProperties: false
            required:
              - channel
              - is_enabled
            properties:
              category:
                type: string
                description: >-
                  Required for a category cell; defaults to the event's category
                  for an override.
                enum:
                  - marketing
                  - payment
                  - security
                  - system
                  - transactional
              channel:
                type: string
                enum:
                  - email
                  - in_app
                  - live_activity
                  - push
                  - sms
              is_enabled:
                type: boolean
              notification_event:
                type: string
                format: uuid
                nullable: true
              event:
                type: string
                format: uuid
                nullable: true
                description: Alias of `notification_event`.
        reason:
          type: string
          minLength: 3
          maxLength: 500
    NotificationPreference:
      type: object
      properties:
        document_id:
          type: string
          format: uuid
        category:
          type: string
          enum:
            - marketing
            - payment
            - system
            - transactional
        channel:
          type: string
          enum:
            - email
            - in_app
            - live_activity
            - push
            - sms
        is_enabled:
          type: boolean
        user:
          type: string
          format: uuid
          description: >-
            Related record id; with `populate` (the default) the related record
            is embedded instead.
        is_actived:
          type: boolean
        is_deleted:
          type: boolean
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
          nullable: true
        deleted_at:
          type: string
          format: date-time
          nullable: true
    NotificationPreferenceAccountMatrix:
      type: object
      properties:
        account:
          type: string
          format: uuid
        cells:
          type: array
          description: Category × channel cells.
          items:
            $ref: '#/components/schemas/NotificationPreferenceMatrixEntry'
        events:
          type: array
          description: Event × channel overrides.
          items:
            type: object
            properties:
              notification_event:
                type: string
                format: uuid
              event:
                type: string
                format: uuid
              event_key:
                type: string
              event_name:
                type: string
              category:
                type: string
              channel:
                type: string
              is_enabled:
                type: boolean
        history:
          type: array
          description: >-
            Audit entries of the account's preferences, with actor, before /
            after and reason.
          items:
            type: object
            additionalProperties: true
    Meta:
      type: object
      properties:
        correlation:
          type: string
          description: Request correlation id; quote it when reporting an issue.
        status:
          type: integer
        timestamp:
          type: string
          format: date-time
        version:
          type: string
          nullable: true
    NotificationPreferenceMatrixEntry:
      type: object
      properties:
        category:
          type: string
          enum:
            - marketing
            - payment
            - system
            - transactional
        channel:
          type: string
          enum:
            - email
            - in_app
            - live_activity
            - push
            - sms
        is_enabled:
          type: boolean
          description: 'Effective state: true unless an override disables it.'
        suppressible:
          type: boolean
          description: Whether the user may opt out of this category.
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              description: Machine-readable error code.
            errors:
              type: array
              items: {}
            message:
              type: string
        meta:
          $ref: '#/components/schemas/Meta'
  responses:
    BadRequest:
      description: Validation error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: Missing, invalid, revoked or expired credentials
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Forbidden:
      description: The caller lacks the required permission
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    TooManyRequests:
      description: Rate limit exceeded
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
      headers:
        Retry-After:
          description: Seconds until a request is allowed again.
          schema:
            type: integer
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: A `secret` API key, `hzk_<env>_<prefix>_<secret>`.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.