---
openapi: 3.0.3
info:
  title: Braze REST API – Create SDK Authentication key
  description: |
    ## Prerequisites

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

    ## Rate limit

    This endpoint has a rate limit of 100 requests per day per workspace, shared between all SDK Authentication endpoints and `GET /app_group/apps`. Requests count toward the limit even when they fail validation. For more information, see [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:
  "/app_group/sdk_authentication/create":
    post:
      summary: Create SDK Authentication key
      operationId: post_app_group_sdk_authentication_create_post_create_sdk_authentication_key
      description: |
        ## Validation rules

        This endpoint has the following validation rules:

        - You can have up to 3 SDK Authentication keys per app.
        - The RSA public key string must be a valid RSA public key in the proper format.
        - The `app_id` must be a valid app API identifier.
        - The description can't be empty or contain only whitespace.
      requestBody:
        required: true
        description: The following sample request shows an example of how to create SDK Authentication key.
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateSdkAuthenticationKeyRequest'
            examples:
              example_request:
                summary: Create an SDK Authentication key
                value:
                  app_id: 01234567-89ab-cdef-0123-456789abcdef
                  rsa_public_key_str: "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvvD+fgA0YuCUd/v35htn...\n-----END PUBLIC KEY-----"
                  description: SDK Authentication Key for iOS App
                  make_primary: false
              request_body_template:
                summary: Request body template
                value:
                  app_id: App API identifier
                  rsa_public_key_str: RSA public key string
                  description: description
                  make_primary: false
      responses:
        "201":
          description: |
            The request succeeded and the SDK Authentication key was created. No action needed.

            The following sample response shows an example of the response returned when you create SDK Authentication key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateSdkAuthenticationKeyResponse'
              examples:
                success:
                  summary: Key created
                  value:
                    id: 65a1f0c2e4b0a1b2c3d4e5f8
        "400":
          description: |
            Bad request. To resolve it:

            - **The `app_id` is missing or isn't a valid app API identifier for this workspace:** Pass a valid `app_id` from the [API Keys page]({{site.baseurl}}/user_guide/administer/global/workspace_settings/apis_and_identifiers/).
            - **The `rsa_public_key_str` is missing:** Include the `rsa_public_key_str` in the request body.
            - **The `rsa_public_key_str` isn't a valid RSA public key:** Pass a valid RSA public key string.
            - **The `description` is missing:** Include a `description` for the key.
            - **The RSA public key already exists for this app:** Use a different RSA public key.
            - **The app already has the maximum number of SDK Authentication keys:** Delete an existing key before creating a new one.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                invalid_app_id:
                  summary: Missing or invalid app_id
                  value:
                    message: 'Missing or invalid required parameter: app_id'
                missing_rsa_public_key_str:
                  summary: Missing rsa_public_key_str
                  value:
                    message: 'Missing required parameter: rsa_public_key_str'
                invalid_rsa_public_key_str:
                  summary: rsa_public_key_str isn't a valid RSA public key
                  value:
                    message: rsa_public_key_str must be an RSA public key
                missing_description:
                  summary: Missing description
                  value:
                    message: 'Missing required parameter: description'
                duplicate_key:
                  summary: RSA public key already exists for this app
                  value:
                    message: rsa_public_key_str already exists for this app
                too_many_keys:
                  summary: Maximum number of keys reached
                  value:
                    message: You have exceeded the maximum number of SDK authentication keys for this app
        "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 `sdk_authentication.create` 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 limit of 100 requests per day shared between the SDK Authentication endpoints and `GET /app_group/apps`. Wait for the limit to reset before retrying. See [API rate limits]({{site.baseurl}}/api/api_limits/).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                rate_limited:
                  summary: Daily rate limit exceeded
                  value:
                    message: You have exceeded your limit of 100 requests per day. 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 `sdk_authentication.create` permission.
        Pass the key as `Authorization: Bearer YOUR_REST_API_KEY`.
  schemas:
    CreateSdkAuthenticationKeyRequest:
      title: Create SDK Authentication key request
      type: object
      required: [app_id, rsa_public_key_str, description]
      properties:
        app_id:
          type: string
          description: The app API identifier.
          example: 01234567-89ab-cdef-0123-456789abcdef
        rsa_public_key_str:
          type: string
          description: The RSA public key string. Must be a valid RSA public key or it will return an error.
          example: "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvvD+fgA0YuCUd/v35htn...\n-----END PUBLIC KEY-----"
        description:
          type: string
          minLength: 1
          pattern: '\S'
          description: Description for the SDK Authentication key. Must contain at least one non-whitespace character.
          example: SDK Authentication Key for iOS App
        make_primary:
          type: boolean
          default: false
          description: If set to `true`, this key will be made the primary SDK Authentication key when it is created.
          example: false
    CreateSdkAuthenticationKeyResponse:
      title: Create SDK Authentication key response
      type: object
      properties:
        id:
          type: string
          description: The ID of the newly created SDK Authentication key, a 24-character hexadecimal string.
          example: 65a1f0c2e4b0a1b2c3d4e5f8
        message:
          type: string
          example: success
    ErrorResponse:
      title: Error
      type: object
      properties:
        message:
          type: string
          description: The error message describing why the request failed.
