{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://zinvyl.example/schemas/purchase-intent-v1.json",
  "title": "Zinvyl Agent Purchase Intent",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "intent_version",
    "intent_id",
    "created_at",
    "offer_id",
    "buyer",
    "authorization",
    "terms_version",
    "maximum_amount",
    "currency",
    "input_manifest",
    "acceptance_test_ids",
    "requested_state"
  ],
  "properties": {
    "$schema": { "type": "string" },
    "intent_version": { "const": "1.1.0" },
    "intent_id": { "type": "string", "pattern": "^pi_[A-Za-z0-9_-]{8,64}$" },
    "created_at": { "type": "string", "format": "date-time" },
    "offer_id": {
      "enum": [
        "zinvyl.freight.workflow-audit.v1",
        "zinvyl.api.workflow-failure-rescue.v1"
      ]
    },
    "terms_version": { "const": "2026-09-18" },
    "maximum_amount": { "type": "integer", "minimum": 1 },
    "currency": { "const": "usd" },
    "buyer": {
      "type": "object",
      "additionalProperties": false,
      "required": ["organization", "contact_name", "contact_email", "budget_authority_confirmed"],
      "properties": {
        "organization": { "type": "string", "minLength": 1 },
        "contact_name": { "type": "string", "minLength": 1 },
        "contact_email": { "type": "string", "format": "email" },
        "budget_authority_confirmed": { "const": true }
      }
    },
    "authorization": {
      "type": "object",
      "additionalProperties": false,
      "required": ["authority_type", "owns_or_controls_inputs", "non_production_only", "no_secrets_in_payload", "funding_method", "terms_accepted"],
      "properties": {
        "authority_type": { "enum": ["authorized_representative", "authorized_agent_with_delegated_authority"] },
        "owns_or_controls_inputs": { "const": true },
        "non_production_only": { "const": true },
        "no_secrets_in_payload": { "const": true },
        "funding_method": { "enum": ["stripe_hosted_card", "stripe_hosted_ach"] },
        "terms_accepted": { "const": true }
      }
    },
    "input_manifest": {
      "type": "object",
      "minProperties": 1,
      "additionalProperties": {
        "type": ["string", "number", "integer", "boolean", "array", "object", "null"]
      }
    },
    "acceptance_test_ids": {
      "type": "array",
      "minItems": 1,
      "uniqueItems": true,
      "items": { "type": "string", "pattern": "^[a-z0-9][a-z0-9._-]+$" }
    },
    "requested_state": { "const": "discovered" },
    "buyer_note": { "type": "string", "maxLength": 2000 }
  }
}
