---
openapi: 3.0.3
info:
  title: Braze REST API – Create new user alias
  description: |
    ## Prerequisites

    To use this endpoint, you'll need an [API key]({{site.baseurl}}/api/basics) with the `users.alias.new` permission.

    ## Rate limit

    We apply a shared rate limit of 20,000 requests per minute to this endpoint. This rate limit is shared with the `/users/delete`, `/users/identify`, `/users/merge`, and `/users/alias/update` endpoints, 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: []
paths:
  /users/alias/new:
    post:
      summary: Create new user alias
      operationId: createUserAlias
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateUserAliasRequest'
            examples:
              identified:
                summary: Add alias for identified user
                value:
                  user_aliases:
                    - external_id: external_identifier
                      alias_name: example_name
                      alias_label: example_label
              alias_only:
                summary: Create alias-only user
                value:
                  user_aliases:
                    - alias_name: anonymous_123
                      alias_label: temporary_id
      responses:
        "201":
          description: |
            The request succeeded and the user aliases were added. No action needed.

            When an alias is skipped because the same `alias_label` and `alias_name` already exist for a user, the response body may still indicate success. See [When the alias label and name already exist](#when-the-alias-label-and-name-already-exist) for details.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AliasResponse'
              examples:
                success:
                  summary: Aliases processed
                  value:
                    aliases_processed: 1
                    message: success
        "400":
          description: |
            Bad request. To resolve it:

            - **The `aliases` value isn't an array:** Pass `aliases` as an array of alias objects.
            - **More than 50 aliases were provided:** Send 50 or fewer aliases per request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                aliases_not_array:
                  summary: The aliases value isn't an array
                  value:
                    message: "'aliases' must be an array"
                too_many_aliases:
                  summary: More than 50 aliases
                  value:
                    message: Max input length exceeded for user aliases.
        "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:
                    message: 'Invalid API key: YOUR_REST_API_KEY'
        "403":
          description: Access denied. The REST API key doesn't have the required permission. Use a REST API key that has the `users.alias.new` permission.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                access_denied:
                  summary: Missing permission
                  value:
                    message: Access Denied
        "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/).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                over_rate_limit:
                  summary: Over rate limit
                  value:
                    message: You have exceeded your limit of 20000 requests per minute. Please contact your account executive to increase your limit. If you do not have their info, you may contact Braze directly at https://www.braze.com/contact/.
        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 `users.alias.new` permission.
        Pass the key as `Authorization: Bearer YOUR_REST_API_KEY`.
  schemas:
    NewUserAlias:
      title: New user alias
      type: object
      required: [alias_name, alias_label]
      properties:
        external_id:
          type: string
          description: Include to add the alias to the existing user with this `external_id`. Omit to create an alias-only user.
          example: external_identifier
        alias_name:
          type: string
          example: example_name
        alias_label:
          type: string
          example: example_label
    CreateUserAliasRequest:
      title: Create user alias request
      type: object
      required: [user_aliases]
      properties:
        user_aliases:
          type: array
          maxItems: 50
          items:
            $ref: '#/components/schemas/NewUserAlias'
          description: |
            Up to 50 alias objects are allowed per request. See [user alias object]({{site.baseurl}}/api/objects_filters/user_alias_object).

            For more information on `alias_name` and `alias_label`, check out our [User Aliases]({{site.baseurl}}/user_guide/data/unification/user_data/user_profile_lifecycle#user-aliases) documentation.
    AliasResponse:
      title: Create user alias response
      type: object
      properties:
        aliases_processed:
          type: integer
          example: 1
        message:
          type: string
          example: success
    ErrorResponse:
      title: Error
      type: object
      properties:
        message:
          type: string
          description: Human-readable error message.
