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

# Rotate an API key

> Issues a new key with the same scopes and name, then invalidates the old one. Returns the new plaintext key **once**.



## OpenAPI

````yaml /api-reference/openapi.json post /v1/api-keys/{id}/rotate
openapi: 3.1.0
info:
  title: Sly API
  description: >-
    The Agentic Economy Platform — stablecoin payments, agent wallets,
    multi-protocol commerce, and AI agent orchestration.
  version: 1.0.0
  contact:
    name: Sly
    url: https://getsly.ai
    email: support@getsly.ai
servers:
  - url: https://api.getsly.ai/v1
    description: Production
  - url: https://sandbox.getsly.ai/v1
    description: Sandbox
security:
  - bearerAuth: []
paths:
  /v1/api-keys/{id}/rotate:
    post:
      tags:
        - API Keys
      summary: Rotate an API key
      description: >-
        Issues a new key with the same scopes and name, then invalidates the old
        one. Returns the new plaintext key **once**.
      parameters:
        - schema:
            type: string
            format: uuid
          required: true
          name: id
          in: path
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                strategy:
                  type: string
                  enum:
                    - immediate
                    - overlap
                  default: immediate
                overlap_seconds:
                  type: integer
                  exclusiveMinimum: 0
                  maximum: 86400
                  default: 300
      responses:
        '200':
          description: Rotated
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/ApiKeyWithSecret'
                required:
                  - data
        '404':
          description: Not found
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/Error'
                  - properties:
                      error:
                        type: string
                      code:
                        type: string
                      details: {}
      security:
        - bearerAuth: []
components:
  schemas:
    ApiKeyWithSecret:
      allOf:
        - $ref: '#/components/schemas/ApiKey'
        - type: object
          properties:
            key:
              type: string
              description: pk_test_* or pk_live_* — shown ONCE
            warning:
              type: string
          required:
            - key
            - warning
    Error:
      type: object
      properties:
        error:
          type: string
        code:
          type: string
        details: {}
        request_id:
          type: string
      required:
        - error
    ApiKey:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        prefix:
          type: string
          description: First 12 chars of the key — safe to display
        environment:
          type: string
          enum:
            - test
            - live
        scopes:
          type: array
          items:
            type: string
        last_used_at:
          type:
            - string
            - 'null'
          format: date-time
        created_at:
          type: string
          format: date-time
        revoked_at:
          type:
            - string
            - 'null'
          format: date-time
      required:
        - id
        - name
        - prefix
        - environment
        - scopes
        - created_at
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        API key (pk_test_* or pk_live_*), JWT session, agent token (agent_*),
        Ed25519 session (sess_*), or portal token (portal_*).

````