{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://agenticspend.ai/api/policy-schema.json",
  "title": "AgenticSpend AI Agent Payment Policy",
  "description": "A machine-readable policy model for delegated AI-agent spending controls.",
  "type": "object",
  "required": [
    "version",
    "agent",
    "currency",
    "limits",
    "allowed_rails",
    "controls"
  ],
  "properties": {
    "version": {
      "type": "string"
    },
    "agent": {
      "type": "string",
      "minLength": 1
    },
    "currency": {
      "type": "string",
      "pattern": "^[A-Z]{3}$"
    },
    "limits": {
      "type": "object",
      "required": [
        "monthly",
        "daily_auto_pause",
        "per_transaction",
        "human_approval_above"
      ],
      "properties": {
        "monthly": {
          "type": "number",
          "minimum": 0
        },
        "daily_auto_pause": {
          "type": "number",
          "minimum": 0
        },
        "per_transaction": {
          "type": "number",
          "minimum": 0
        },
        "human_approval_above": {
          "type": "number",
          "minimum": 0
        }
      },
      "additionalProperties": false
    },
    "allowed_rails": {
      "type": "array",
      "items": {
        "enum": [
          "Cards",
          "Stablecoins",
          "Bank transfer"
        ]
      },
      "uniqueItems": true
    },
    "allowed_merchant_categories": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "controls": {
      "type": "object",
      "required": [
        "review_first_time_merchants",
        "require_receipt",
        "emergency_kill_switch"
      ],
      "properties": {
        "review_first_time_merchants": {
          "type": "boolean"
        },
        "require_receipt": {
          "type": "boolean"
        },
        "emergency_kill_switch": {
          "type": "boolean"
        }
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": false
}
