---
openapi: 3.0.3
info:
  title: Braze REST API – Update preference center
  description: |
    ## Prerequisites

    To use this endpoint, you'll need an [API key]({{site.baseurl}}/api/basics#rest-api-key-permissions) with the `preference_center.update` permission.

    ## Rate limit

    This endpoint has a rate limit of 10 requests per minute, per workspace, as documented in [API rate limits]({{site.baseurl}}/api/api_limits/).
  version: 1.0.0
  contact:
    name: Braze Support
    url: https://www.braze.com/docs/braze_support/
  license:
    name: Braze Documentation
    url: https://www.braze.com/docs/api/home/
servers:
  - url: https://rest.iad-01.braze.com
    description: US-01
  - url: https://rest.iad-02.braze.com
    description: US-02
  - url: https://rest.iad-03.braze.com
    description: US-03
  - url: https://rest.iad-04.braze.com
    description: US-04
  - url: https://rest.iad-05.braze.com
    description: US-05
  - url: https://rest.iad-06.braze.com
    description: US-06
  - url: https://rest.iad-07.braze.com
    description: US-07
  - url: https://rest.iad-08.braze.com
    description: US-08
  - url: https://rest.us-10.braze.com
    description: US-10
  - url: https://rest.fra-01.braze.eu
    description: EU-01
  - url: https://rest.fra-02.braze.eu
    description: EU-02
  - url: https://rest.au-01.braze.com
    description: AU-01
  - url: https://rest.id-01.braze.com
    description: ID-01
  - url: https://rest.jp-01.braze.com
    description: JP-01
  - url: https://rest.kr-01.braze.com
    description: KR-01
security:
- BearerAuth: []
# cspell:ignore preferencecenterexternalid
paths:
  "/preference_center/v1/{preferenceCenterExternalID}":
    put:
      summary: Update preference center
      operationId: put_preference_center_v1_preferencecenterexternalid_put_update_preference_center
      parameters:
        - name: preferenceCenterExternalID
          in: path
          required: true
          description: The ID for your preference center.
          schema:
            type: string
          example: preference_center_external_id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdatePreferenceCenterRequest'
            examples:
              example_request:
                summary: Update preference center
                value:
                  name: Example
                  preference_center_title: Example Preference Center Title
                  preference_center_page_html: HTML for preference center here
                  confirmation_page_html: HTML here with a message to users here
                  state: active
      responses:
        "200":
          description: The request succeeded and the Preference Center was updated. No action needed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UpdatePreferenceCenterResponse'
              examples:
                success:
                  summary: Preference center updated
                  value:
                    preference_center_api_id: 8efc52aa-935e-42b7-bd6b-98f43bb9b0f1
                    created_at: "2022-09-22T18:28:07Z"
                    updated_at: "2022-09-22T18:32:07Z"
                    message: success
        "400":
          description: |
            Bad request. To resolve it:

            - **The request is missing a required parameter or violates a constraint:** Correct the request per the details in the error message (`400 Bad request. Details: …`).
            - **The request body doesn't include a field to update:** Include at least one of `preference_center_page_html`, `preference_center_title`, `confirmation_page_html`, `state`, or `options`.
            - **The `state` changes an active preference center to `draft`:** Omit `state`, or set it to `active`. An active preference center can't go back to draft.
            - **The preference center was created with the drag-and-drop editor:** Edit it in the dashboard instead. This endpoint only updates preference centers built with HTML.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                active_to_draft:
                  summary: Active preference center set to draft
                  value:
                    error: '400 Bad request. Details: Cannot change active state to draft.'
                drag_and_drop:
                  summary: Drag-and-drop preference center
                  value:
                    error: '400 Bad request. Details: DND templates cannot be updated through the API.'
        "401":
          description: |
            Unauthorized. The REST API key is missing, malformed, or sent to the wrong REST endpoint. Send the key as `Authorization: Bearer YOUR_REST_API_KEY` to the correct [REST endpoint]({{site.baseurl}}/api/basics/#endpoints). For more causes, see [Errors and responses]({{site.baseurl}}/api/errors/#fatal-errors).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                invalid_api_key:
                  summary: Invalid API key
                  value:
                    error: Error authenticating credentials
        "403":
          description: Access denied. The REST API key doesn't have the required permission. Use a REST API key that has the `preference_center.update` permission.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                access_denied:
                  summary: Missing permission
                  value:
                    error: You do not have permission to access this resource
        "404":
          description: Not found. No Preference Center matches the `preference_center_api_id`. Pass a valid `preference_center_api_id` from the [List preference centers endpoint]({{site.baseurl}}/api/endpoints/preference_center/get_list_preference_center/).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                not_found:
                  summary: Preference center not found
                  value:
                    error: Preference center could not be found.
        "429":
          description: |
            Rate limited. You exceeded the rate limit for this endpoint. Slow your request rate and retry with exponential backoff. See [API rate limits]({{site.baseurl}}/api/api_limits/). The error message says how many seconds to wait before you retry.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                over_rate_limit:
                  summary: Over rate limit
                  value:
                    error: 429 Try again in 30 seconds
        "500":
          description: |
            Internal server error. An unexpected error occurred on the Braze server. Retry with exponential backoff. If the error persists, contact [Support]({{site.baseurl}}/braze_support/).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                internal_server_error:
                  summary: Internal server error
                  value:
                    error: 500 Internal Server Error
        5XX:
          description: |
            Internal server error. An unexpected error occurred on the Braze server. Retry with exponential backoff. If the error persists, contact [Support]({{site.baseurl}}/braze_support/).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: REST API key
      description: |
        REST API keys are created in the Braze dashboard at **Settings → APIs and
        Identifiers → API Keys**. The key must include the `preference_center.update` permission.
        Pass the key as `Authorization: Bearer YOUR_REST_API_KEY`.
  schemas:
    LinkTag:
      title: Link tag
      type: object
      required: [rel, href]
      properties:
        rel:
          type: string
          enum: [icon, shortcut icon, apple-touch-icon]
          description: 'One of: "icon", "shortcut icon", or "apple-touch-icon".'
          example: icon
        type:
          type: string
          enum: [image/png, image/svg, image/gif, image/x-icon, image/svg+xml, mask-icon]
          description: 'Valid values: "image/png", "image/svg", "image/gif", "image/x-icon", "image/svg+xml", "mask-icon".'
          example: image/png
        sizes:
          type: string
        color:
          type: string
          description: Use when type="mask-icon".
        href:
          type: string
          example: https://www.example.com/favicon.png
    PreferenceCenterOptions:
      title: Preference center options
      type: object
      description: |
        Attributes:

        `meta-viewport-content`: When present, a `viewport` meta tag will be added to the page with `content= <value of attribute>`.

        `links-tags`: Set a favicon for the page. When set, a `<link>` tag with a rel attribute is added to the page.

        Each attribute you send replaces that attribute on the preference center. Attributes you omit keep their current values.
      properties:
        meta-viewport-content:
          type: string
          description: Only the `content` value of the meta tag.
          example: width=device-width, initial-scale=2
        links-tags:
          type: array
          items:
            $ref: '#/components/schemas/LinkTag'
    UpdatePreferenceCenterRequest:
      title: Update preference center request
      type: object
      description: Include at least one of `preference_center_page_html`, `preference_center_title`, `confirmation_page_html`, `state`, or `options`.
      properties:
        name:
          type: string
          description: The preference center name can't be edited after it's created, so this endpoint ignores `name`.
          example: preference_center_name
        preference_center_page_html:
          type: string
          description: The HTML for the preference center page.
          example: HTML for preference center here
        preference_center_title:
          type: string
          description: The title for the preference center and confirmation pages. If a title is not specified, the title of the pages will default to "Preference Center".
          example: Example Preference Center Title
        confirmation_page_html:
          type: string
          description: The HTML for the confirmation page.
          example: HTML here with a message to users here
        state:
          type: string
          enum: [active, draft]
          description: |
            Choose `active` or `draft`.

            You can't change an active preference center to `draft`.
          example: active
        options:
          $ref: '#/components/schemas/PreferenceCenterOptions'
    UpdatePreferenceCenterResponse:
      title: Update preference center response
      type: object
      properties:
        preference_center_api_id:
          type: string
          description: The ID for your preference center.
          example: 8efc52aa-935e-42b7-bd6b-98f43bb9b0f1
        created_at:
          type: string
          description: When the preference center was created, in ISO 8601 format.
          example: "2022-09-22T18:28:07Z"
        updated_at:
          type: string
          description: When the preference center was last updated, in ISO 8601 format.
          example: "2022-09-22T18:32:07Z"
        message:
          type: string
          example: success
    ErrorResponse:
      title: Error
      type: object
      properties:
        error:
          type: string
          description: The error message describing why the request failed.
