{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://rctp.dev/schemas/decision.schema.json",
  "title": "RCTP decision",
  "description": "The parsed form of the RCTP-Decision header (RFC 9651 Token with parameters; Draft 0.5 8.2), as returned by the SDKs and carried in MCP structuredContent.decision.",
  "type": "object",
  "properties": {
    "decision": {
      "$ref": "common.schema.json#/$defs/Tier"
    },
    "status": {
      "type": "integer",
      "enum": [
        200,
        201,
        202,
        401,
        403,
        409,
        422,
        429
      ]
    },
    "action": {
      "$ref": "common.schema.json#/$defs/Action"
    },
    "reason": {
      "$ref": "common.schema.json#/$defs/Reason"
    },
    "retry_after": {
      "type": "integer",
      "minimum": 0
    },
    "approval_id": {
      "$ref": "common.schema.json#/$defs/ApprovalId"
    },
    "expires_in": {
      "type": "integer",
      "minimum": 0
    },
    "on_timeout": {
      "const": "deny"
    }
  },
  "additionalProperties": false,
  "required": [
    "decision"
  ],
  "allOf": [
    {
      "if": {
        "properties": {
          "decision": {
            "const": "forbid"
          }
        }
      },
      "then": {
        "required": [
          "reason"
        ]
      }
    },
    {
      "if": {
        "properties": {
          "decision": {
            "const": "ask"
          }
        }
      },
      "then": {
        "required": [
          "approval_id",
          "expires_in",
          "on_timeout"
        ]
      }
    }
  ]
}
