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

# Get API Key

> Retrieve a single API key by id or hash.

<Note>
  This endpoint requires a management API key. Standard Gateway API keys are not accepted.
</Note>

Returns metadata for one API key in the authenticated workspace. The `{id}` path segment may be either the internal key id or the key hash returned by the API.


## OpenAPI

````yaml GET /keys/{id}
openapi: 3.0.3
info:
  title: AI Stats Gateway API
  description: >-
    A gateway API for accessing various AI models with OpenAI-compatible
    endpoints.
  version: 1.0.0
  contact:
    name: AI Stats
    url: https://docs.ai-stats.phaseo.app
    email: danielbutler500@gmail.com
servers:
  - url: https://api.phaseo.app/v1
security:
  - BearerAuth: []
tags:
  - name: Gateway
    description: Core AI Stats Gateway operations.
paths:
  /keys/{id}:
    get:
      tags:
        - Gateway
      summary: Get a single API key
      description: >-
        Returns metadata for one API key in the authenticated workspace.
        Management API key required.
      operationId: getApiKey
      parameters:
        - name: id
          in: path
          required: true
          description: API key identifier or hash.
          schema:
            type: string
      responses:
        '200':
          description: API key metadata
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiKeyResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: API key not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    ApiKeyResponse:
      type: object
      required:
        - data
      properties:
        data:
          $ref: '#/components/schemas/ApiKey'
      additionalProperties: false
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        ok:
          type: boolean
          example: false
        error:
          oneOf:
            - type: string
            - type: object
              additionalProperties: true
          example: error_type
        message:
          type: string
          example: Human-readable error message
        description:
          type: string
          example: Additional error details.
        generation_id:
          type: string
          example: G-abc123
        status_code:
          type: integer
          example: 502
        error_type:
          type: string
          enum:
            - user
            - system
          example: system
        error_origin:
          type: string
          enum:
            - user
            - gateway
            - upstream
          example: upstream
        reason:
          type: string
          example: all_candidates_failed
        attempt_count:
          type: integer
          example: 2
        failed_providers:
          type: array
          items:
            type: string
          example:
            - google-ai-studio
            - openai
        failed_statuses:
          type: array
          items:
            type: integer
          example:
            - 403
            - 429
        upstream_error:
          $ref: '#/components/schemas/ErrorUpstreamError'
        failure_sample:
          type: array
          items:
            $ref: '#/components/schemas/ErrorFailureSampleItem'
        provider_failure_diagnostics:
          $ref: '#/components/schemas/ErrorProviderFailureDiagnostics'
        routing_diagnostics:
          $ref: '#/components/schemas/ErrorRoutingDiagnostics'
        provider_candidate_diagnostics:
          $ref: '#/components/schemas/ErrorProviderCandidateDiagnostics'
        provider_enablement:
          $ref: '#/components/schemas/ErrorProviderEnablementDiagnostics'
        missing_pricing_providers:
          type: array
          items:
            type: string
        provider_payment_required_provider:
          type: string
          example: openai
        provider_payment_required_support_notice:
          type: string
          example: >-
            Our upstream provider billing appears to be unavailable. If this
            persists, contact support.
        details:
          type: array
          items:
            type: object
            additionalProperties: true
      additionalProperties: true
    ApiKey:
      type: object
      required:
        - id
        - hash
        - workspace_id
        - name
        - label
        - prefix
        - status
        - disabled
        - soft_blocked
        - scopes
        - created_by
        - created_at
        - updated_at
        - last_used_at
        - expires_at
      properties:
        id:
          type: string
          format: uuid
          example: 11111111-1111-4111-8111-111111111111
        hash:
          type: string
          example: a3f5b7c9d8e1f23456789abcdeffedcba9876543210fedcba1234567890abcdef
        workspace_id:
          type: string
          format: uuid
          example: 22222222-2222-4222-8222-222222222222
        name:
          type: string
          nullable: true
          example: Analytics Service Key
        label:
          type: string
          nullable: true
          example: Analytics Service Key
        prefix:
          type: string
          nullable: true
          example: aistats_v1_sk_abcd1234
        status:
          type: string
          nullable: true
          example: active
        disabled:
          type: boolean
          example: false
        soft_blocked:
          type: boolean
          example: false
        scopes:
          $ref: '#/components/schemas/ApiKeyScopeValue'
        created_by:
          type: string
          nullable: true
          example: user_abc123
        created_at:
          type: string
          format: date-time
          nullable: true
          example: '2026-04-28T12:00:00Z'
        updated_at:
          type: string
          format: date-time
          nullable: true
          example: '2026-04-28T12:15:00Z'
        last_used_at:
          type: string
          format: date-time
          nullable: true
          example: '2026-04-28T12:30:00Z'
        expires_at:
          type: string
          format: date-time
          nullable: true
          example: '2027-12-31T23:59:59Z'
      additionalProperties: false
    ErrorUpstreamError:
      type: object
      properties:
        code:
          type: string
          nullable: true
          example: PERMISSION_DENIED
        message:
          type: string
          nullable: true
          example: The caller does not have permission.
        description:
          type: string
          nullable: true
        param:
          type: string
          nullable: true
    ErrorFailureSampleItem:
      type: object
      properties:
        provider:
          type: string
          nullable: true
        type:
          type: string
          nullable: true
        status:
          type: integer
          nullable: true
        upstream_error_code:
          type: string
          nullable: true
        upstream_error_message:
          type: string
          nullable: true
        upstream_error_description:
          type: string
          nullable: true
        upstream_error_param:
          type: string
          nullable: true
        upstream_payload_preview:
          type: string
          nullable: true
        retryable:
          type: boolean
          nullable: true
      additionalProperties: true
    ErrorProviderFailureDiagnostics:
      type: object
      properties:
        category:
          type: string
          enum:
            - credentials_not_configured
            - credentials_invalid_or_forbidden
            - provider_access_missing
            - region_or_project_restriction
            - model_unavailable_for_endpoint
            - rate_limited
            - server_error
        hint:
          type: string
        provider:
          type: string
          nullable: true
    ErrorRoutingDiagnostics:
      type: object
      properties:
        filterStages:
          type: array
          items:
            type: object
            properties:
              stage:
                type: string
              beforeCount:
                type: integer
              afterCount:
                type: integer
              droppedProviders:
                type: array
                items:
                  type: object
                  properties:
                    providerId:
                      type: string
                      nullable: true
                    reason:
                      type: string
                      nullable: true
                  additionalProperties: true
            additionalProperties: true
      additionalProperties: true
    ErrorProviderCandidateDiagnostics:
      type: object
      properties:
        totalProviders:
          type: integer
        supportsEndpointCount:
          type: integer
        candidateCount:
          type: integer
        droppedUnsupportedEndpoint:
          type: array
          items:
            type: string
        droppedMissingAdapter:
          type: array
          items:
            type: object
            properties:
              providerId:
                type: string
                nullable: true
              endpoint:
                type: string
                nullable: true
            additionalProperties: true
      additionalProperties: true
    ErrorProviderEnablementDiagnostics:
      type: object
      properties:
        capability:
          type: string
        providersBefore:
          type: array
          items:
            type: string
        providersAfter:
          type: array
          items:
            type: string
        dropped:
          type: array
          items:
            type: object
            properties:
              providerId:
                type: string
                nullable: true
              reason:
                type: string
                nullable: true
            additionalProperties: true
      additionalProperties: true
    ApiKeyScopeValue:
      oneOf:
        - type: string
          example: '["chat.completions","responses"]'
        - type: array
          items:
            type: string
          example:
            - chat.completions
            - responses
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: Bearer token authentication

````