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

# Rotate/Regenerate an API Key

> Generates and returns a new secure raw key string for an existing API Key while keeping metadata, scopes, and association unchanged.



## OpenAPI

````yaml /openapi.yaml post /v1/api-keys/{id}/regenerate
openapi: 3.1.0
info:
  title: px0 API
  description: >
    px[0] is an open-source prompt infrastructure toolkit for managing prompts
    in production. It replaces hardcoded prompt strings with versioned
    templates, in-process caching, and OpenTelemetry observability, so teams can
    iterate on prompts without touching application code. This is the OpenAPI
    specification for all the public APIs of px0.
  version: 1.0.0
servers:
  - url: http://localhost:3000
    description: Local development server
security: []
paths:
  /v1/api-keys/{id}/regenerate:
    post:
      tags:
        - API Keys
      summary: Rotate/Regenerate an API Key
      description: >-
        Generates and returns a new secure raw key string for an existing API
        Key while keeping metadata, scopes, and association unchanged.
      operationId: regenerateAPIKey
      parameters:
        - name: id
          in: path
          required: true
          description: The unique UUID of the API Key to regenerate.
          schema:
            type: string
            format: uuid
      responses:
        '200':
          description: API key regenerated successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIKeyCreatedResponse'
        '400':
          description: Invalid request
        '401':
          description: Unauthorized
        '403':
          description: Forbidden
        '404':
          description: API key not found
        '500':
          description: Internal Server Error
      security:
        - BearerAuth: []
components:
  schemas:
    APIKeyCreatedResponse:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: Unique API Key identifier.
        name:
          type: string
          description: Human-readable name of the key.
        key:
          type: string
          description: >-
            The fully generated secure raw API Key string. This is returned ONLY
            ONCE.
          example: ak_7f9ba3271cf881309d9be8c9c0fcae47a95b8d29c3f0b2da8e89cf21e5c3df01
        operation:
          type: string
        created_at:
          type: string
          format: date-time
          description: Timestamp of creation.
      required:
        - id
        - name
        - key
        - operation
        - created_at
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        Use an access token retrieved from login (Bearer sess_...) or a
        programmatic API key (Bearer ak_...).

````