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

# Rotate Api Key

> Atomically rotate an API key: deactivate the old key and issue a new one.

The new key inherits the old key's name, scopes, and expiry policy.
The old key is deactivated (not deleted) for audit trail purposes.
The full new key is returned only once, store it securely.



## OpenAPI

````yaml /api-reference/openapi.json post /api/api-keys/{key_id}/rotate
openapi: 3.1.0
info:
  title: Blindsight API
  version: 0.1.0
  description: >-
    The full Blindsight REST surface, generated from the running application.
    Replace the server host with your own deployment.


    For the Runtime Security integration surface (scan, proxy, tool calls) see
    the Runtime Security spec, which is hand written and carries worked
    examples.
servers:
  - url: https://api.your-blindsight.com
    description: Your Blindsight deployment
security: []
paths:
  /api/api-keys/{key_id}/rotate:
    post:
      tags:
        - api-keys
      summary: Rotate Api Key
      description: >-
        Atomically rotate an API key: deactivate the old key and issue a new
        one.


        The new key inherits the old key's name, scopes, and expiry policy.

        The old key is deactivated (not deleted) for audit trail purposes.

        The full new key is returned only once, store it securely.
      operationId: rotate_api_key_api_api_keys__key_id__rotate_post
      parameters:
        - name: key_id
          in: path
          required: true
          schema:
            type: integer
            title: Key Id
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiKeyCreateResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    ApiKeyCreateResponse:
      properties:
        id:
          type: integer
          title: Id
        uuid:
          type: string
          title: Uuid
        name:
          type: string
          title: Name
        key:
          type: string
          title: Key
        key_preview:
          type: string
          title: Key Preview
        scopes:
          items:
            type: string
          type: array
          title: Scopes
        allowed_app_uuids:
          items:
            type: string
          type: array
          title: Allowed App Uuids
        expires_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Expires At
        created_at:
          type: string
          format: date-time
          title: Created At
      type: object
      required:
        - id
        - uuid
        - name
        - key
        - key_preview
        - scopes
        - created_at
      title: ApiKeyCreateResponse
      description: >-
        Response when creating an API key - includes the full key (shown only
        once).
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````