{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://agentweb.us/.well-known/payment-authority.schema.json",
  "title": "AgentWeb Payment Authority",
  "description": "A scoped authority artifact that lets an agent request paid AgentWeb setup or execution without receiving raw payment credentials.",
  "type": "object",
  "required": [
    "authority_id",
    "principal",
    "scope",
    "amount_limit",
    "currency",
    "expires_at",
    "revocation_url",
    "receipt_required",
    "verification_required",
    "created_at"
  ],
  "properties": {
    "authority_id": { "type": "string" },
    "principal": {
      "type": "object",
      "required": ["type"],
      "properties": {
        "type": {
          "type": "string",
          "enum": ["user", "business", "agent", "enterprise_account"]
        },
        "id": { "type": "string" },
        "agent_provider": { "type": "string" },
        "authority_reference": { "type": "string" }
      },
      "additionalProperties": false
    },
    "scope": {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "scan.public_site",
          "price.setup",
          "create.checkout_session",
          "create.setup_session",
          "generate.action_map_draft",
          "verify.install",
          "execute.approved_action"
        ]
      },
      "minItems": 1
    },
    "amount_limit": {
      "type": "object",
      "required": ["value"],
      "description": "Maximum spend approved for the scoped AgentWeb task. Value is expressed in the smallest currency unit, such as cents for USD.",
      "properties": {
        "value": { "type": "integer", "minimum": 1 },
        "interval": {
          "type": "string",
          "enum": ["single_use", "daily", "monthly", "setup_session"]
        }
      },
      "additionalProperties": false
    },
    "currency": { "type": "string", "minLength": 3, "maxLength": 3 },
    "expires_at": { "type": "string", "format": "date-time" },
    "revocation_url": { "type": "string", "format": "uri" },
    "receipt_required": { "type": "boolean", "default": true },
    "verification_required": { "type": "boolean", "default": true },
    "created_at": { "type": "string", "format": "date-time" }
  },
  "additionalProperties": false
}
