{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "/schemas/provenance-profile/v1.json",
  "title": "Provenance discovery profile, format version 1 (working draft)",
  "description": "A business's signed discovery profile: it accepts Provenance approvals, its rules and its selling agents. Verify `signature` (ES256 JWS, typ provenance-profile+jwt) against the issuer's JWKS; its payload's profile_sha256 is the SHA-256 of the canonical JSON of the profile without `signature`.",
  "type": "object",
  "required": ["object", "version", "business", "accepts", "rules", "categories", "selling", "profile_url", "revision", "updated_at", "signature"],
  "properties": {
    "object": { "const": "provenance_profile" },
    "version": { "const": "1" },
    "business": {
      "type": "object",
      "required": ["id", "name", "origins"],
      "properties": {
        "id": { "type": "string", "pattern": "^biz_" },
        "name": { "type": "string", "maxLength": 80 },
        "origins": { "type": "array", "items": { "type": "string", "format": "uri" }, "minItems": 1 }
      }
    },
    "accepts": {
      "type": "object",
      "required": ["approvals", "network_mandates", "rails"],
      "properties": {
        "approvals": { "type": "boolean" },
        "network_mandates": { "type": "boolean" },
        "rails": { "type": "array", "items": { "enum": ["x402", "acp", "ap2", "checkout"] } }
      }
    },
    "rules": {
      "type": "object",
      "required": ["person_required_over", "currency"],
      "properties": {
        "person_required_over": { "type": ["number", "null"], "minimum": 0 },
        "currency": { "type": "string", "pattern": "^[A-Z]{3}$" }
      }
    },
    "categories": { "type": "array", "items": { "type": "string", "pattern": "^[a-z0-9_]{2,40}$" } },
    "selling": {
      "type": "array",
      "items": {
        "type": "object",
        "required": ["agent_id", "name", "kids", "endpoints", "categories", "seller_confirmation"],
        "properties": {
          "agent_id": { "type": "string" },
          "name": { "type": "string" },
          "kids": { "type": "array", "items": { "type": "string" }, "minItems": 1 },
          "origin": { "type": ["string", "null"], "format": "uri" },
          "endpoints": {
            "type": "object",
            "properties": { "a2a": { "type": "string", "format": "uri" }, "mcp": { "type": "string", "format": "uri" }, "offers": { "type": "string", "format": "uri" } },
            "additionalProperties": false
          },
          "categories": { "type": "array", "items": { "type": "string" } },
          "seller_confirmation": {
            "type": "object",
            "required": ["offered", "response_time"],
            "properties": {
              "offered": { "enum": ["never", "on_request", "always"] },
              "min_amount": { "type": "number", "minimum": 0 },
              "response_time": { "enum": ["1h", "4bh", "1bd", "2bd"] }
            }
          }
        }
      }
    },
    "profile_url": { "type": "string", "format": "uri" },
    "directory_url": { "type": "string", "format": "uri" },
    "schema": { "type": "string", "format": "uri" },
    "revision": { "type": "integer", "minimum": 1 },
    "updated_at": { "type": "string", "format": "date-time" },
    "signature": { "type": "string", "pattern": "^[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+$" }
  }
}
