{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/commsharbor/json-schema/commsharbor-api-key-schema.json",
  "title": "ApiKey",
  "description": "A scoped machine credential. It determines its own organization and rejects a conflicting header.",
  "x-generated": "2026-11-09",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/commsharbor-organizations-api-openapi.yml#/components/schemas/ApiKey",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "description": "API key ID, used to revoke it."
    },
    "name": {
      "type": "string",
      "description": "Label chosen at creation."
    },
    "scopes": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "What this key may do, e.g. `crm:read`, `messages:send`."
    },
    "prefix": {
      "type": "string",
      "description": "Token prefix, so a key can be recognised in a list."
    },
    "last_used_at": {
      "type": [
        "string",
        "null"
      ],
      "description": "When the key last answered; null if never."
    },
    "revoked_at": {
      "type": [
        "string",
        "null"
      ],
      "description": "When it was revoked; null while it is still valid."
    },
    "created_at": {
      "type": "string",
      "description": "Creation time (UTC)."
    },
    "token": {
      "type": "string",
      "description": "The key itself. Present only on the response that created it — it is never shown again."
    }
  },
  "required": [
    "id",
    "name",
    "scopes",
    "prefix",
    "last_used_at",
    "revoked_at",
    "created_at"
  ]
}