{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/sealgate-ai/json-schema/sealgate-ai-approval-request-schema.json",
  "title": "ApprovalRequest",
  "description": "A gated approval request derived from a blocked session action.",
  "x-generated": "2026-10-30",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/sealgate-ai-management-openapi.json#/components/schemas/ApprovalRequest",
  "type": "object",
  "properties": {
    "id": {
      "type": "integer",
      "description": "Approval request ID"
    },
    "session_id": {
      "type": "string",
      "description": "Session that triggered the approval request"
    },
    "tool_name": {
      "type": "string",
      "description": "Name of the tool requesting approval"
    },
    "tool_params": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": true,
      "description": "Parameters passed to the tool"
    },
    "user_id": {
      "type": "string"
    },
    "user_email": {
      "type": [
        "string",
        "null"
      ]
    },
    "agent_name": {
      "type": [
        "string",
        "null"
      ]
    },
    "trifecta_flags": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "risk": {
      "oneOf": [
        {
          "$ref": "#/$defs/RiskInfo"
        },
        {
          "type": "null"
        }
      ]
    },
    "reason": {
      "type": [
        "string",
        "null"
      ],
      "description": "What held the call: 'trifecta'/'trifecta_prevent' or 'policy_approval'"
    },
    "policy_rule": {
      "type": [
        "string",
        "null"
      ]
    },
    "status": {
      "type": "string",
      "description": "Approval status: pending, approved, denied"
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    }
  },
  "required": [
    "id",
    "session_id",
    "tool_name",
    "user_id",
    "trifecta_flags",
    "status",
    "created_at"
  ],
  "$defs": {
    "RiskInfo": {
      "type": "object",
      "description": "Plain-language risk explanation for a blocked action.",
      "properties": {
        "title": {
          "type": "string"
        },
        "headline": {
          "type": "string"
        },
        "summary": {
          "type": "string"
        },
        "legs": {
          "type": [
            "object",
            "null"
          ],
          "additionalProperties": {
            "type": "string"
          },
          "description": "Trifecta legs (private/untrusted/external) with their sources"
        },
        "server_name": {
          "type": "string"
        },
        "acl_level": {
          "type": "string"
        },
        "risk_level": {
          "type": [
            "string",
            "null"
          ],
          "description": "Severity: low, medium, high, or critical"
        },
        "policy_rule": {
          "type": [
            "string",
            "null"
          ]
        },
        "source": {
          "type": "string",
          "default": "template",
          "description": "How the summary was produced: template or llm"
        }
      }
    }
  }
}