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

# Revoke Key

> Revoke one of the caller's keys.

The row is kept and stamped with ``revoked_at`` rather than deleted, so the
audit trail still records that the key existed and when it stopped working.

Raises:
    HTTPException 404: If the key does not exist or belongs to someone else.
                       The two cases are deliberately indistinguishable.



## OpenAPI

````yaml /openapi.json delete /api/keys/{key_id}
openapi: 3.1.0
info:
  title: HAI-Co² API
  description: Human-AI Co-Construction reference implementation.
  version: 0.1.0
servers:
  - url: https://haico.gr
    description: Production
  - url: https://dev.haico.gr
    description: Development
  - url: http://localhost:8000
    description: Local development
security: []
paths:
  /api/keys/{key_id}:
    delete:
      tags:
        - API Keys
      summary: Revoke Key
      description: >-
        Revoke one of the caller's keys.


        The row is kept and stamped with ``revoked_at`` rather than deleted, so
        the

        audit trail still records that the key existed and when it stopped
        working.


        Raises:
            HTTPException 404: If the key does not exist or belongs to someone else.
                               The two cases are deliberately indistinguishable.
      operationId: revoke_key_api_keys__key_id__delete
      parameters:
        - name: key_id
          in: path
          required: true
          schema:
            type: integer
            title: Key Id
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiKeySchema'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    ApiKeySchema:
      properties:
        id:
          type: integer
          title: Id
        name:
          type: string
          title: Name
        key_prefix:
          type: string
          title: Key Prefix
        last_four:
          type: string
          title: Last Four
        scopes:
          type: string
          title: Scopes
        created_at:
          type: string
          format: date-time
          title: Created At
        last_used_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Last Used At
        expires_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Expires At
        revoked_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Revoked At
        active:
          type: boolean
          title: Active
      type: object
      required:
        - id
        - name
        - key_prefix
        - last_four
        - scopes
        - created_at
        - active
      title: ApiKeySchema
      description: A key's non-secret metadata. The plaintext is never included here.
    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
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      description: >-
        A personal access token (`haico_pat_...`), created under Profile → API
        keys. Send it as `Authorization: Bearer <key>`. The browser session JWT
        is also accepted but is an internal mechanism and is not part of the
        public contract.
      scheme: bearer

````