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

# Rotate a browser key

> Mints a new key with this key's label. This key stays live until you revoke it, so deploy the new key first and then revoke this one. The new key is in this response only. With 2 live keys there is no room for the new one: revoke the other key first.



## OpenAPI

````yaml /api-reference/openapi.json post /acceptance/browser_keys/{browser_key_id}/rotate
openapi: 3.1.0
info:
  title: baselayer-api-service
  version: 0.1.0
servers:
  - url: https://api.baselayer.com/
security: []
paths:
  /acceptance/browser_keys/{browser_key_id}/rotate:
    post:
      tags:
        - Acceptance
      summary: Rotate a browser key
      description: >-
        Mints a new key with this key's label. This key stays live until you
        revoke it, so deploy the new key first and then revoke this one. The new
        key is in this response only. With 2 live keys there is no room for the
        new one: revoke the other key first.
      operationId: acceptance_browser_keys_rotate
      parameters:
        - name: browser_key_id
          in: path
          required: true
          schema:
            description: The key's id.
            format: uuid
            title: Browser Key Id
            type: string
          description: The key's id.
      responses:
        '201':
          description: The new key, with `browser_key`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/v1.AcceptanceBrowserKeyMinted'
            application/vnd.baselayer.v1+json:
              schema:
                $ref: '#/components/schemas/v1.AcceptanceBrowserKeyMinted'
          headers:
            Location:
              description: The new key.
              schema:
                type: string
        '404':
          description: Your application has no key with this id.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
                title: ResourceNotFound
                description: Could not locate the resource for the given URI.
                examples:
                  - type: resource_not_found
                    code: 1
                    message: Could not locate the resource for the given URI.
                    metadata: {}
        '409':
          description: >-
            The application already has the maximum number of live keys
            (`browser_key_limit_reached`), or this key is revoked
            (`browser_key_revoked`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: The request is invalid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
                title: ValidationFailed
                description: The request is invalid.
                examples:
                  - type: validation_failed
                    code: 7112
                    message: The request is invalid.
                    metadata: {}
      security:
        - APIKeyHeader: []
components:
  schemas:
    v1.AcceptanceBrowserKeyMinted:
      description: 'A key just minted: the only response that carries the key itself.'
      properties:
        browser_key_id:
          description: The key's id.
          format: uuid
          title: Browser Key Id
          type: string
        label:
          description: What the key is for.
          title: Label
          type: string
        environment:
          $ref: '#/components/schemas/v1.ApplicationType'
          description: The application's environment.
        created_at:
          description: When the key was minted.
          format: date-time
          title: Created At
          type: string
        created_by:
          $ref: '#/components/schemas/v1.ActedBy'
          description: Who minted it.
        revoked_at:
          anyOf:
            - format: date-time
              type: string
            - type: 'null'
          default: null
          description: When it was revoked; null while it is live.
          title: Revoked At
        browser_key:
          description: >-
            The key, for baselayer.js's `browserKey`. Shown only in this
            response; Baselayer stores its sha256, so it cannot be shown again.
          title: Browser Key
          type: string
      required:
        - browser_key_id
        - label
        - environment
        - created_at
        - created_by
        - browser_key
      title: AcceptanceBrowserKeyMinted (v1)
      type: object
    Error:
      properties:
        type:
          type: string
          title: Type
          description: >-
            Stable snake_case name of the error. Branch on this, never on
            `message`.
        code:
          type: integer
          title: Code
          description: Integer catalog code of the error.
        message:
          type: string
          title: Message
          description: For a human reading a log; not stable and not localized.
        metadata:
          additionalProperties: true
          type: object
          title: Metadata
          description: Context documented per `type`.
        request_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Request Id
          description: The `X-Request-ID` of the failed request.
      type: object
      required:
        - type
        - code
        - message
      title: Error
      description: The one body of every error a KYA route answers.
    v1.ApplicationType:
      enum:
        - sandbox
        - production
      title: ApplicationType
      type: string
    v1.ActedBy:
      description: |-
        Who acted on a record, as they were named when they acted: the one actor
        shape every route answers.
      properties:
        kind:
          $ref: '#/components/schemas/v1.ActedByKind'
          description: '`USER` for a console user, `API_KEY` for a key.'
        label:
          description: >-
            The user's first and last name or the API key's name, as they were
            when they acted; never rewritten by a later rename or deletion.
          title: Label
          type: string
      required:
        - kind
        - label
      title: ActedBy (v1)
      type: object
    v1.ActedByKind:
      description: 'Who acted on a record: a console user or an API key.'
      enum:
        - USER
        - API_KEY
      title: ActedByKind
      type: string
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: X-API-Key

````

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