{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://docs.caracal.run/schemas/caracal-jwt-claims-2026-05-21.schema.json",
  "title": "Caracal JWT Claims",
  "description": "Registered JWT claims and Caracal authority claims emitted by the STS.",
  "type": "object",
  "required": ["iss", "sub", "aud", "exp", "iat", "jti", "zone_id", "client_id", "sid", "root_sid", "use", "sub_type"],
  "properties": {
    "iss": {
      "type": "string",
      "format": "uri"
    },
    "sub": {
      "type": "string",
      "minLength": 1
    },
    "aud": {
      "oneOf": [
        {
          "type": "string",
          "minLength": 1
        },
        {
          "type": "array",
          "items": {
            "type": "string",
            "minLength": 1
          },
          "minItems": 1,
          "uniqueItems": true
        }
      ]
    },
    "exp": {
      "type": "integer",
      "minimum": 1
    },
    "iat": {
      "type": "integer",
      "minimum": 1
    },
    "jti": {
      "type": "string",
      "minLength": 1
    },
    "zone_id": {
      "type": "string",
      "minLength": 1
    },
    "client_id": {
      "type": "string",
      "minLength": 1
    },
    "scope": {
      "type": "string"
    },
    "sid": {
      "type": "string",
      "minLength": 1,
      "description": "Authority record ID for this STS exchange."
    },
    "root_sid": {
      "type": "string",
      "minLength": 1,
      "description": "Root authority record ID for the STS exchange ancestry."
    },
    "use": {
      "enum": ["session", "gateway", "resource"]
    },
    "sub_type": {
      "enum": ["user", "application"]
    },
    "target": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      },
      "uniqueItems": true
    },
    "agent_session_id": {
      "type": "string",
      "description": "Governed Session ID."
    },
    "delegation_edge_id": {
      "type": "string",
      "description": "Delegation ID."
    },
    "source_session_id": {
      "type": "string",
      "description": "Source governed Session ID for the Delegation."
    },
    "target_session_id": {
      "type": "string",
      "description": "Target governed Session ID for the Delegation."
    },
    "delegation_path": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1
      }
    },
    "delegation_chain": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["application_id"],
        "properties": {
          "application_id": {
            "type": "string",
            "minLength": 1
          },
          "agent_session_id": {
            "type": "string",
            "description": "Governed Session ID for this delegation-chain hop."
          },
          "delegation_edge_id": {
            "type": "string",
            "description": "Delegation ID for this delegation-chain hop."
          }
        },
        "additionalProperties": false
      }
    },
    "hop_count": {
      "type": "integer",
      "minimum": 0
    },
    "delegation_graph_epoch": {
      "type": "integer",
      "minimum": 0
    }
  },
  "additionalProperties": true
}
