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

# Rotate Agent Credential

> Revoke the current credential and issue a new one.



## OpenAPI

````yaml /api-reference/openapi-developer.json post /api/v1/agent/{agent_id}/rotate-credential
openapi: 3.1.0
info:
  title: PromptGuard Developer API
  description: >-
    Public API for developers to integrate PromptGuard security into their
    applications
  version: 1.0.0
servers:
  - url: https://api.promptguard.dev
    description: Production API
  - url: https://staging-api.promptguard.dev
    description: Staging API
  - url: http://localhost:8080
    description: Local Development
security:
  - ApiKeyAuth: []
paths:
  /api/v1/agent/{agent_id}/rotate-credential:
    post:
      tags:
        - agent
      summary: Rotate Agent Credential
      description: Revoke the current credential and issue a new one.
      operationId: rotate_agent_credential_api_v1_agent__agent_id__rotate_credential_post
      parameters:
        - name: agent_id
          in: path
          required: true
          schema:
            type: string
            title: Agent Id
        - name: x-api-key
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: X-Api-Key
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentRotateResponse'
        '401':
          description: Missing or invalid API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuthErrorEnvelope'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
        '429':
          description: Monthly quota exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/QuotaErrorEnvelope'
components:
  schemas:
    AgentRotateResponse:
      properties:
        agent_id:
          type: string
          title: Agent Id
        new_secret:
          type: string
          title: New Secret
        credential_prefix:
          type: string
          title: Credential Prefix
        old_credential_revoked:
          type: boolean
          title: Old Credential Revoked
      type: object
      required:
        - agent_id
        - new_secret
        - credential_prefix
        - old_credential_revoked
      title: AgentRotateResponse
      description: Response from credential rotation.
    AuthErrorEnvelope:
      properties:
        error:
          $ref: '#/components/schemas/ErrorDetail'
          examples:
            - code: missing_api_key
              message: >-
                PromptGuard API key required. Please provide via X-API-Key
                header.
              type: authentication_error
      type: object
      required:
        - error
      title: AuthErrorEnvelope
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    QuotaErrorEnvelope:
      properties:
        error:
          $ref: '#/components/schemas/QuotaErrorDetail'
      type: object
      required:
        - error
      title: QuotaErrorEnvelope
    ErrorDetail:
      properties:
        message:
          type: string
          title: Message
          description: Human-readable error description
        type:
          type: string
          title: Type
          description: Error category, e.g. 'authentication_error'
        code:
          type: string
          title: Code
          description: Machine-readable error code
      type: object
      required:
        - message
        - type
        - code
      title: ErrorDetail
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    QuotaErrorDetail:
      properties:
        message:
          type: string
          title: Message
        type:
          type: string
          title: Type
          description: '''quota_exceeded'' or ''spending_limit_exceeded'''
        code:
          type: string
          title: Code
          description: '''monthly_quota_exceeded'' or ''spending_limit_exceeded'''
        current_plan:
          type: string
          title: Current Plan
        requests_used:
          type: integer
          title: Requests Used
        requests_limit:
          type: integer
          title: Requests Limit
        upgrade_url:
          type: string
          title: Upgrade Url
        retry_after:
          anyOf:
            - type: integer
            - type: 'null'
          title: Retry After
      type: object
      required:
        - message
        - type
        - code
        - current_plan
        - requests_used
        - requests_limit
        - upgrade_url
      title: QuotaErrorDetail
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: >-
        PromptGuard API key for developer endpoints. Keys start with pg_live_
        and are created in the dashboard.

````