{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/vertesiahq/json-schema/vertesiahq-api-key-schema.json",
  "title": "ApiKey",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/vertesiahq-api-keys-api-openapi.yml#/components/schemas/ApiKey",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "name": {
      "type": "string"
    },
    "type": {
      "$ref": "#/$defs/ApiKeyTypes"
    },
    "role": {
      "$ref": "#/$defs/SystemRoles"
    },
    "maskedValue": {
      "type": "string"
    },
    "can_retrieve_value": {
      "type": "boolean"
    },
    "account": {
      "type": "string"
    },
    "project": {
      "$ref": "#/$defs/ProjectRef"
    },
    "enabled": {
      "type": "boolean"
    },
    "scim_provisioning": {
      "type": "boolean",
      "description": "Organization-wide SCIM provisioning credential. Only account administrators may create or manage these keys. May be enabled by account administrators on existing keys; disable or delete to revoke access."
    },
    "created_by": {
      "type": "string"
    },
    "updated_by": {
      "type": "string"
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "updated_at": {
      "type": "string",
      "format": "date-time"
    },
    "expires_at": {
      "type": "string",
      "format": "date-time"
    },
    "properties": {
      "type": "object",
      "additionalProperties": true,
      "description": "Custom properties for dynamic permission matching (PrincipalSet / $principal. conditions)"
    },
    "clearance": {
      "type": "number",
      "description": "BLP clearance level — the maximum document sensitivity the key can access"
    },
    "compartments": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "description": "Compartments the key belongs to — restricts access to matching documents"
    }
  },
  "required": [
    "id",
    "name",
    "type",
    "role",
    "account",
    "project",
    "enabled",
    "created_by",
    "updated_by",
    "created_at",
    "updated_at"
  ],
  "additionalProperties": false,
  "$defs": {
    "ApiKeyTypes": {
      "type": "string",
      "const": "sk"
    },
    "ProjectRef": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "account": {
          "type": "string"
        },
        "restricted": {
          "type": "boolean",
          "description": "Only set when fetching the list of projects visible to an user which is an org admin or owner. If present and true, it means that the project is not accessible to the user.(even if it visible in listing) If not present or false then the project is accessible to the user."
        }
      },
      "required": [
        "id",
        "name",
        "account"
      ],
      "additionalProperties": false
    },
    "SystemRoles": {
      "type": "string",
      "enum": [
        "owner",
        "admin",
        "app_admin",
        "manager",
        "developer",
        "application",
        "automation",
        "content_processor",
        "consumer",
        "executor",
        "reader",
        "auditor",
        "support",
        "billing",
        "member",
        "app_member",
        "content_superadmin"
      ]
    }
  }
}