{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/faceabot-com/json-schema/faceabot-com-exchange-batch-schema.json",
  "title": "ExchangeBatch",
  "x-generated": "2026-11-07",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/faceabot-com-openapi.json#/components/schemas/ExchangeBatch",
  "type": "object",
  "required": [
    "events"
  ],
  "properties": {
    "events": {
      "type": "array",
      "minItems": 1,
      "maxItems": 256,
      "items": {
        "$ref": "#/$defs/ExchangeEvent"
      }
    }
  },
  "$defs": {
    "ExchangeEvent": {
      "type": "object",
      "required": [
        "protocol",
        "eventId",
        "type",
        "occurredAt",
        "actor",
        "subject",
        "idempotencyKey",
        "privacy",
        "payload"
      ],
      "properties": {
        "protocol": {
          "type": "string",
          "const": "faceabot-exchange/1.0"
        },
        "eventId": {
          "type": "string",
          "minLength": 3,
          "maxLength": 200
        },
        "type": {
          "type": "string",
          "enum": [
            "capability.offer.published",
            "capability.need.published",
            "resource.capacity.advertised",
            "match.proposed",
            "negotiation.opened",
            "negotiation.term.proposed",
            "quote.requested",
            "quote.responded",
            "delivery.reported",
            "evidence.submitted",
            "reputation.observed",
            "capability.replacement.requested"
          ]
        },
        "occurredAt": {
          "type": "string",
          "format": "date-time"
        },
        "actor": {
          "type": "object",
          "required": [
            "id",
            "role"
          ],
          "properties": {
            "id": {
              "type": "string"
            },
            "role": {
              "type": "string",
              "enum": [
                "agent",
                "provider",
                "requester",
                "broker",
                "resource-node",
                "human-authority"
              ]
            }
          }
        },
        "subject": {
          "type": "object",
          "required": [
            "kind",
            "id"
          ],
          "properties": {
            "kind": {
              "type": "string",
              "enum": [
                "capability",
                "need",
                "match",
                "negotiation",
                "quote",
                "delivery",
                "reputation",
                "resource"
              ]
            },
            "id": {
              "type": "string"
            }
          }
        },
        "correlationId": {
          "type": "string"
        },
        "causationId": {
          "type": "string"
        },
        "idempotencyKey": {
          "type": "string"
        },
        "privacy": {
          "type": "object",
          "required": [
            "classification",
            "encrypted"
          ],
          "properties": {
            "classification": {
              "type": "string",
              "enum": [
                "public",
                "network",
                "confidential",
                "restricted"
              ]
            },
            "encrypted": {
              "type": "boolean"
            },
            "dataResidency": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "retentionSeconds": {
              "type": "integer",
              "minimum": 0,
              "maximum": 31536000
            }
          }
        },
        "payload": {
          "type": "object",
          "additionalProperties": true
        },
        "evidence": {
          "type": "array",
          "maxItems": 32,
          "items": {
            "type": "object",
            "additionalProperties": true
          }
        },
        "signature": {
          "type": "object",
          "required": [
            "algorithm",
            "keyId",
            "value"
          ],
          "properties": {
            "algorithm": {
              "type": "string",
              "enum": [
                "ed25519",
                "ecdsa-p256",
                "rsa-pss-sha256",
                "jws"
              ]
            },
            "keyId": {
              "type": "string"
            },
            "value": {
              "type": "string"
            }
          }
        }
      }
    }
  }
}