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

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

    ## Rate limit

    This endpoint has a rate limit of 1,000 requests per minute, per workspace, as documented in [API rate limits]({{site.baseurl}}/api/api_limits/). This rate limit is fixed and is not configurable.
  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}/url/{userID}":
    get:
      summary: Generate preference center URL
      operationId: get_preference_center_v1_preferencecenterexternalid_url_userid_get_create_url_preference_center
      parameters:
        - name: preferenceCenterExternalID
          in: path
          required: true
          description: The ID for your preference center. This is the preference center's `preference_center_api_id`.
          schema:
            type: string
          example: preference_center_external_id
        - name: userID
          in: path
          required: true
          description: The user ID. This is the external ID for a user (`external_id`).
          schema:
            type: string
          example: user_external_id
      responses:
        "200":
          description: The request succeeded and the response body includes the generated Preference Center URL. No action needed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateUrlPreferenceCenterResponse'
              examples:
                success:
                  summary: Preference center URL
                  value:
                    preference_center_url: https://www.example.com/preferences
        "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: …`).
            - **No user matches the `userID`:** Pass the `external_id` of an existing user.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                user_not_found:
                  summary: User not found
                  value:
                    error: '400 Bad request. Details: User could not be found.'
        "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.user.get` 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.user.get` permission.
        Pass the key as `Authorization: Bearer YOUR_REST_API_KEY`.
  schemas:
    CreateUrlPreferenceCenterResponse:
      title: Generate preference center URL response
      type: object
      properties:
        preference_center_url:
          type: string
          description: The preference center URL for this user.
          example: https://www.example.com/preferences
    ErrorResponse:
      title: Error
      type: object
      properties:
        error:
          type: string
          description: The error message describing why the request failed.
