{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/honkio-ca/json-schema/honkio-ca-api-key-schema.json",
  "title": "ApiKey",
  "description": "An active (unrevoked) API key, never the key itself. Field names are camelCase here, unlike the rest of the API.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/honkio-ca-auth-api-openapi.yml#/components/schemas/ApiKey",
  "type": "object",
  "additionalProperties": true,
  "required": [
    "id",
    "keyPrefix",
    "mode",
    "label",
    "createdAt",
    "lastUsedAt"
  ],
  "properties": {
    "id": {
      "type": "string"
    },
    "keyPrefix": {
      "type": "string",
      "description": "Non-secret prefix for display and identification."
    },
    "mode": {
      "type": "string",
      "enum": [
        "LIVE",
        "TEST"
      ]
    },
    "label": {
      "type": [
        "string",
        "null"
      ]
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "lastUsedAt": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "defaultDeny": {
      "type": "boolean",
      "description": "Present on GET /v1/accounts/me and /v1/accounts/{id}; absent from the login response."
    },
    "permissions": {
      "$ref": "#/$defs/ApiKeyPermissions"
    },
    "email_domain_ids": {
      "type": [
        "array",
        "null"
      ],
      "items": {
        "type": "string"
      },
      "description": "The email domains this key may send from (ids from /v1/email-domains): null when unrestricted, [] when restricted to none (its domains were deleted). Present on GET /v1/accounts/me and /v1/accounts/{id}; absent from the login response."
    },
    "oauth_grant": {
      "type": "boolean",
      "description": "True when an OAuth connection holds this key: it can be revoked but not rotated (409 CONFLICT, details.reason \"oauth_grant\"). Present on GET /v1/accounts/me and /v1/accounts/{id}; absent from the login response."
    }
  },
  "$defs": {
    "ApiKeyPermissions": {
      "type": "object",
      "description": "Per-resource permissions. Each key is a resource name; value is a string of allowed operation letters: r=read, w=write/create, m=modify/update, d=delete. A missing key denies all access to that resource.",
      "additionalProperties": {
        "type": "string"
      }
    }
  }
}