{
  "asyncapi": "3.0.0",
  "info": {
    "title": "Batch Relay Events V1",
    "version": "1.0.0",
    "description": "Public Batch Relay outbound webhook contract. The live canonical document is https://api.batchrelay.com/asyncapi.json."
  },
  "defaultContentType": "application/cloudevents+json",
  "servers": {
    "webhook": {
      "host": "customer-configured",
      "protocol": "https",
      "description": "Each configured destination receives one CloudEvent per HTTP POST."
    }
  },
  "channels": {
    "destination": {
      "address": "/",
      "messages": {
        "orderCreated": { "$ref": "#/components/messages/orderCreated" },
        "orderPaid": { "$ref": "#/components/messages/orderPaid" },
        "orderPaymentFailed": { "$ref": "#/components/messages/orderPaymentFailed" },
        "orderCanceled": { "$ref": "#/components/messages/orderCanceled" },
        "orderFulfillmentQueued": { "$ref": "#/components/messages/orderFulfillmentQueued" },
        "orderFulfillmentSubmitted": { "$ref": "#/components/messages/orderFulfillmentSubmitted" },
        "orderFulfillmentAccepted": { "$ref": "#/components/messages/orderFulfillmentAccepted" },
        "orderFulfillmentRejected": { "$ref": "#/components/messages/orderFulfillmentRejected" },
        "orderShipped": { "$ref": "#/components/messages/orderShipped" },
        "orderFulfilled": { "$ref": "#/components/messages/orderFulfilled" },
        "orderFulfillmentFailed": { "$ref": "#/components/messages/orderFulfillmentFailed" },
        "catalogItemChanged": { "$ref": "#/components/messages/catalogItemChanged" },
        "packageChanged": { "$ref": "#/components/messages/packageChanged" },
        "catalogBatchCompleted": { "$ref": "#/components/messages/catalogBatchCompleted" },
        "storefrontChanged": { "$ref": "#/components/messages/storefrontChanged" },
        "destinationTest": { "$ref": "#/components/messages/destinationTest" }
      }
    }
  },
  "operations": {
    "deliverEvent": {
      "action": "send",
      "channel": { "$ref": "#/channels/destination" },
      "summary": "Deliver exactly one signed CloudEvents 1.0 structured JSON message by HTTP POST.",
      "bindings": {
        "http": {
          "type": "request",
          "method": "POST",
          "headers": { "$ref": "#/components/schemas/standardWebhookHeaders" },
          "bindingVersion": "0.3.0"
        }
      }
    }
  },
  "components": {
    "messages": {
      "orderCreated": { "name": "order.created.v1", "title": "Order created", "contentType": "application/cloudevents+json", "payload": { "$ref": "#/components/schemas/orderCreatedEvent" }, "x-visibility": "public", "x-required-capabilities": ["events.orders.read"] },
      "orderPaid": { "name": "order.paid.v1", "title": "Order paid", "contentType": "application/cloudevents+json", "payload": { "$ref": "#/components/schemas/orderPaidEvent" }, "x-visibility": "public", "x-required-capabilities": ["events.orders.read"] },
      "orderPaymentFailed": { "name": "order.payment_failed.v1", "title": "Order payment failed", "contentType": "application/cloudevents+json", "payload": { "$ref": "#/components/schemas/orderPaymentFailedEvent" }, "x-visibility": "public", "x-required-capabilities": ["events.orders.read"] },
      "orderCanceled": { "name": "order.canceled.v1", "title": "Order canceled", "contentType": "application/cloudevents+json", "payload": { "$ref": "#/components/schemas/orderCanceledEvent" }, "x-visibility": "public", "x-required-capabilities": ["events.orders.read"] },
      "orderFulfillmentQueued": { "name": "order.fulfillment_queued.v1", "title": "Order fulfillment queued", "contentType": "application/cloudevents+json", "payload": { "$ref": "#/components/schemas/orderFulfillmentQueuedEvent" }, "x-visibility": "public", "x-required-capabilities": ["events.orders.read"] },
      "orderFulfillmentSubmitted": { "name": "order.fulfillment_submitted.v1", "title": "Order fulfillment submitted", "contentType": "application/cloudevents+json", "payload": { "$ref": "#/components/schemas/orderFulfillmentSubmittedEvent" }, "x-visibility": "public", "x-required-capabilities": ["events.orders.read"] },
      "orderFulfillmentAccepted": { "name": "order.fulfillment_accepted.v1", "title": "Order fulfillment accepted", "contentType": "application/cloudevents+json", "payload": { "$ref": "#/components/schemas/orderFulfillmentAcceptedEvent" }, "x-visibility": "public", "x-required-capabilities": ["events.orders.read"] },
      "orderFulfillmentRejected": { "name": "order.fulfillment_rejected.v1", "title": "Order fulfillment rejected", "contentType": "application/cloudevents+json", "payload": { "$ref": "#/components/schemas/orderFulfillmentRejectedEvent" }, "x-visibility": "public", "x-required-capabilities": ["events.orders.read"] },
      "orderShipped": { "name": "order.shipped.v1", "title": "Order shipped", "contentType": "application/cloudevents+json", "payload": { "$ref": "#/components/schemas/orderShippedEvent" }, "x-visibility": "public", "x-required-capabilities": ["events.orders.read"] },
      "orderFulfilled": { "name": "order.fulfilled.v1", "title": "Order fulfilled", "contentType": "application/cloudevents+json", "payload": { "$ref": "#/components/schemas/orderFulfilledEvent" }, "x-visibility": "public", "x-required-capabilities": ["events.orders.read"] },
      "orderFulfillmentFailed": { "name": "order.fulfillment_failed.v1", "title": "Order fulfillment failed", "contentType": "application/cloudevents+json", "payload": { "$ref": "#/components/schemas/orderFulfillmentFailedEvent" }, "x-visibility": "public", "x-required-capabilities": ["events.orders.read"] },
      "catalogItemChanged": { "name": "catalog_item.changed.v1", "title": "Catalog item changed", "contentType": "application/cloudevents+json", "payload": { "$ref": "#/components/schemas/catalogEvent" }, "x-visibility": "public", "x-required-capabilities": ["events.catalog.read"] },
      "packageChanged": { "name": "package.changed.v1", "title": "Package changed", "contentType": "application/cloudevents+json", "payload": { "$ref": "#/components/schemas/packageEvent" }, "x-visibility": "public", "x-required-capabilities": ["events.catalog.read"] },
      "catalogBatchCompleted": { "name": "catalog_batch.completed.v1", "title": "Catalog batch completed", "contentType": "application/cloudevents+json", "payload": { "$ref": "#/components/schemas/catalogBatchEvent" }, "x-visibility": "public", "x-required-capabilities": ["events.catalog.read"] },
      "storefrontChanged": { "name": "storefront.changed.v1", "title": "Storefront changed", "contentType": "application/cloudevents+json", "payload": { "$ref": "#/components/schemas/storefrontEvent" }, "x-visibility": "public", "x-required-capabilities": ["events.catalog.read"] },
      "destinationTest": { "name": "destination.test.v1", "title": "Destination test", "contentType": "application/cloudevents+json", "payload": { "$ref": "#/components/schemas/destinationTestEvent" }, "x-visibility": "public", "x-required-capabilities": ["events.destinations.manage"] }
    },
    "schemas": {
      "standardWebhookHeaders": {
        "type": "object",
        "required": ["webhook-id", "webhook-timestamp", "webhook-signature"],
        "properties": {
          "webhook-id": { "type": "string", "minLength": 1 },
          "webhook-timestamp": { "type": "string", "pattern": "^[0-9]+$" },
          "webhook-signature": { "type": "string", "pattern": "^v1," }
        },
        "additionalProperties": true
      },
      "cloudEvent": {
        "type": "object",
        "required": ["specversion", "id", "source", "type", "subject", "time", "datacontenttype", "dataschema", "tenanttype", "tenantid", "environment", "resourceversion", "origin", "correlationid", "actorkind", "data"],
        "properties": {
          "specversion": { "const": "1.0" },
          "id": { "type": "string", "minLength": 1 },
          "source": { "type": "string", "format": "uri" },
          "type": { "type": "string" },
          "subject": { "type": "string", "pattern": "^[a-z-]+/[A-Za-z0-9_-]+$" },
          "time": { "type": "string", "format": "date-time" },
          "datacontenttype": { "const": "application/json" },
          "dataschema": { "type": "string", "format": "uri" },
          "tenanttype": { "enum": ["studio", "api_account"] },
          "environment": { "enum": ["sandbox", "production"] },
          "origin": { "enum": ["storefront", "developer_api", "system"] },
          "tenantid": { "type": "string", "minLength": 1 },
          "resourceversion": { "type": "integer", "minimum": 1 },
          "correlationid": { "type": "string", "minLength": 1 },
          "causationid": { "type": "string", "minLength": 1 },
          "actorkind": { "enum": ["system", "staff", "api", "provider"] },
          "data": { "type": "object" }
        },
        "additionalProperties": false
      },
      "orderLine": {
        "oneOf": [
          {
            "type": "object",
            "required": ["line_id", "display_name", "quantity", "unit_price_minor_units"],
            "properties": {
              "line_id": { "type": "string", "minLength": 1 },
              "display_name": { "type": "string", "minLength": 1, "maxLength": 256 },
              "quantity": { "type": "integer", "minimum": 1 },
              "unit_price_minor_units": { "type": "integer", "minimum": 0 },
              "canonical_product_id": { "type": "string", "minLength": 1 },
              "catalog_item_id": { "type": "string", "minLength": 1 },
              "package_id": { "type": "string", "minLength": 1 }
            },
            "anyOf": [
              { "required": ["canonical_product_id"] },
              { "required": ["catalog_item_id"] },
              { "required": ["package_id"] }
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "required": ["canonical_product_id", "quantity"],
            "properties": {
              "canonical_product_id": { "type": "string", "minLength": 1 },
              "quantity": { "type": "integer", "minimum": 1 },
              "display_name": { "type": "string", "minLength": 1, "maxLength": 256 }
            },
            "additionalProperties": false
          }
        ]
      },
      "orderCreatedData": {
        "type": "object",
        "required": ["order_id", "status", "currency", "subtotal_minor_units", "discount_minor_units", "shipping_minor_units", "tax_minor_units", "total_minor_units", "lines"],
        "properties": {
          "order_id": { "type": "string", "minLength": 1 },
          "status": { "const": "created" },
          "currency": { "const": "USD" },
          "subtotal_minor_units": { "type": "integer", "minimum": 0 },
          "discount_minor_units": { "type": "integer", "minimum": 0 },
          "shipping_minor_units": { "type": "integer", "minimum": 0 },
          "tax_minor_units": { "type": "integer", "minimum": 0 },
          "total_minor_units": { "type": "integer", "minimum": 0 },
          "lines": { "type": "array", "minItems": 1, "items": { "$ref": "#/components/schemas/orderLine" } }
        },
        "additionalProperties": false
      },
      "orderPaidData": {
        "type": "object",
        "required": ["order_id", "status", "currency", "subtotal_minor_units", "discount_minor_units", "shipping_minor_units", "tax_minor_units", "total_minor_units", "lines"],
        "properties": {
          "order_id": { "type": "string", "minLength": 1 },
          "status": { "const": "paid" },
          "currency": { "const": "USD" },
          "subtotal_minor_units": { "type": "integer", "minimum": 0 },
          "discount_minor_units": { "type": "integer", "minimum": 0 },
          "shipping_minor_units": { "type": "integer", "minimum": 0 },
          "tax_minor_units": { "type": "integer", "minimum": 0 },
          "total_minor_units": { "type": "integer", "minimum": 0 },
          "lines": { "type": "array", "minItems": 1, "items": { "$ref": "#/components/schemas/orderLine" } }
        },
        "additionalProperties": false
      },
      "orderPaymentFailedData": {
        "type": "object",
        "required": ["order_id", "status", "reason_code"],
        "properties": {
          "order_id": { "type": "string", "minLength": 1 },
          "status": { "const": "payment_failed" },
          "reason_code": { "enum": ["insufficient_funds", "payment_declined", "payment_method_required", "payment_not_completed", "unknown"] }
        },
        "additionalProperties": false
      },
      "orderCanceledData": {
        "type": "object",
        "required": ["order_id", "status"],
        "properties": { "order_id": { "type": "string", "minLength": 1 }, "status": { "const": "canceled" } },
        "additionalProperties": false
      },
      "orderFulfillmentQueuedData": {
        "type": "object",
        "required": ["order_id", "status"],
        "properties": { "order_id": { "type": "string", "minLength": 1 }, "status": { "const": "fulfillment_queued" } },
        "additionalProperties": false
      },
      "orderFulfillmentSubmittedData": {
        "type": "object",
        "required": ["order_id", "status"],
        "properties": { "order_id": { "type": "string", "minLength": 1 }, "status": { "const": "fulfillment_submitted" } },
        "additionalProperties": false
      },
      "orderFulfillmentAcceptedData": {
        "type": "object",
        "required": ["order_id", "status"],
        "properties": { "order_id": { "type": "string", "minLength": 1 }, "status": { "const": "fulfillment_accepted" } },
        "additionalProperties": false
      },
      "orderFulfillmentRejectedData": {
        "type": "object",
        "required": ["order_id", "status", "reason_code"],
        "properties": {
          "order_id": { "type": "string", "minLength": 1 },
          "status": { "const": "fulfillment_rejected" },
          "reason_code": { "enum": ["provider_rejected", "provider_hold_nonretryable", "provider_unavailable", "provider_validation_failed", "unknown"] }
        },
        "additionalProperties": false
      },
      "orderShippedData": {
        "type": "object",
        "required": ["order_id", "status"],
        "properties": {
          "order_id": { "type": "string", "minLength": 1 },
          "status": { "const": "shipped" },
          "carrier_code": { "type": "string", "minLength": 1 },
          "carrier_name": { "type": "string", "minLength": 1 },
          "service_level": { "type": "string", "minLength": 1 },
          "tracking_number": { "type": "string", "minLength": 1 },
          "tracking_url": { "type": "string", "format": "uri", "pattern": "^https://" }
        },
        "additionalProperties": false
      },
      "orderFulfilledData": {
        "type": "object",
        "required": ["order_id", "status"],
        "properties": { "order_id": { "type": "string", "minLength": 1 }, "status": { "const": "fulfilled" } },
        "additionalProperties": false
      },
      "orderFulfillmentFailedData": {
        "type": "object",
        "required": ["order_id", "status", "reason_code"],
        "properties": {
          "order_id": { "type": "string", "minLength": 1 },
          "status": { "const": "fulfillment_failed" },
          "reason_code": { "enum": ["approval_or_hold_changed", "dispatch_claim_expired_ambiguous", "dispatch_precondition_failed", "dispatch_retry_exhausted", "fulfillment_failed", "provider_hold_nonretryable", "provider_not_live", "snapshot_not_ready", "unknown"] }
        },
        "additionalProperties": false
      },
      "orderCreatedEvent": {
        "allOf": [
          { "$ref": "#/components/schemas/cloudEvent" },
          { "properties": { "type": { "const": "order.created.v1" }, "subject": { "pattern": "^orders/" }, "dataschema": { "const": "https://api.batchrelay.com/schemas/events/order.created/v1" }, "data": { "$ref": "#/components/schemas/orderCreatedData" } } }
        ]
      },
      "orderPaidEvent": { "allOf": [{ "$ref": "#/components/schemas/cloudEvent" }, { "properties": { "type": { "const": "order.paid.v1" }, "subject": { "pattern": "^orders/" }, "dataschema": { "const": "https://api.batchrelay.com/schemas/events/order.paid/v1" }, "data": { "$ref": "#/components/schemas/orderPaidData" } } }] },
      "orderPaymentFailedEvent": { "allOf": [{ "$ref": "#/components/schemas/cloudEvent" }, { "properties": { "type": { "const": "order.payment_failed.v1" }, "subject": { "pattern": "^orders/" }, "dataschema": { "const": "https://api.batchrelay.com/schemas/events/order.payment_failed/v1" }, "data": { "$ref": "#/components/schemas/orderPaymentFailedData" } } }] },
      "orderCanceledEvent": { "allOf": [{ "$ref": "#/components/schemas/cloudEvent" }, { "properties": { "type": { "const": "order.canceled.v1" }, "subject": { "pattern": "^orders/" }, "dataschema": { "const": "https://api.batchrelay.com/schemas/events/order.canceled/v1" }, "data": { "$ref": "#/components/schemas/orderCanceledData" } } }] },
      "orderFulfillmentQueuedEvent": { "allOf": [{ "$ref": "#/components/schemas/cloudEvent" }, { "properties": { "type": { "const": "order.fulfillment_queued.v1" }, "subject": { "pattern": "^orders/" }, "dataschema": { "const": "https://api.batchrelay.com/schemas/events/order.fulfillment_queued/v1" }, "data": { "$ref": "#/components/schemas/orderFulfillmentQueuedData" } } }] },
      "orderFulfillmentSubmittedEvent": { "allOf": [{ "$ref": "#/components/schemas/cloudEvent" }, { "properties": { "type": { "const": "order.fulfillment_submitted.v1" }, "subject": { "pattern": "^orders/" }, "dataschema": { "const": "https://api.batchrelay.com/schemas/events/order.fulfillment_submitted/v1" }, "data": { "$ref": "#/components/schemas/orderFulfillmentSubmittedData" } } }] },
      "orderFulfillmentAcceptedEvent": { "allOf": [{ "$ref": "#/components/schemas/cloudEvent" }, { "properties": { "type": { "const": "order.fulfillment_accepted.v1" }, "subject": { "pattern": "^orders/" }, "dataschema": { "const": "https://api.batchrelay.com/schemas/events/order.fulfillment_accepted/v1" }, "data": { "$ref": "#/components/schemas/orderFulfillmentAcceptedData" } } }] },
      "orderFulfillmentRejectedEvent": { "allOf": [{ "$ref": "#/components/schemas/cloudEvent" }, { "properties": { "type": { "const": "order.fulfillment_rejected.v1" }, "subject": { "pattern": "^orders/" }, "dataschema": { "const": "https://api.batchrelay.com/schemas/events/order.fulfillment_rejected/v1" }, "data": { "$ref": "#/components/schemas/orderFulfillmentRejectedData" } } }] },
      "orderShippedEvent": { "allOf": [{ "$ref": "#/components/schemas/cloudEvent" }, { "properties": { "type": { "const": "order.shipped.v1" }, "subject": { "pattern": "^orders/" }, "dataschema": { "const": "https://api.batchrelay.com/schemas/events/order.shipped/v1" }, "data": { "$ref": "#/components/schemas/orderShippedData" } } }] },
      "orderFulfilledEvent": { "allOf": [{ "$ref": "#/components/schemas/cloudEvent" }, { "properties": { "type": { "const": "order.fulfilled.v1" }, "subject": { "pattern": "^orders/" }, "dataschema": { "const": "https://api.batchrelay.com/schemas/events/order.fulfilled/v1" }, "data": { "$ref": "#/components/schemas/orderFulfilledData" } } }] },
      "orderFulfillmentFailedEvent": { "allOf": [{ "$ref": "#/components/schemas/cloudEvent" }, { "properties": { "type": { "const": "order.fulfillment_failed.v1" }, "subject": { "pattern": "^orders/" }, "dataschema": { "const": "https://api.batchrelay.com/schemas/events/order.fulfillment_failed/v1" }, "data": { "$ref": "#/components/schemas/orderFulfillmentFailedData" } } }] },
      "safeScalar": { "type": ["string", "number", "boolean", "null"] },
      "catalogItemState": {
        "type": "object",
        "required": ["status", "availability"],
        "properties": {
          "status": { "enum": ["draft", "published", "archived", "deleted"] },
          "availability": { "enum": ["active", "inactive"] },
          "display_name": { "type": "string", "minLength": 1 },
          "currency": { "const": "USD" },
          "price_minor_units": { "type": "integer", "minimum": 0 },
          "canonical_product_id": { "type": "string", "minLength": 1 },
          "canonical_product_revision": { "type": "integer", "minimum": 1 },
          "fulfillment_type": { "enum": ["print", "digital", "banner", "other"] },
          "tax_category": { "enum": ["physical_print", "digital_download", "banner", "other"] },
          "is_listed_on_storefront": { "type": "boolean" },
          "is_available_standalone": { "type": "boolean" },
          "is_available_in_packages": { "type": "boolean" },
          "is_available_as_add_on": { "type": "boolean" }
        },
        "additionalProperties": false
      },
      "catalogChange": {
        "oneOf": [
          {
            "type": "object",
            "required": ["field"],
            "properties": {
              "field": { "enum": ["availability", "status", "canonical_product_id", "canonical_product_revision", "currency", "fulfillment_type", "tax_category", "is_listed_on_storefront", "is_available_standalone", "is_available_in_packages", "is_available_as_add_on", "price_minor_units"] },
              "previous": { "$ref": "#/components/schemas/safeScalar" },
              "current": { "$ref": "#/components/schemas/safeScalar" }
            },
            "additionalProperties": false
          },
          {
            "type": "object",
            "required": ["field"],
            "properties": { "field": { "enum": ["display_name", "description", "image_urls", "photo_configurations", "option_selections", "role_bindings", "variant_label", "variant_group_name"] } },
            "additionalProperties": false
          }
        ]
      },
      "catalogItemChangedData": {
        "type": "object",
        "required": ["catalog_item_id", "action", "state", "changes"],
        "properties": {
          "catalog_item_id": { "type": "string", "minLength": 1 },
          "action": { "enum": ["created", "updated", "published", "archived", "restored", "deleted"] },
          "state": { "$ref": "#/components/schemas/catalogItemState" },
          "changes": { "type": "array", "minItems": 1, "items": { "$ref": "#/components/schemas/catalogChange" } },
          "batch_id": { "type": "string", "minLength": 1 }
        },
        "additionalProperties": false
      },
      "packageState": {
        "type": "object",
        "required": ["status", "availability", "display_name", "currency", "price_minor_units", "included_item_count"],
        "properties": {
          "status": { "enum": ["draft", "published", "archived", "deleted"] },
          "availability": { "enum": ["active", "inactive"] },
          "display_name": { "type": "string", "minLength": 1 },
          "currency": { "const": "USD" },
          "price_minor_units": { "type": "integer", "minimum": 0 },
          "included_item_count": { "type": "integer", "minimum": 0 }
        },
        "additionalProperties": false
      },
      "packageChange": {
        "oneOf": [
          {
            "type": "object",
            "required": ["field"],
            "properties": { "field": { "enum": ["availability", "currency", "included_item_count", "price_minor_units", "status"] }, "previous": { "$ref": "#/components/schemas/safeScalar" }, "current": { "$ref": "#/components/schemas/safeScalar" } },
            "additionalProperties": false
          },
          {
            "type": "object",
            "required": ["field"],
            "properties": { "field": { "enum": ["display_name", "description", "included_items", "add_ons", "variant_label", "variant_group_name"] } },
            "additionalProperties": false
          }
        ]
      },
      "packageChangedData": {
        "type": "object",
        "required": ["package_id", "action", "state", "changes"],
        "properties": {
          "package_id": { "type": "string", "minLength": 1 },
          "action": { "enum": ["created", "updated", "published", "archived", "restored", "deleted"] },
          "state": { "$ref": "#/components/schemas/packageState" },
          "changes": { "type": "array", "minItems": 1, "items": { "$ref": "#/components/schemas/packageChange" } },
          "batch_id": { "type": "string", "minLength": 1 }
        },
        "additionalProperties": false
      },
      "catalogActionCounts": {
        "type": "object",
        "required": ["created", "updated", "published", "archived", "restored", "deleted"],
        "properties": {
          "created": { "type": "integer", "minimum": 0 }, "updated": { "type": "integer", "minimum": 0 }, "published": { "type": "integer", "minimum": 0 },
          "archived": { "type": "integer", "minimum": 0 }, "restored": { "type": "integer", "minimum": 0 }, "deleted": { "type": "integer", "minimum": 0 }
        },
        "additionalProperties": false
      },
      "catalogChangedResource": {
        "type": "object",
        "required": ["id", "resource_type", "resource_version", "action"],
        "properties": {
          "id": { "type": "string", "minLength": 1 }, "resource_type": { "enum": ["catalog_item", "package"] },
          "resource_version": { "type": "integer", "minimum": 1 }, "action": { "enum": ["created", "updated", "published", "archived", "restored", "deleted"] }
        },
        "additionalProperties": false
      },
      "catalogBatchCompletedData": {
        "type": "object",
        "required": ["batch_id", "operation", "counts", "changed_resources"],
        "properties": {
          "batch_id": { "type": "string", "minLength": 1 },
          "operation": { "enum": ["availability", "bulk_edit", "import"] },
          "counts": { "$ref": "#/components/schemas/catalogActionCounts" },
          "changed_resources": { "type": "array", "items": { "$ref": "#/components/schemas/catalogChangedResource" } }
        },
        "additionalProperties": false
      },
      "storefrontState": {
        "type": "object",
        "required": ["status", "availability"],
        "properties": {
          "status": { "enum": ["draft", "published", "archived", "deleted"] },
          "availability": { "enum": ["available", "unavailable", "restricted"] },
          "hostname": { "type": "string" }, "checkout_mode": { "enum": ["public_live", "restricted_live", "disabled"] },
          "audience": { "enum": ["public", "restricted"] }, "guardian_join_mode": { "enum": ["invite_link", "explicit_grant_only"] },
          "provider_submission_enabled": { "type": "boolean" }
        },
        "additionalProperties": false
      },
      "storefrontChange": {
        "oneOf": [
          {
            "type": "object",
            "required": ["field"],
            "properties": {
              "field": { "enum": ["availability", "hostname", "checkout_mode", "audience", "guardian_join_mode", "provider_submission_enabled", "status"] },
              "previous": { "$ref": "#/components/schemas/safeScalar" },
              "current": { "$ref": "#/components/schemas/safeScalar" }
            },
            "additionalProperties": false
          },
          {
            "type": "object",
            "required": ["field"],
            "properties": { "field": { "enum": ["brand_name", "brand_description", "brand_logo", "brand_image", "brand_colors", "website", "custom_domain"] } },
            "additionalProperties": false
          }
        ]
      },
      "storefrontChangedData": {
        "type": "object",
        "required": ["storefront_id", "action", "state", "changes"],
        "properties": {
          "storefront_id": { "type": "string", "minLength": 1 },
          "action": { "enum": ["created", "updated", "published", "archived", "restored", "deleted"] },
          "state": { "$ref": "#/components/schemas/storefrontState" }, "changes": { "type": "array", "minItems": 1, "items": { "$ref": "#/components/schemas/storefrontChange" } }
        },
        "additionalProperties": false
      },
      "destinationTestData": {
        "type": "object",
        "required": ["test_id", "message"],
        "properties": { "test_id": { "type": "string", "minLength": 1 }, "message": { "const": "Batch Relay event destination verification." } },
        "additionalProperties": false
      },
      "catalogEvent": { "allOf": [{ "$ref": "#/components/schemas/cloudEvent" }, { "properties": { "type": { "const": "catalog_item.changed.v1" }, "subject": { "pattern": "^catalog-items/" }, "dataschema": { "const": "https://api.batchrelay.com/schemas/events/catalog_item.changed/v1" }, "data": { "$ref": "#/components/schemas/catalogItemChangedData" } } }] },
      "packageEvent": { "allOf": [{ "$ref": "#/components/schemas/cloudEvent" }, { "properties": { "type": { "const": "package.changed.v1" }, "subject": { "pattern": "^packages/" }, "dataschema": { "const": "https://api.batchrelay.com/schemas/events/package.changed/v1" }, "data": { "$ref": "#/components/schemas/packageChangedData" } } }] },
      "catalogBatchEvent": { "allOf": [{ "$ref": "#/components/schemas/cloudEvent" }, { "properties": { "type": { "const": "catalog_batch.completed.v1" }, "subject": { "pattern": "^catalog-batches/" }, "dataschema": { "const": "https://api.batchrelay.com/schemas/events/catalog_batch.completed/v1" }, "data": { "$ref": "#/components/schemas/catalogBatchCompletedData" } } }] },
      "storefrontEvent": { "allOf": [{ "$ref": "#/components/schemas/cloudEvent" }, { "properties": { "type": { "const": "storefront.changed.v1" }, "subject": { "pattern": "^storefronts/" }, "dataschema": { "const": "https://api.batchrelay.com/schemas/events/storefront.changed/v1" }, "data": { "$ref": "#/components/schemas/storefrontChangedData" } } }] },
      "destinationTestEvent": { "allOf": [{ "$ref": "#/components/schemas/cloudEvent" }, { "properties": { "type": { "const": "destination.test.v1" }, "subject": { "pattern": "^destinations/" }, "dataschema": { "const": "https://api.batchrelay.com/schemas/events/destination.test/v1" }, "data": { "$ref": "#/components/schemas/destinationTestData" } } }] }
    }
  }
}
