{
  "version": "certarail.asyncapi-event-catalog.v1",
  "source": {
    "href": "/contracts/certrail.asyncapi.v1.yaml",
    "sha256": "99597d6bb4b033e7c2a51b250ea5a7d6370bd7eb8f08b9fcabcc14ceebae3d15",
    "asyncapi": "3.1.0",
    "documentId": "urn:certarail:asyncapi:kafka:v1",
    "documentVersion": "1.3.1"
  },
  "boundary": {
    "defaultContentType": "application/json",
    "servers": [
      {
        "id": "localSandbox",
        "host": "localhost:9092",
        "protocol": "kafka",
        "environmentClass": "LOCAL",
        "securityState": "PLAINTEXT_LOCAL_SANDBOX",
        "description": "Loopback development broker from compose.yaml. Production TLS, SASL,\nACLs, multi-broker replication, quotas, and disaster recovery are not\nimplemented by this server definition."
      }
    ]
  },
  "stats": {
    "events": 6,
    "topics": 5,
    "producerDeclared": 4,
    "notProduced": 2,
    "consumerDeclared": 0
  },
  "events": [
    {
      "id": "event-certarail-eligibility-decision-v1",
      "name": "certarail.eligibility.decision.v1",
      "title": "Eligibility decision event v1",
      "summary": "Immutable eligibility decision and audit receipt.",
      "description": "Immutable eligibility decision and audit receipt.",
      "channel": {
        "key": "eligibilityDecisions",
        "topic": "certarail.decision.v1",
        "description": "Eligibility decision evidence committed atomically with its audit\nreceipt and outbox row. Delivery is at least once. Consumers MUST\ndeduplicate by payload event_id and MUST tolerate a duplicate after\nKafka acknowledged a publish whose PostgreSQL acknowledgement failed.\nOrdering is guaranteed only for records sharing this Kafka key in this\ntopic."
      },
      "publication": {
        "state": "producer-declared",
        "marker": "ASYNCAPI_SEND_OPERATION",
        "summary": "Canonical AsyncAPI declares a send operation. This documents the producer contract; it does not by itself prove a live or production publisher."
      },
      "producer": {
        "state": "declared",
        "operations": [
          {
            "id": "emitEligibilityDecision",
            "action": "send",
            "summary": "Publish committed eligibility decision evidence.",
            "description": ""
          }
        ],
        "summary": "Send operation emitEligibilityDecision is declared in canonical AsyncAPI. This is a contract declaration, not runtime evidence."
      },
      "consumer": {
        "state": "not-declared",
        "operations": [],
        "summary": "No named consumer operation is declared in canonical AsyncAPI; the catalog does not infer one."
      },
      "payload": {
        "schemaId": "urn:certarail:schema:event:certarail.eligibility.decision.v1",
        "schemaTitle": "CertaRail eligibility decision event v1",
        "schemaFormat": "application/schema+json;version=draft-2020-12",
        "schemaHref": "/events/certarail.eligibility.decision.v1.schema.json",
        "schemaSha256": "3548436bd083a52b17bb1559ca3232d3b2154d97c0f84bfa67bc41ae20ef8464",
        "required": [
          "event_id",
          "event_type",
          "occurred_at",
          "tenant_id",
          "result"
        ],
        "properties": [
          {
            "name": "event_id",
            "required": true,
            "type": "string",
            "description": "",
            "constraints": ["pattern ^evt_", "minLength 5"]
          },
          {
            "name": "event_type",
            "required": true,
            "type": "string",
            "description": "",
            "constraints": ["const \"certarail.eligibility.decision.v1\""]
          },
          {
            "name": "occurred_at",
            "required": true,
            "type": "string",
            "description": "",
            "constraints": ["format date-time"]
          },
          {
            "name": "tenant_id",
            "required": true,
            "type": "string",
            "description": "",
            "constraints": ["minLength 1"]
          },
          {
            "name": "result",
            "required": true,
            "type": "object",
            "description": "",
            "constraints": ["#/$defs/evaluationResult"]
          }
        ],
        "schema": {
          "$schema": "https://json-schema.org/draft/2020-12/schema",
          "$id": "urn:certarail:schema:event:certarail.eligibility.decision.v1",
          "title": "CertaRail eligibility decision event v1",
          "description": "Immutable event envelope written to the PostgreSQL outbox in the same transaction as the decision and audit receipt.",
          "type": "object",
          "additionalProperties": false,
          "required": [
            "event_id",
            "event_type",
            "occurred_at",
            "tenant_id",
            "result"
          ],
          "properties": {
            "event_id": {
              "type": "string",
              "pattern": "^evt_",
              "minLength": 5
            },
            "event_type": {
              "const": "certarail.eligibility.decision.v1"
            },
            "occurred_at": {
              "type": "string",
              "format": "date-time"
            },
            "tenant_id": {
              "type": "string",
              "minLength": 1
            },
            "result": {
              "$ref": "#/$defs/evaluationResult"
            }
          },
          "$defs": {
            "evaluationResult": {
              "type": "object",
              "additionalProperties": false,
              "required": ["decision", "audit"],
              "properties": {
                "decision": {
                  "$ref": "#/$defs/decision"
                },
                "audit": {
                  "$ref": "#/$defs/auditReceipt"
                }
              }
            },
            "decision": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "decision_id",
                "request_id",
                "tenant_id",
                "outcome",
                "enforceable",
                "evaluated_at",
                "operation",
                "asset_code",
                "input_digest",
                "checks"
              ],
              "properties": {
                "decision_id": {
                  "type": "string",
                  "minLength": 1
                },
                "request_id": {
                  "type": "string",
                  "minLength": 1
                },
                "tenant_id": {
                  "type": "string",
                  "minLength": 1
                },
                "outcome": {
                  "enum": ["ALLOW", "DENY", "REVIEW"]
                },
                "enforceable": {
                  "type": "boolean"
                },
                "evaluated_at": {
                  "type": "string",
                  "format": "date-time"
                },
                "evaluator_version": {
                  "const": "certarail.eligibility.go.v1",
                  "description": "Immutable rule-engine semantics identity. Optional in v1 only for pre-migration committed replays; every new decision includes it."
                },
                "operation": {
                  "enum": ["BUY", "SELL", "DEPOSIT", "WITHDRAW", "EXCHANGE"]
                },
                "asset_code": {
                  "type": "string",
                  "minLength": 1
                },
                "policy_id": {
                  "type": "string",
                  "minLength": 1
                },
                "policy_version": {
                  "type": "string",
                  "minLength": 1
                },
                "policy_digest": {
                  "$ref": "#/$defs/digest"
                },
                "policy_mode": {
                  "enum": ["SANDBOX", "PRODUCTION"]
                },
                "input_digest": {
                  "$ref": "#/$defs/digest"
                },
                "checks": {
                  "type": "array",
                  "items": {
                    "$ref": "#/$defs/check"
                  }
                },
                "obligations": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              }
            },
            "check": {
              "type": "object",
              "additionalProperties": false,
              "required": ["id", "status", "summary"],
              "properties": {
                "id": {
                  "type": "string",
                  "minLength": 1
                },
                "status": {
                  "enum": ["PASS", "FAIL", "REVIEW"]
                },
                "summary": {
                  "type": "string"
                },
                "rule_id": {
                  "type": "string",
                  "minLength": 1
                },
                "source_refs": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              }
            },
            "auditReceipt": {
              "type": "object",
              "additionalProperties": false,
              "required": ["lane", "sequence", "recorded_at", "event_hash"],
              "properties": {
                "lane": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 31
                },
                "sequence": {
                  "type": "integer",
                  "minimum": 1
                },
                "recorded_at": {
                  "type": "string",
                  "format": "date-time"
                },
                "evaluator_version": {
                  "const": "certarail.eligibility.go.v1",
                  "description": "Evaluator identity bound into the audit event hash. Optional in v1 only for pre-migration committed replays; every new audit event includes it."
                },
                "previous_hash": {
                  "$ref": "#/$defs/digest"
                },
                "event_hash": {
                  "$ref": "#/$defs/digest"
                }
              }
            },
            "digest": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            }
          }
        }
      },
      "example": {
        "event_id": "evt_x",
        "event_type": "certarail.eligibility.decision.v1",
        "occurred_at": "2026-01-01T00:00:00Z",
        "tenant_id": "tenant_example",
        "result": {
          "decision": {
            "decision_id": "decision_example",
            "request_id": "request_example",
            "tenant_id": "tenant_example",
            "outcome": "ALLOW",
            "enforceable": false,
            "evaluated_at": "2026-01-01T00:00:00Z",
            "evaluator_version": "certarail.eligibility.go.v1",
            "operation": "BUY",
            "asset_code": "BTC",
            "input_digest": "0000000000000000000000000000000000000000000000000000000000000000",
            "checks": [
              {
                "id": "example",
                "status": "PASS",
                "summary": "example"
              }
            ]
          },
          "audit": {
            "lane": 0,
            "sequence": 1,
            "recorded_at": "2026-01-01T00:00:00Z",
            "evaluator_version": "certarail.eligibility.go.v1",
            "event_hash": "0000000000000000000000000000000000000000000000000000000000000000"
          }
        }
      },
      "version": {
        "label": "v1",
        "value": 1,
        "asyncApiDocument": "1.3.1",
        "transportHeader": "1"
      },
      "correlationFields": {
        "state": "declared",
        "fields": [
          {
            "location": "payload",
            "path": "payload.event_id",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.tenant_id",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.result.decision.decision_id",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.result.decision.request_id",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.result.decision.tenant_id",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.result.decision.policy_id",
            "required": false,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.result.decision.checks.[].id",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.result.decision.checks.[].rule_id",
            "required": false,
            "type": "string",
            "description": ""
          },
          {
            "location": "header",
            "path": "headers.certarail-event-id",
            "required": true,
            "type": "string",
            "description": "Stable consumer deduplication identifier; equal to payload event_id."
          },
          {
            "location": "header",
            "path": "headers.traceparent",
            "required": false,
            "type": "string",
            "description": "Optional W3C Trace Context for the Kafka publisher attempt."
          },
          {
            "location": "header",
            "path": "headers.tracestate",
            "required": false,
            "type": "string",
            "description": "Optional W3C Trace Context tracestate value; omitted when empty."
          },
          {
            "location": "kafka-key",
            "path": "message.key",
            "required": null,
            "type": "string",
            "description": "Pseudonymous ordering key computed as `subject_` plus the first\n16 bytes of SHA-256(tenant_id || NUL || subject_ref), encoded as\nlowercase hexadecimal. It is not an authentication or tenancy\nboundary."
          }
        ],
        "summary": "Identifier, reference, trace, and Kafka-key fields are listed from the canonical schemas and message bindings."
      },
      "ordering": {
        "state": "declared",
        "scope": "one Kafka key within certarail.decision.v1",
        "key": {
          "type": "string",
          "pattern": "^subject_[0-9a-f]{32}$",
          "description": "Pseudonymous ordering key computed as `subject_` plus the first\n16 bytes of SHA-256(tenant_id || NUL || subject_ref), encoded as\nlowercase hexadecimal. It is not an authentication or tenancy\nboundary."
        },
        "summary": "Ordering is guaranteed only for one Kafka key within certarail.decision.v1."
      },
      "retry": {
        "state": "declared",
        "guarantee": "at-least-once",
        "deduplicationKey": "payload.event_id",
        "deduplicationScope": null,
        "summary": "at-least-once delivery is declared. Consumers must deduplicate by payload.event_id and tolerate redelivery."
      },
      "relatedOpenApiTags": ["Decision"]
    },
    {
      "id": "event-certarail-asset-movement-v1",
      "name": "certarail.asset.movement.v1",
      "title": "Asset movement event v1",
      "summary": "Immutable movement observation evidence.",
      "description": "This event records an observation and does not execute funds or asset movement.",
      "channel": {
        "key": "assetMovements",
        "topic": "certarail.movement.v1",
        "description": "Immutable observation evidence; this event does not execute a transfer.\nDelivery is at least once. Consumers MUST deduplicate by payload\nevent_id and MUST tolerate a duplicate after Kafka acknowledged a\npublish whose PostgreSQL acknowledgement failed. Ordering is guaranteed\nonly for records sharing this Kafka key in this topic."
      },
      "publication": {
        "state": "producer-declared",
        "marker": "ASYNCAPI_SEND_OPERATION",
        "summary": "Canonical AsyncAPI declares a send operation. This documents the producer contract; it does not by itself prove a live or production publisher."
      },
      "producer": {
        "state": "declared",
        "operations": [
          {
            "id": "emitAssetMovement",
            "action": "send",
            "summary": "Publish committed asset movement observation evidence.",
            "description": ""
          }
        ],
        "summary": "Send operation emitAssetMovement is declared in canonical AsyncAPI. This is a contract declaration, not runtime evidence."
      },
      "consumer": {
        "state": "not-declared",
        "operations": [],
        "summary": "No named consumer operation is declared in canonical AsyncAPI; the catalog does not infer one."
      },
      "payload": {
        "schemaId": "https://schemas.certarail.local/events/certarail.asset.movement.v1.schema.json",
        "schemaTitle": "CertaRail Asset Movement Event v1",
        "schemaFormat": "application/schema+json;version=draft-2020-12",
        "schemaHref": "/events/certarail.asset.movement.v1.schema.json",
        "schemaSha256": "d79a1e348353735a77c902077e26f9df6c9366aae775a3c54965bdb83eff5f21",
        "required": [
          "event_id",
          "event_type",
          "occurred_at",
          "tenant_id",
          "movement"
        ],
        "properties": [
          {
            "name": "event_id",
            "required": true,
            "type": "string",
            "description": "",
            "constraints": ["minLength 1"]
          },
          {
            "name": "event_type",
            "required": true,
            "type": "string",
            "description": "",
            "constraints": ["const \"certarail.asset.movement.v1\""]
          },
          {
            "name": "occurred_at",
            "required": true,
            "type": "string",
            "description": "",
            "constraints": ["format date-time"]
          },
          {
            "name": "tenant_id",
            "required": true,
            "type": "string",
            "description": "",
            "constraints": ["minLength 1", "maxLength 128"]
          },
          {
            "name": "movement",
            "required": true,
            "type": "object",
            "description": "",
            "constraints": []
          }
        ],
        "schema": {
          "$schema": "https://json-schema.org/draft/2020-12/schema",
          "$id": "https://schemas.certarail.local/events/certarail.asset.movement.v1.schema.json",
          "title": "CertaRail Asset Movement Event v1",
          "type": "object",
          "additionalProperties": false,
          "required": [
            "event_id",
            "event_type",
            "occurred_at",
            "tenant_id",
            "movement"
          ],
          "properties": {
            "event_id": {
              "type": "string",
              "minLength": 1
            },
            "event_type": {
              "const": "certarail.asset.movement.v1"
            },
            "occurred_at": {
              "type": "string",
              "format": "date-time"
            },
            "tenant_id": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            },
            "movement": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "movement_id",
                "request_id",
                "tenant_id",
                "decision_id",
                "kind",
                "direction",
                "asset_code",
                "quantity",
                "network",
                "status",
                "wallet_ref",
                "source_system",
                "source_event_ref",
                "observed_at",
                "recorded_at",
                "evidence_digest"
              ],
              "properties": {
                "movement_id": {
                  "type": "string",
                  "minLength": 1
                },
                "request_id": {
                  "type": "string",
                  "minLength": 1
                },
                "tenant_id": {
                  "type": "string",
                  "minLength": 1
                },
                "decision_id": {
                  "type": "string",
                  "minLength": 1
                },
                "kind": {
                  "enum": [
                    "BUY_FILL",
                    "SELL_FILL",
                    "DEPOSIT",
                    "WITHDRAWAL",
                    "INTERNAL_TRANSFER",
                    "EXTERNAL_TRANSFER",
                    "SWAP_LEG",
                    "FEE",
                    "REFUND",
                    "REVERSAL",
                    "REWARD",
                    "AIRDROP",
                    "FORK",
                    "MINING",
                    "STAKING",
                    "CUSTODY_MOVE",
                    "ADJUSTMENT"
                  ]
                },
                "direction": {
                  "enum": ["CREDIT", "DEBIT"]
                },
                "asset_code": {
                  "type": "string",
                  "minLength": 1
                },
                "quantity": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": ["atomic_units", "decimals"],
                  "properties": {
                    "atomic_units": {
                      "type": "string",
                      "pattern": "^[1-9][0-9]{0,77}$"
                    },
                    "decimals": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 38
                    }
                  }
                },
                "network": {
                  "type": "string",
                  "minLength": 1
                },
                "status": {
                  "enum": [
                    "OBSERVED",
                    "PENDING",
                    "CONFIRMED",
                    "FAILED",
                    "REVERSED"
                  ]
                },
                "wallet_ref": {
                  "type": "string",
                  "minLength": 1
                },
                "counterparty_ref": {
                  "type": "string"
                },
                "venue_ref": {
                  "type": "string"
                },
                "blockchain_transaction_id": {
                  "type": "string"
                },
                "confirmations": {
                  "type": "integer",
                  "minimum": 0
                },
                "source_system": {
                  "type": "string",
                  "minLength": 1
                },
                "source_event_ref": {
                  "type": "string",
                  "minLength": 1
                },
                "kyt_assessment_ref": {
                  "type": "string"
                },
                "address_verification_ref": {
                  "type": "string"
                },
                "travel_rule_ref": {
                  "type": "string"
                },
                "observed_at": {
                  "type": "string",
                  "format": "date-time"
                },
                "recorded_at": {
                  "type": "string",
                  "format": "date-time"
                },
                "evidence_digest": {
                  "type": "string",
                  "pattern": "^[a-f0-9]{64}$"
                }
              }
            }
          }
        }
      },
      "example": {
        "event_id": "event_example",
        "event_type": "certarail.asset.movement.v1",
        "occurred_at": "2026-01-01T00:00:00Z",
        "tenant_id": "tenant_example",
        "movement": {
          "movement_id": "movement_example",
          "request_id": "request_example",
          "tenant_id": "tenant_example",
          "decision_id": "decision_example",
          "kind": "BUY_FILL",
          "direction": "CREDIT",
          "asset_code": "BTC",
          "quantity": {
            "atomic_units": "1",
            "decimals": 0
          },
          "network": "bitcoin",
          "status": "OBSERVED",
          "wallet_ref": "wallet_example",
          "source_system": "example",
          "source_event_ref": "source_event_example",
          "observed_at": "2026-01-01T00:00:00Z",
          "recorded_at": "2026-01-01T00:00:00Z",
          "evidence_digest": "0000000000000000000000000000000000000000000000000000000000000000"
        }
      },
      "version": {
        "label": "v1",
        "value": 1,
        "asyncApiDocument": "1.3.1",
        "transportHeader": "1"
      },
      "correlationFields": {
        "state": "declared",
        "fields": [
          {
            "location": "payload",
            "path": "payload.event_id",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.tenant_id",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.movement.movement_id",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.movement.request_id",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.movement.tenant_id",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.movement.decision_id",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.movement.wallet_ref",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.movement.counterparty_ref",
            "required": false,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.movement.venue_ref",
            "required": false,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.movement.blockchain_transaction_id",
            "required": false,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.movement.source_event_ref",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.movement.kyt_assessment_ref",
            "required": false,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.movement.address_verification_ref",
            "required": false,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.movement.travel_rule_ref",
            "required": false,
            "type": "string",
            "description": ""
          },
          {
            "location": "header",
            "path": "headers.certarail-event-id",
            "required": true,
            "type": "string",
            "description": "Stable consumer deduplication identifier; equal to payload event_id."
          },
          {
            "location": "header",
            "path": "headers.traceparent",
            "required": false,
            "type": "string",
            "description": "Optional W3C Trace Context for the Kafka publisher attempt."
          },
          {
            "location": "header",
            "path": "headers.tracestate",
            "required": false,
            "type": "string",
            "description": "Optional W3C Trace Context tracestate value; omitted when empty."
          },
          {
            "location": "kafka-key",
            "path": "message.key",
            "required": null,
            "type": "string",
            "description": "Pseudonymous ordering key computed as `movement_` plus the first\n16 bytes of SHA-256(tenant_id || NUL || wallet_ref), encoded as\nlowercase hexadecimal. It is not an authentication or tenancy\nboundary."
          }
        ],
        "summary": "Identifier, reference, trace, and Kafka-key fields are listed from the canonical schemas and message bindings."
      },
      "ordering": {
        "state": "declared",
        "scope": "one Kafka key within certarail.movement.v1",
        "key": {
          "type": "string",
          "pattern": "^movement_[0-9a-f]{32}$",
          "description": "Pseudonymous ordering key computed as `movement_` plus the first\n16 bytes of SHA-256(tenant_id || NUL || wallet_ref), encoded as\nlowercase hexadecimal. It is not an authentication or tenancy\nboundary."
        },
        "summary": "Ordering is guaranteed only for one Kafka key within certarail.movement.v1."
      },
      "retry": {
        "state": "declared",
        "guarantee": "at-least-once",
        "deduplicationKey": "payload.event_id",
        "deduplicationScope": null,
        "summary": "at-least-once delivery is declared. Consumers must deduplicate by payload.event_id and tolerate redelivery."
      },
      "relatedOpenApiTags": ["Movement"]
    },
    {
      "id": "event-certarail-trade-order-v1",
      "name": "certarail.trade.order.v1",
      "title": "Legacy durable sandbox trading order event v1",
      "summary": "Frozen pre-subject/pre-BUY-only local order/fill/cancel fact.",
      "description": "Legacy records may omit or empty subject_ref and may contain BUY or\nSELL, or contain a three-letter quote outside the current v2 set.\nExisting orders have immutable event_contract=v1 and retain v1 for all\nlater lifecycle facts. Historical v1 payloads may omit event_contract.\nNo legacy order can be newly created. A legacy SELL can only be locally\ncancelled and cannot receive a fill. V1 represents only CertaRail\nsandbox state and is not live execution or a balance.",
      "channel": {
        "key": "sandboxTradingOrders",
        "topic": "certarail.trade.v1",
        "description": "Durable PostgreSQL facts for the non-monetary trading sandbox. Frozen v1\nrecords may omit subject_ref and may contain SELL; current v2 records\nrequire eligibility-bound subject_ref, side=BUY and quote RUB/USD/EUR.\nImmutable order.event_contract selects the schema for the complete order\nlifecycle: migrated existing rows use v1 and new rows use v2. Historical\nv1 payloads may omit event_contract; subsequent v1 lifecycle facts carry\nit. A legacy SELL can only be read and locally cancelled; it cannot\nreceive a fill.\nConsumers MUST branch on\npayload.event_type and validate with the matching schema. Delivery is at\nleast once; consumers MUST deduplicate by payload.event_id across both\nversions and MUST NOT treat a version change as a new business fact.\nOrdering is guaranteed only for records sharing one order key in this\ntopic. No event proves a venue call,\nprovider acknowledgement, price source, settlement, custody balance,\nledger posting, asset movement, or legal permission to trade."
      },
      "publication": {
        "state": "producer-declared",
        "marker": "ASYNCAPI_SEND_OPERATION",
        "summary": "Canonical AsyncAPI declares a send operation. This documents the producer contract; it does not by itself prove a live or production publisher."
      },
      "producer": {
        "state": "declared",
        "operations": [
          {
            "id": "emitSandboxTradingOrderFact",
            "action": "send",
            "summary": "Publish a committed local non-monetary sandbox trading fact.",
            "description": "Immutable order.event_contract routes every fact in one order lifecycle.\nExisting migrated orders remain v1 and newly created orders are v2. No\nnew legacy order is accepted, and a legacy SELL may only be locally\ncancelled, never filled."
          }
        ],
        "summary": "Send operation emitSandboxTradingOrderFact is declared in canonical AsyncAPI. This is a contract declaration, not runtime evidence."
      },
      "consumer": {
        "state": "not-declared",
        "operations": [],
        "summary": "No named consumer operation is declared in canonical AsyncAPI; the catalog does not infer one."
      },
      "payload": {
        "schemaId": "urn:certarail:schema:event:certarail.trade.order.v1",
        "schemaTitle": "CertaRail legacy durable sandbox trading order event v1",
        "schemaFormat": "application/schema+json;version=draft-2020-12",
        "schemaHref": "/events/certarail.trade.order.v1.schema.json",
        "schemaSha256": "ab8abf608e7fa27238aa8625bc744eec5d70c189b4a394d9cdfad4b66ef16fd1",
        "required": [
          "event_id",
          "event_type",
          "action",
          "occurred_at",
          "tenant_id",
          "order_id",
          "decision_id",
          "order",
          "evidence_digest",
          "safety",
          "external_calls"
        ],
        "properties": [
          {
            "name": "event_id",
            "required": true,
            "type": "string",
            "description": "",
            "constraints": ["pattern ^evt-trade_[0-9a-f]{32}$"]
          },
          {
            "name": "event_type",
            "required": true,
            "type": "string",
            "description": "",
            "constraints": ["const \"certarail.trade.order.v1\""]
          },
          {
            "name": "action",
            "required": true,
            "type": "string",
            "description": "",
            "constraints": [
              "ORDER_OPENED | SYNTHETIC_FILL_RECORDED | ORDER_CANCELLED"
            ]
          },
          {
            "name": "occurred_at",
            "required": true,
            "type": "string",
            "description": "",
            "constraints": ["format date-time"]
          },
          {
            "name": "tenant_id",
            "required": true,
            "type": "string",
            "description": "",
            "constraints": ["minLength 1", "maxLength 128"]
          },
          {
            "name": "order_id",
            "required": true,
            "type": "string",
            "description": "",
            "constraints": ["pattern ^ord_[0-9a-f]{32}$"]
          },
          {
            "name": "decision_id",
            "required": true,
            "type": "string",
            "description": "",
            "constraints": ["minLength 1", "maxLength 160"]
          },
          {
            "name": "order",
            "required": true,
            "type": "object",
            "description": "",
            "constraints": ["#/$defs/order"]
          },
          {
            "name": "fill",
            "required": false,
            "type": "object",
            "description": "",
            "constraints": ["#/$defs/fill"]
          },
          {
            "name": "evidence_digest",
            "required": true,
            "type": "string",
            "description": "",
            "constraints": ["#/$defs/digest"]
          },
          {
            "name": "safety",
            "required": true,
            "type": "object",
            "description": "",
            "constraints": ["#/$defs/safety"]
          },
          {
            "name": "external_calls",
            "required": true,
            "type": "number",
            "description": "",
            "constraints": ["const 0"]
          }
        ],
        "schema": {
          "$schema": "https://json-schema.org/draft/2020-12/schema",
          "$id": "urn:certarail:schema:event:certarail.trade.order.v1",
          "title": "CertaRail legacy durable sandbox trading order event v1",
          "description": "Frozen legacy PostgreSQL transactional-outbox contract emitted before subject binding, the BUY-only gate, the current RUB/USD/EUR quote set and explicit order provenance. V1 may omit subject_ref, may contain BUY or SELL, and accepts any uppercase three-letter quote. Existing rows are assigned immutable event_contract v1 and retain v1 for subsequent lifecycle facts; historical v1 payloads may omit event_contract. A legacy SELL can only be locally cancelled and cannot receive a fill. V1 never authorizes a new legacy order or asserts a live venue call, market price, settlement, custody balance, ledger posting, asset movement, or legal permission to trade.",
          "type": "object",
          "additionalProperties": false,
          "required": [
            "event_id",
            "event_type",
            "action",
            "occurred_at",
            "tenant_id",
            "order_id",
            "decision_id",
            "order",
            "evidence_digest",
            "safety",
            "external_calls"
          ],
          "properties": {
            "event_id": {
              "type": "string",
              "pattern": "^evt-trade_[0-9a-f]{32}$"
            },
            "event_type": {
              "const": "certarail.trade.order.v1"
            },
            "action": {
              "enum": [
                "ORDER_OPENED",
                "SYNTHETIC_FILL_RECORDED",
                "ORDER_CANCELLED"
              ]
            },
            "occurred_at": {
              "type": "string",
              "format": "date-time"
            },
            "tenant_id": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            },
            "order_id": {
              "type": "string",
              "pattern": "^ord_[0-9a-f]{32}$"
            },
            "decision_id": {
              "type": "string",
              "minLength": 1,
              "maxLength": 160
            },
            "order": {
              "$ref": "#/$defs/order"
            },
            "fill": {
              "$ref": "#/$defs/fill"
            },
            "evidence_digest": {
              "$ref": "#/$defs/digest"
            },
            "safety": {
              "$ref": "#/$defs/safety"
            },
            "external_calls": {
              "const": 0
            }
          },
          "allOf": [
            {
              "if": {
                "properties": {
                  "action": {
                    "const": "SYNTHETIC_FILL_RECORDED"
                  }
                },
                "required": ["action"]
              },
              "then": {
                "properties": {
                  "fill": {
                    "$ref": "#/$defs/fill"
                  }
                },
                "required": ["fill"]
              },
              "else": {
                "properties": {
                  "fill": false
                }
              }
            }
          ],
          "$defs": {
            "digest": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "safety": {
              "type": "object",
              "additionalProperties": false,
              "required": ["environment", "production_enforceable", "monetary"],
              "properties": {
                "environment": {
                  "const": "sandbox"
                },
                "production_enforceable": {
                  "const": false
                },
                "monetary": {
                  "const": false
                }
              }
            },
            "instrument": {
              "type": "object",
              "additionalProperties": false,
              "required": ["base_asset", "quote_currency"],
              "properties": {
                "base_asset": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 64
                },
                "quote_currency": {
                  "type": "string",
                  "pattern": "^[A-Z]{3}$"
                }
              }
            },
            "positiveQuantity": {
              "type": "object",
              "additionalProperties": false,
              "required": ["atomic_units", "decimals"],
              "properties": {
                "atomic_units": {
                  "type": "string",
                  "pattern": "^[1-9][0-9]{0,77}$"
                },
                "decimals": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 38
                }
              }
            },
            "nonNegativeQuantity": {
              "type": "object",
              "additionalProperties": false,
              "required": ["atomic_units", "decimals"],
              "properties": {
                "atomic_units": {
                  "type": "string",
                  "pattern": "^(0|[1-9][0-9]{0,77})$"
                },
                "decimals": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 38
                }
              }
            },
            "decimal": {
              "type": "object",
              "additionalProperties": false,
              "required": ["value", "scale"],
              "properties": {
                "value": {
                  "type": "string",
                  "pattern": "^[1-9][0-9]{0,77}$"
                },
                "scale": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 38
                }
              }
            },
            "money": {
              "type": "object",
              "additionalProperties": false,
              "required": ["currency", "minor_units"],
              "properties": {
                "currency": {
                  "type": "string",
                  "pattern": "^[A-Z]{3}$"
                },
                "minor_units": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 9223372036854776000
                }
              }
            },
            "order": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "order_id",
                "request_id",
                "tenant_id",
                "decision_id",
                "portfolio_ref",
                "approval_ref",
                "connection_id",
                "account_ref",
                "client_order_id",
                "instrument",
                "side",
                "order_type",
                "base_quantity",
                "time_in_force",
                "max_notional",
                "command_id",
                "provider_order_ref",
                "status",
                "submit_disposition",
                "venue_state",
                "filled_quantity",
                "version",
                "created_at",
                "updated_at",
                "evidence_digest",
                "safety",
                "external_calls"
              ],
              "properties": {
                "order_id": {
                  "type": "string",
                  "pattern": "^ord_[0-9a-f]{32}$"
                },
                "request_id": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 128
                },
                "tenant_id": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 128
                },
                "decision_id": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 160
                },
                "event_contract": {
                  "const": "certarail.trade.order.v1",
                  "description": "Immutable order event-schema provenance. Optional because historical v1 payloads predate the field."
                },
                "subject_ref": {
                  "type": "string",
                  "minLength": 0,
                  "maxLength": 256,
                  "description": "Optional legacy field. It may be absent or empty because v1 predates mandatory eligibility subject binding."
                },
                "portfolio_ref": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 256
                },
                "approval_ref": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 256,
                  "description": "Correlation only; not evidence that CertaRail performed maker-checker approval."
                },
                "connection_id": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 128
                },
                "account_ref": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 256
                },
                "client_order_id": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 128
                },
                "instrument": {
                  "$ref": "#/$defs/instrument"
                },
                "side": {
                  "enum": ["BUY", "SELL"],
                  "description": "Legacy v1 facts may contain SELL. This does not make SELL executable in the current runtime."
                },
                "order_type": {
                  "const": "MARKET"
                },
                "base_quantity": {
                  "$ref": "#/$defs/positiveQuantity"
                },
                "limit_price": {
                  "$ref": "#/$defs/decimal"
                },
                "time_in_force": {
                  "const": "IOC"
                },
                "max_notional": {
                  "$ref": "#/$defs/money"
                },
                "command_id": {
                  "type": "string",
                  "pattern": "^cmd_[0-9a-f]{32}$"
                },
                "provider_order_ref": {
                  "type": "string",
                  "pattern": "^syn-order_[0-9a-f]{32}$",
                  "description": "Deterministic local reference, never a provider receipt."
                },
                "status": {
                  "enum": ["OPEN", "PARTIALLY_FILLED", "FILLED", "CANCELLED"]
                },
                "submit_disposition": {
                  "const": "ACKNOWLEDGED",
                  "description": "Local PostgreSQL acknowledgement only."
                },
                "venue_state": {
                  "enum": ["OPEN", "PARTIALLY_FILLED", "FILLED", "CANCELLED"]
                },
                "filled_quantity": {
                  "$ref": "#/$defs/nonNegativeQuantity"
                },
                "version": {
                  "type": "integer",
                  "minimum": 1
                },
                "created_at": {
                  "type": "string",
                  "format": "date-time"
                },
                "updated_at": {
                  "type": "string",
                  "format": "date-time"
                },
                "evidence_digest": {
                  "$ref": "#/$defs/digest"
                },
                "safety": {
                  "$ref": "#/$defs/safety"
                },
                "external_calls": {
                  "const": 0
                }
              }
            },
            "fill": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "fill_id",
                "order_id",
                "tenant_id",
                "fill_ref",
                "quantity",
                "price",
                "observed_at",
                "recorded_at",
                "evidence_digest",
                "safety"
              ],
              "properties": {
                "fill_id": {
                  "type": "string",
                  "pattern": "^fill_[0-9a-f]{32}$"
                },
                "order_id": {
                  "type": "string",
                  "pattern": "^ord_[0-9a-f]{32}$"
                },
                "tenant_id": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 128
                },
                "fill_ref": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 256,
                  "description": "Synthetic deduplication reference, not a live venue fill ID."
                },
                "quantity": {
                  "$ref": "#/$defs/positiveQuantity"
                },
                "price": {
                  "allOf": [
                    {
                      "$ref": "#/$defs/decimal"
                    }
                  ],
                  "description": "Caller-supplied local fixture, not real-time market data."
                },
                "observed_at": {
                  "type": "string",
                  "format": "date-time"
                },
                "recorded_at": {
                  "type": "string",
                  "format": "date-time"
                },
                "evidence_digest": {
                  "allOf": [
                    {
                      "$ref": "#/$defs/digest"
                    }
                  ],
                  "description": "Legacy lowercase SHA-256 evidence digest. Consumers must not assume v2 fill-preimage semantics for already published v1 payloads."
                },
                "evidence_format": {
                  "enum": [
                    "SYNTHETIC_FILL_EVIDENCE_V1",
                    "LEGACY_COMMAND_PREIMAGE_V1"
                  ],
                  "description": "Optional compatibility tag. Historical v1 payloads may omit it; LEGACY_COMMAND_PREIMAGE_V1 identifies a repaired row whose digest is bound to the original immutable command preimage."
                },
                "safety": {
                  "$ref": "#/$defs/safety"
                }
              }
            }
          }
        }
      },
      "example": {
        "event_id": "evt-trade_00000000000000000000000000000000",
        "event_type": "certarail.trade.order.v1",
        "action": "ORDER_OPENED",
        "occurred_at": "2026-01-01T00:00:00Z",
        "tenant_id": "tenant_example",
        "order_id": "ord_00000000000000000000000000000000",
        "decision_id": "decision_example",
        "order": {
          "order_id": "ord_00000000000000000000000000000000",
          "request_id": "request_example",
          "tenant_id": "tenant_example",
          "decision_id": "decision_example",
          "event_contract": "certarail.trade.order.v1",
          "portfolio_ref": "portfolio_example",
          "approval_ref": "approval_example",
          "connection_id": "connection_example",
          "account_ref": "account_example",
          "client_order_id": "client_order_example",
          "instrument": {
            "base_asset": "BTC",
            "quote_currency": "RUB"
          },
          "side": "BUY",
          "order_type": "MARKET",
          "base_quantity": {
            "atomic_units": "1",
            "decimals": 0
          },
          "time_in_force": "IOC",
          "max_notional": {
            "currency": "RUB",
            "minor_units": 1
          },
          "command_id": "cmd_00000000000000000000000000000000",
          "provider_order_ref": "syn-order_00000000000000000000000000000000",
          "status": "OPEN",
          "submit_disposition": "ACKNOWLEDGED",
          "venue_state": "OPEN",
          "filled_quantity": {
            "atomic_units": "0",
            "decimals": 0
          },
          "version": 1,
          "created_at": "2026-01-01T00:00:00Z",
          "updated_at": "2026-01-01T00:00:00Z",
          "evidence_digest": "0000000000000000000000000000000000000000000000000000000000000000",
          "safety": {
            "environment": "sandbox",
            "production_enforceable": false,
            "monetary": false
          },
          "external_calls": 0
        },
        "evidence_digest": "0000000000000000000000000000000000000000000000000000000000000000",
        "safety": {
          "environment": "sandbox",
          "production_enforceable": false,
          "monetary": false
        },
        "external_calls": 0
      },
      "version": {
        "label": "v1",
        "value": 1,
        "asyncApiDocument": "1.3.1",
        "transportHeader": "1"
      },
      "correlationFields": {
        "state": "declared",
        "fields": [
          {
            "location": "payload",
            "path": "payload.event_id",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.tenant_id",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.order_id",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.decision_id",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.order.order_id",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.order.request_id",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.order.tenant_id",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.order.decision_id",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.order.subject_ref",
            "required": false,
            "type": "string",
            "description": "Optional legacy field. It may be absent or empty because v1 predates mandatory eligibility subject binding."
          },
          {
            "location": "payload",
            "path": "payload.order.portfolio_ref",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.order.approval_ref",
            "required": true,
            "type": "string",
            "description": "Correlation only; not evidence that CertaRail performed maker-checker approval."
          },
          {
            "location": "payload",
            "path": "payload.order.connection_id",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.order.account_ref",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.order.client_order_id",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.order.command_id",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.order.provider_order_ref",
            "required": true,
            "type": "string",
            "description": "Deterministic local reference, never a provider receipt."
          },
          {
            "location": "payload",
            "path": "payload.fill.fill_id",
            "required": false,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.fill.order_id",
            "required": false,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.fill.tenant_id",
            "required": false,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.fill.fill_ref",
            "required": false,
            "type": "string",
            "description": "Synthetic deduplication reference, not a live venue fill ID."
          },
          {
            "location": "header",
            "path": "headers.certarail-event-id",
            "required": true,
            "type": "string",
            "description": "Stable consumer deduplication identifier; equal to payload event_id."
          },
          {
            "location": "header",
            "path": "headers.traceparent",
            "required": false,
            "type": "string",
            "description": "Optional W3C Trace Context for the Kafka publisher attempt."
          },
          {
            "location": "header",
            "path": "headers.tracestate",
            "required": false,
            "type": "string",
            "description": "Optional W3C Trace Context tracestate value; omitted when empty."
          },
          {
            "location": "kafka-key",
            "path": "message.key",
            "required": null,
            "type": "string",
            "description": "Pseudonymous ordering key computed as `order_` plus the first\n16 bytes of SHA-256(tenant_id || NUL || order_id), encoded as\nlowercase hexadecimal. It is not authentication, tenancy,\nprovider identity, or proof of execution."
          }
        ],
        "summary": "Identifier, reference, trace, and Kafka-key fields are listed from the canonical schemas and message bindings."
      },
      "ordering": {
        "state": "declared",
        "scope": "one order key within certarail.trade.v1",
        "key": {
          "type": "string",
          "pattern": "^order_[0-9a-f]{32}$",
          "description": "Pseudonymous ordering key computed as `order_` plus the first\n16 bytes of SHA-256(tenant_id || NUL || order_id), encoded as\nlowercase hexadecimal. It is not authentication, tenancy,\nprovider identity, or proof of execution."
        },
        "summary": "Ordering is guaranteed only for one order key within certarail.trade.v1."
      },
      "retry": {
        "state": "declared",
        "guarantee": "at-least-once",
        "deduplicationKey": "payload.event_id",
        "deduplicationScope": "one event_id across v1 and v2",
        "summary": "at-least-once delivery is declared. Consumers must deduplicate by payload.event_id and tolerate redelivery."
      },
      "relatedOpenApiTags": ["Trading Sandbox"]
    },
    {
      "id": "event-certarail-trade-order-v2",
      "name": "certarail.trade.order.v2",
      "title": "Current durable sandbox trading order event v2",
      "summary": "Subject-bound BUY-only local order/fill/cancel fact with mandatory safety markers.",
      "description": "Current v2 requires non-empty eligibility-bound subject_ref and\nside=BUY. New orders receive immutable event_contract=v2, which routes\nthe full lifecycle to this schema. The event represents only CertaRail\nsandbox state. It is not a live venue execution, provider receipt,\nmarket price, bank/custody balance, asset movement, settlement record,\nor accounting posting.",
      "channel": {
        "key": "sandboxTradingOrders",
        "topic": "certarail.trade.v1",
        "description": "Durable PostgreSQL facts for the non-monetary trading sandbox. Frozen v1\nrecords may omit subject_ref and may contain SELL; current v2 records\nrequire eligibility-bound subject_ref, side=BUY and quote RUB/USD/EUR.\nImmutable order.event_contract selects the schema for the complete order\nlifecycle: migrated existing rows use v1 and new rows use v2. Historical\nv1 payloads may omit event_contract; subsequent v1 lifecycle facts carry\nit. A legacy SELL can only be read and locally cancelled; it cannot\nreceive a fill.\nConsumers MUST branch on\npayload.event_type and validate with the matching schema. Delivery is at\nleast once; consumers MUST deduplicate by payload.event_id across both\nversions and MUST NOT treat a version change as a new business fact.\nOrdering is guaranteed only for records sharing one order key in this\ntopic. No event proves a venue call,\nprovider acknowledgement, price source, settlement, custody balance,\nledger posting, asset movement, or legal permission to trade."
      },
      "publication": {
        "state": "producer-declared",
        "marker": "ASYNCAPI_SEND_OPERATION",
        "summary": "Canonical AsyncAPI declares a send operation. This documents the producer contract; it does not by itself prove a live or production publisher."
      },
      "producer": {
        "state": "declared",
        "operations": [
          {
            "id": "emitSandboxTradingOrderFact",
            "action": "send",
            "summary": "Publish a committed local non-monetary sandbox trading fact.",
            "description": "Immutable order.event_contract routes every fact in one order lifecycle.\nExisting migrated orders remain v1 and newly created orders are v2. No\nnew legacy order is accepted, and a legacy SELL may only be locally\ncancelled, never filled."
          }
        ],
        "summary": "Send operation emitSandboxTradingOrderFact is declared in canonical AsyncAPI. This is a contract declaration, not runtime evidence."
      },
      "consumer": {
        "state": "not-declared",
        "operations": [],
        "summary": "No named consumer operation is declared in canonical AsyncAPI; the catalog does not infer one."
      },
      "payload": {
        "schemaId": "urn:certarail:schema:event:certarail.trade.order.v2",
        "schemaTitle": "CertaRail durable sandbox trading order event v2",
        "schemaFormat": "application/schema+json;version=draft-2020-12",
        "schemaHref": "/events/certarail.trade.order.v2.schema.json",
        "schemaSha256": "2c251a4ff9e9748455d970b13dd80c78b52fcf11fab97f4a435bb9f123b236ab",
        "required": [
          "event_id",
          "event_type",
          "action",
          "occurred_at",
          "tenant_id",
          "order_id",
          "decision_id",
          "order",
          "evidence_digest",
          "safety",
          "external_calls"
        ],
        "properties": [
          {
            "name": "event_id",
            "required": true,
            "type": "string",
            "description": "",
            "constraints": ["pattern ^evt-trade_[0-9a-f]{32}$"]
          },
          {
            "name": "event_type",
            "required": true,
            "type": "string",
            "description": "",
            "constraints": ["const \"certarail.trade.order.v2\""]
          },
          {
            "name": "action",
            "required": true,
            "type": "string",
            "description": "",
            "constraints": [
              "ORDER_OPENED | SYNTHETIC_FILL_RECORDED | ORDER_CANCELLED"
            ]
          },
          {
            "name": "occurred_at",
            "required": true,
            "type": "string",
            "description": "",
            "constraints": ["format date-time"]
          },
          {
            "name": "tenant_id",
            "required": true,
            "type": "string",
            "description": "",
            "constraints": ["minLength 1", "maxLength 128"]
          },
          {
            "name": "order_id",
            "required": true,
            "type": "string",
            "description": "",
            "constraints": ["pattern ^ord_[0-9a-f]{32}$"]
          },
          {
            "name": "decision_id",
            "required": true,
            "type": "string",
            "description": "",
            "constraints": ["minLength 1", "maxLength 160"]
          },
          {
            "name": "order",
            "required": true,
            "type": "object",
            "description": "",
            "constraints": ["#/$defs/order"]
          },
          {
            "name": "fill",
            "required": false,
            "type": "object",
            "description": "",
            "constraints": ["#/$defs/fill"]
          },
          {
            "name": "evidence_digest",
            "required": true,
            "type": "string",
            "description": "",
            "constraints": ["#/$defs/digest"]
          },
          {
            "name": "safety",
            "required": true,
            "type": "object",
            "description": "",
            "constraints": ["#/$defs/safety"]
          },
          {
            "name": "external_calls",
            "required": true,
            "type": "number",
            "description": "",
            "constraints": ["const 0"]
          }
        ],
        "schema": {
          "$schema": "https://json-schema.org/draft/2020-12/schema",
          "$id": "urn:certarail:schema:event:certarail.trade.order.v2",
          "title": "CertaRail durable sandbox trading order event v2",
          "description": "Current PostgreSQL transactional-outbox fact from the BUY-only non-monetary sandbox. V2 requires the eligibility-bound opaque subject_ref and never asserts a live venue call, market price, settlement, custody balance, ledger posting, asset movement, or legal permission to trade.",
          "type": "object",
          "additionalProperties": false,
          "required": [
            "event_id",
            "event_type",
            "action",
            "occurred_at",
            "tenant_id",
            "order_id",
            "decision_id",
            "order",
            "evidence_digest",
            "safety",
            "external_calls"
          ],
          "properties": {
            "event_id": {
              "type": "string",
              "pattern": "^evt-trade_[0-9a-f]{32}$"
            },
            "event_type": {
              "const": "certarail.trade.order.v2"
            },
            "action": {
              "enum": [
                "ORDER_OPENED",
                "SYNTHETIC_FILL_RECORDED",
                "ORDER_CANCELLED"
              ]
            },
            "occurred_at": {
              "type": "string",
              "format": "date-time"
            },
            "tenant_id": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            },
            "order_id": {
              "type": "string",
              "pattern": "^ord_[0-9a-f]{32}$"
            },
            "decision_id": {
              "type": "string",
              "minLength": 1,
              "maxLength": 160
            },
            "order": {
              "$ref": "#/$defs/order"
            },
            "fill": {
              "$ref": "#/$defs/fill"
            },
            "evidence_digest": {
              "$ref": "#/$defs/digest"
            },
            "safety": {
              "$ref": "#/$defs/safety"
            },
            "external_calls": {
              "const": 0
            }
          },
          "allOf": [
            {
              "if": {
                "properties": {
                  "action": {
                    "const": "SYNTHETIC_FILL_RECORDED"
                  }
                },
                "required": ["action"]
              },
              "then": {
                "properties": {
                  "fill": {
                    "$ref": "#/$defs/fill"
                  }
                },
                "required": ["fill"]
              },
              "else": {
                "properties": {
                  "fill": false
                }
              }
            }
          ],
          "$defs": {
            "digest": {
              "type": "string",
              "pattern": "^[0-9a-f]{64}$"
            },
            "safety": {
              "type": "object",
              "additionalProperties": false,
              "required": ["environment", "production_enforceable", "monetary"],
              "properties": {
                "environment": {
                  "const": "sandbox"
                },
                "production_enforceable": {
                  "const": false
                },
                "monetary": {
                  "const": false
                }
              }
            },
            "instrument": {
              "type": "object",
              "additionalProperties": false,
              "required": ["base_asset", "quote_currency"],
              "properties": {
                "base_asset": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 64
                },
                "quote_currency": {
                  "enum": ["RUB", "USD", "EUR"]
                }
              }
            },
            "positiveQuantity": {
              "type": "object",
              "additionalProperties": false,
              "required": ["atomic_units", "decimals"],
              "properties": {
                "atomic_units": {
                  "type": "string",
                  "pattern": "^[1-9][0-9]{0,77}$"
                },
                "decimals": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 38
                }
              }
            },
            "nonNegativeQuantity": {
              "type": "object",
              "additionalProperties": false,
              "required": ["atomic_units", "decimals"],
              "properties": {
                "atomic_units": {
                  "type": "string",
                  "pattern": "^(0|[1-9][0-9]{0,77})$"
                },
                "decimals": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 38
                }
              }
            },
            "decimal": {
              "type": "object",
              "additionalProperties": false,
              "required": ["value", "scale"],
              "properties": {
                "value": {
                  "type": "string",
                  "pattern": "^[1-9][0-9]{0,77}$"
                },
                "scale": {
                  "type": "integer",
                  "minimum": 0,
                  "maximum": 38
                }
              }
            },
            "money": {
              "type": "object",
              "additionalProperties": false,
              "required": ["currency", "minor_units"],
              "properties": {
                "currency": {
                  "type": "string",
                  "pattern": "^[A-Z]{3}$"
                },
                "minor_units": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 9223372036854776000
                }
              }
            },
            "order": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "order_id",
                "request_id",
                "tenant_id",
                "decision_id",
                "event_contract",
                "subject_ref",
                "portfolio_ref",
                "approval_ref",
                "connection_id",
                "account_ref",
                "client_order_id",
                "instrument",
                "side",
                "order_type",
                "base_quantity",
                "time_in_force",
                "max_notional",
                "command_id",
                "provider_order_ref",
                "status",
                "submit_disposition",
                "venue_state",
                "filled_quantity",
                "version",
                "created_at",
                "updated_at",
                "evidence_digest",
                "safety",
                "external_calls"
              ],
              "properties": {
                "order_id": {
                  "type": "string",
                  "pattern": "^ord_[0-9a-f]{32}$"
                },
                "request_id": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 128
                },
                "tenant_id": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 128
                },
                "decision_id": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 160
                },
                "event_contract": {
                  "const": "certarail.trade.order.v2",
                  "description": "Immutable event-schema provenance assigned when a new order is created."
                },
                "subject_ref": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 256,
                  "description": "Opaque reference bound to client.subject_ref in the verified eligibility evidence."
                },
                "portfolio_ref": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 256
                },
                "approval_ref": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 256,
                  "description": "Correlation only; not evidence that CertaRail performed maker-checker approval."
                },
                "connection_id": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 128
                },
                "account_ref": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 256
                },
                "client_order_id": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 128
                },
                "instrument": {
                  "$ref": "#/$defs/instrument"
                },
                "side": {
                  "const": "BUY",
                  "description": "Current v2 sandbox events are BUY-only; SELL is not executable."
                },
                "order_type": {
                  "const": "MARKET"
                },
                "base_quantity": {
                  "$ref": "#/$defs/positiveQuantity"
                },
                "limit_price": {
                  "$ref": "#/$defs/decimal"
                },
                "time_in_force": {
                  "const": "IOC"
                },
                "max_notional": {
                  "$ref": "#/$defs/money"
                },
                "command_id": {
                  "type": "string",
                  "pattern": "^cmd_[0-9a-f]{32}$"
                },
                "provider_order_ref": {
                  "type": "string",
                  "pattern": "^syn-order_[0-9a-f]{32}$",
                  "description": "Deterministic local reference, never a provider receipt."
                },
                "status": {
                  "enum": ["OPEN", "PARTIALLY_FILLED", "FILLED", "CANCELLED"]
                },
                "submit_disposition": {
                  "const": "ACKNOWLEDGED",
                  "description": "Local PostgreSQL acknowledgement only."
                },
                "venue_state": {
                  "enum": ["OPEN", "PARTIALLY_FILLED", "FILLED", "CANCELLED"]
                },
                "filled_quantity": {
                  "$ref": "#/$defs/nonNegativeQuantity"
                },
                "version": {
                  "type": "integer",
                  "minimum": 1
                },
                "created_at": {
                  "type": "string",
                  "format": "date-time"
                },
                "updated_at": {
                  "type": "string",
                  "format": "date-time"
                },
                "evidence_digest": {
                  "$ref": "#/$defs/digest"
                },
                "safety": {
                  "$ref": "#/$defs/safety"
                },
                "external_calls": {
                  "const": 0
                }
              }
            },
            "fill": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "fill_id",
                "order_id",
                "tenant_id",
                "fill_ref",
                "quantity",
                "price",
                "observed_at",
                "recorded_at",
                "evidence_digest",
                "evidence_format",
                "safety"
              ],
              "properties": {
                "fill_id": {
                  "type": "string",
                  "pattern": "^fill_[0-9a-f]{32}$"
                },
                "order_id": {
                  "type": "string",
                  "pattern": "^ord_[0-9a-f]{32}$"
                },
                "tenant_id": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 128
                },
                "fill_ref": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 256,
                  "description": "Synthetic deduplication reference, not a live venue fill ID."
                },
                "quantity": {
                  "$ref": "#/$defs/positiveQuantity"
                },
                "price": {
                  "allOf": [
                    {
                      "$ref": "#/$defs/decimal"
                    }
                  ],
                  "description": "Caller-supplied local fixture, not real-time market data."
                },
                "observed_at": {
                  "type": "string",
                  "format": "date-time"
                },
                "recorded_at": {
                  "type": "string",
                  "format": "date-time"
                },
                "evidence_digest": {
                  "allOf": [
                    {
                      "$ref": "#/$defs/digest"
                    }
                  ],
                  "description": "SHA-256 of the persisted versioned canonical synthetic-fill evidence bytes."
                },
                "evidence_format": {
                  "const": "SYNTHETIC_FILL_EVIDENCE_V1",
                  "description": "Exact current canonical evidence format hashed by evidence_digest."
                },
                "safety": {
                  "$ref": "#/$defs/safety"
                }
              }
            }
          }
        }
      },
      "example": {
        "event_id": "evt-trade_00000000000000000000000000000000",
        "event_type": "certarail.trade.order.v2",
        "action": "ORDER_OPENED",
        "occurred_at": "2026-01-01T00:00:00Z",
        "tenant_id": "tenant_example",
        "order_id": "ord_00000000000000000000000000000000",
        "decision_id": "decision_example",
        "order": {
          "order_id": "ord_00000000000000000000000000000000",
          "request_id": "request_example",
          "tenant_id": "tenant_example",
          "decision_id": "decision_example",
          "event_contract": "certarail.trade.order.v2",
          "subject_ref": "subject_example",
          "portfolio_ref": "portfolio_example",
          "approval_ref": "approval_example",
          "connection_id": "connection_example",
          "account_ref": "account_example",
          "client_order_id": "client_order_example",
          "instrument": {
            "base_asset": "BTC",
            "quote_currency": "RUB"
          },
          "side": "BUY",
          "order_type": "MARKET",
          "base_quantity": {
            "atomic_units": "1",
            "decimals": 0
          },
          "time_in_force": "IOC",
          "max_notional": {
            "currency": "RUB",
            "minor_units": 1
          },
          "command_id": "cmd_00000000000000000000000000000000",
          "provider_order_ref": "syn-order_00000000000000000000000000000000",
          "status": "OPEN",
          "submit_disposition": "ACKNOWLEDGED",
          "venue_state": "OPEN",
          "filled_quantity": {
            "atomic_units": "0",
            "decimals": 0
          },
          "version": 1,
          "created_at": "2026-01-01T00:00:00Z",
          "updated_at": "2026-01-01T00:00:00Z",
          "evidence_digest": "0000000000000000000000000000000000000000000000000000000000000000",
          "safety": {
            "environment": "sandbox",
            "production_enforceable": false,
            "monetary": false
          },
          "external_calls": 0
        },
        "evidence_digest": "0000000000000000000000000000000000000000000000000000000000000000",
        "safety": {
          "environment": "sandbox",
          "production_enforceable": false,
          "monetary": false
        },
        "external_calls": 0
      },
      "version": {
        "label": "v2",
        "value": 2,
        "asyncApiDocument": "1.3.1",
        "transportHeader": "1"
      },
      "correlationFields": {
        "state": "declared",
        "fields": [
          {
            "location": "payload",
            "path": "payload.event_id",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.tenant_id",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.order_id",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.decision_id",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.order.order_id",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.order.request_id",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.order.tenant_id",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.order.decision_id",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.order.subject_ref",
            "required": true,
            "type": "string",
            "description": "Opaque reference bound to client.subject_ref in the verified eligibility evidence."
          },
          {
            "location": "payload",
            "path": "payload.order.portfolio_ref",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.order.approval_ref",
            "required": true,
            "type": "string",
            "description": "Correlation only; not evidence that CertaRail performed maker-checker approval."
          },
          {
            "location": "payload",
            "path": "payload.order.connection_id",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.order.account_ref",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.order.client_order_id",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.order.command_id",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.order.provider_order_ref",
            "required": true,
            "type": "string",
            "description": "Deterministic local reference, never a provider receipt."
          },
          {
            "location": "payload",
            "path": "payload.fill.fill_id",
            "required": false,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.fill.order_id",
            "required": false,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.fill.tenant_id",
            "required": false,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.fill.fill_ref",
            "required": false,
            "type": "string",
            "description": "Synthetic deduplication reference, not a live venue fill ID."
          },
          {
            "location": "header",
            "path": "headers.certarail-event-id",
            "required": true,
            "type": "string",
            "description": "Stable consumer deduplication identifier; equal to payload event_id."
          },
          {
            "location": "header",
            "path": "headers.traceparent",
            "required": false,
            "type": "string",
            "description": "Optional W3C Trace Context for the Kafka publisher attempt."
          },
          {
            "location": "header",
            "path": "headers.tracestate",
            "required": false,
            "type": "string",
            "description": "Optional W3C Trace Context tracestate value; omitted when empty."
          },
          {
            "location": "kafka-key",
            "path": "message.key",
            "required": null,
            "type": "string",
            "description": "Pseudonymous ordering key computed as `order_` plus the first\n16 bytes of SHA-256(tenant_id || NUL || order_id), encoded as\nlowercase hexadecimal. It is not authentication, tenancy,\nprovider identity, or proof of execution."
          }
        ],
        "summary": "Identifier, reference, trace, and Kafka-key fields are listed from the canonical schemas and message bindings."
      },
      "ordering": {
        "state": "declared",
        "scope": "one order key within certarail.trade.v1",
        "key": {
          "type": "string",
          "pattern": "^order_[0-9a-f]{32}$",
          "description": "Pseudonymous ordering key computed as `order_` plus the first\n16 bytes of SHA-256(tenant_id || NUL || order_id), encoded as\nlowercase hexadecimal. It is not authentication, tenancy,\nprovider identity, or proof of execution."
        },
        "summary": "Ordering is guaranteed only for one order key within certarail.trade.v1."
      },
      "retry": {
        "state": "declared",
        "guarantee": "at-least-once",
        "deduplicationKey": "payload.event_id",
        "deduplicationScope": "one event_id across v1 and v2",
        "summary": "at-least-once delivery is declared. Consumers must deduplicate by payload.event_id and tolerate redelivery."
      },
      "relatedOpenApiTags": ["Trading Sandbox"]
    },
    {
      "id": "event-certarail-checkout-lifecycle-v1",
      "name": "certarail.checkout.lifecycle.v1",
      "title": "Crypto Checkout lifecycle event v1",
      "summary": "Schema-only checkout/session/deal state-change candidate; NOT_PRODUCED.",
      "description": "Compatibility design only. The current checkout runtime does not emit\nthis Kafka event. Partner webhook delivery signs exact HTTP body bytes\nunder the separately documented webhook contract and must not be\ninferred from this schema.",
      "channel": {
        "key": "checkoutLifecycle",
        "topic": "certarail.checkout.lifecycle.v1",
        "description": "Schema-only candidate for PII-minimized Crypto Checkout state-change\nevidence. The current checkout runtime does not create an outbox row or\npublish this Kafka event. Independent admission, quote, payment,\nexecution, delivery, and ledger axes remain authoritative in the\nPostgreSQL-backed checkout projection. No schema proves a real payment,\nvenue trade, custody balance, or blockchain transfer."
      },
      "publication": {
        "state": "not-produced",
        "marker": "NOT_PRODUCED",
        "summary": "Canonical AsyncAPI marks this Kafka event as NOT_PRODUCED. Its schema is browsable, but it is not evidence of a running publisher."
      },
      "producer": {
        "state": "not-produced",
        "operations": [],
        "summary": "No producer operation is declared because the canonical Kafka publication state is NOT_PRODUCED."
      },
      "consumer": {
        "state": "not-declared",
        "operations": [],
        "summary": "No named consumer operation is declared in canonical AsyncAPI; the catalog does not infer one."
      },
      "payload": {
        "schemaId": "urn:certarail:schema:event:certarail.checkout.lifecycle.v1",
        "schemaTitle": "CertaRail checkout lifecycle event v1",
        "schemaFormat": "application/schema+json;version=draft-2020-12",
        "schemaHref": "/events/certarail.checkout.lifecycle.v1.schema.json",
        "schemaSha256": "7134e3b7ccc160f2711ea0aceebf838bd6219407230aa3213758183765fa97e3",
        "required": [
          "event_id",
          "event_type",
          "event_version",
          "tenant_id",
          "occurred_at",
          "aggregate_id",
          "correlation_id",
          "sequence",
          "payload",
          "safety"
        ],
        "properties": [
          {
            "name": "event_id",
            "required": true,
            "type": "string",
            "description": "",
            "constraints": ["pattern ^checkout_evt_[A-Za-z0-9._:/-]{1,112}$"]
          },
          {
            "name": "event_type",
            "required": true,
            "type": "string",
            "description": "",
            "constraints": [
              "checkout.session.created | checkout.session.expired | deal.action_required | deal.review | +13"
            ]
          },
          {
            "name": "event_version",
            "required": true,
            "type": "number",
            "description": "",
            "constraints": ["const 1"]
          },
          {
            "name": "tenant_id",
            "required": true,
            "type": "string",
            "description": "",
            "constraints": ["minLength 1", "maxLength 128"]
          },
          {
            "name": "occurred_at",
            "required": true,
            "type": "string",
            "description": "",
            "constraints": ["format date-time"]
          },
          {
            "name": "aggregate_id",
            "required": true,
            "type": "string",
            "description": "",
            "constraints": [
              "pattern ^(checkout_|deal_)[A-Za-z0-9._:/-]{1,120}$"
            ]
          },
          {
            "name": "correlation_id",
            "required": true,
            "type": "string",
            "description": "",
            "constraints": ["minLength 1", "maxLength 128"]
          },
          {
            "name": "sequence",
            "required": true,
            "type": "integer",
            "description": "",
            "constraints": ["minimum 1"]
          },
          {
            "name": "payload",
            "required": true,
            "type": "object",
            "description": "",
            "constraints": ["#/$defs/safePayload"]
          },
          {
            "name": "safety",
            "required": true,
            "type": "object",
            "description": "",
            "constraints": ["#/$defs/safety"]
          }
        ],
        "schema": {
          "$schema": "https://json-schema.org/draft/2020-12/schema",
          "$id": "urn:certarail:schema:event:certarail.checkout.lifecycle.v1",
          "title": "CertaRail checkout lifecycle event v1",
          "description": "PII-minimized lifecycle evidence for the sandbox Crypto Checkout. This event is not proof of a real payment, venue execution, custody balance, or blockchain transfer.",
          "type": "object",
          "additionalProperties": false,
          "required": [
            "event_id",
            "event_type",
            "event_version",
            "tenant_id",
            "occurred_at",
            "aggregate_id",
            "correlation_id",
            "sequence",
            "payload",
            "safety"
          ],
          "properties": {
            "event_id": {
              "type": "string",
              "pattern": "^checkout_evt_[A-Za-z0-9._:/-]{1,112}$"
            },
            "event_type": {
              "enum": [
                "checkout.session.created",
                "checkout.session.expired",
                "deal.action_required",
                "deal.review",
                "deal.confirmed",
                "payment.pending",
                "payment.confirmed",
                "payment.failed",
                "execution.submitted",
                "execution.unknown",
                "execution.filled",
                "delivery.pending",
                "delivery.confirmed",
                "deal.completed",
                "deal.failed",
                "refund.pending",
                "refund.completed"
              ]
            },
            "event_version": {
              "const": 1
            },
            "tenant_id": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            },
            "occurred_at": {
              "type": "string",
              "format": "date-time"
            },
            "aggregate_id": {
              "type": "string",
              "pattern": "^(checkout_|deal_)[A-Za-z0-9._:/-]{1,120}$"
            },
            "correlation_id": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            },
            "sequence": {
              "type": "integer",
              "minimum": 1
            },
            "payload": {
              "$ref": "#/$defs/safePayload"
            },
            "safety": {
              "$ref": "#/$defs/safety"
            }
          },
          "$defs": {
            "axes": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "admission",
                "quote",
                "payment",
                "execution",
                "delivery",
                "ledger"
              ],
              "properties": {
                "admission": {
                  "enum": [
                    "NOT_STARTED",
                    "EVALUATING",
                    "ALLOW",
                    "DENY",
                    "REVIEW",
                    "ACTION_REQUIRED"
                  ]
                },
                "quote": {
                  "enum": [
                    "NOT_REQUESTED",
                    "REQUESTING",
                    "AVAILABLE",
                    "EXPIRED",
                    "REJECTED",
                    "SUPERSEDED"
                  ]
                },
                "payment": {
                  "enum": [
                    "NOT_STARTED",
                    "RESERVING",
                    "RESERVED",
                    "PENDING",
                    "CONFIRMED",
                    "FAILED",
                    "RELEASE_PENDING",
                    "RELEASED",
                    "REFUND_PENDING",
                    "REFUNDED",
                    "UNKNOWN"
                  ]
                },
                "execution": {
                  "enum": [
                    "NOT_STARTED",
                    "SUBMITTING",
                    "UNKNOWN",
                    "ACKNOWLEDGED",
                    "PARTIALLY_FILLED",
                    "FILLED",
                    "CANCEL_PENDING",
                    "CANCELLED",
                    "REJECTED",
                    "FAILED"
                  ]
                },
                "delivery": {
                  "enum": [
                    "NOT_STARTED",
                    "PENDING",
                    "PROCESSING",
                    "CONFIRMED",
                    "FAILED",
                    "UNKNOWN"
                  ]
                },
                "ledger": {
                  "enum": [
                    "NOT_STARTED",
                    "RESERVED",
                    "POSTED",
                    "REVERSED",
                    "RECONCILIATION_REQUIRED"
                  ]
                }
              }
            },
            "safePayload": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "checkout_session_reference",
                "overall_status",
                "axes"
              ],
              "properties": {
                "checkout_session_reference": {
                  "type": "string",
                  "pattern": "^checkout_[A-Za-z0-9._:/-]{1,120}$"
                },
                "deal_reference": {
                  "type": "string",
                  "pattern": "^deal_[A-Za-z0-9._:/-]{1,120}$"
                },
                "overall_status": {
                  "enum": [
                    "DRAFT",
                    "CHECKING",
                    "ACTION_REQUIRED",
                    "READY_TO_CONFIRM",
                    "QUOTE_EXPIRED",
                    "PROCESSING_PAYMENT",
                    "EXECUTING",
                    "DELIVERING",
                    "COMPLETED",
                    "REVIEW",
                    "FAILED",
                    "CANCELLED",
                    "REFUNDING"
                  ]
                },
                "axes": {
                  "$ref": "#/$defs/axes"
                },
                "action": {
                  "enum": [
                    "RETRY",
                    "REFRESH_QUOTE",
                    "REDUCE_AMOUNT",
                    "COMPLETE_VERIFICATION",
                    "CHANGE_PAYMENT_METHOD",
                    "CONTACT_SUPPORT",
                    "RETURN_TO_PARTNER",
                    "WAIT",
                    "NONE"
                  ]
                },
                "receipt_reference": {
                  "type": "string",
                  "pattern": "^receipt_[A-Za-z0-9._:/-]{1,118}$"
                }
              }
            },
            "safety": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "environment",
                "external_calls",
                "monetary",
                "production_enforceable",
                "execution_mode"
              ],
              "properties": {
                "environment": {
                  "const": "SANDBOX"
                },
                "external_calls": {
                  "const": 0
                },
                "monetary": {
                  "const": false
                },
                "production_enforceable": {
                  "const": false
                },
                "execution_mode": {
                  "const": "SANDBOX"
                }
              }
            }
          }
        }
      },
      "example": {
        "event_id": "checkout_evt_A",
        "event_type": "checkout.session.created",
        "event_version": 1,
        "tenant_id": "tenant_example",
        "occurred_at": "2026-01-01T00:00:00Z",
        "aggregate_id": "checkout_A",
        "correlation_id": "correlation_example",
        "sequence": 1,
        "payload": {
          "checkout_session_reference": "checkout_A",
          "overall_status": "DRAFT",
          "axes": {
            "admission": "NOT_STARTED",
            "quote": "NOT_REQUESTED",
            "payment": "NOT_STARTED",
            "execution": "NOT_STARTED",
            "delivery": "NOT_STARTED",
            "ledger": "NOT_STARTED"
          }
        },
        "safety": {
          "environment": "SANDBOX",
          "external_calls": 0,
          "monetary": false,
          "production_enforceable": false,
          "execution_mode": "SANDBOX"
        }
      },
      "version": {
        "label": "v1",
        "value": 1,
        "asyncApiDocument": "1.3.1",
        "transportHeader": "1"
      },
      "correlationFields": {
        "state": "declared",
        "fields": [
          {
            "location": "payload",
            "path": "payload.event_id",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.tenant_id",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.aggregate_id",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.correlation_id",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.payload.checkout_session_reference",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.payload.deal_reference",
            "required": false,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.payload.receipt_reference",
            "required": false,
            "type": "string",
            "description": ""
          },
          {
            "location": "header",
            "path": "headers.certarail-event-id",
            "required": true,
            "type": "string",
            "description": "Stable consumer deduplication identifier; equal to payload event_id."
          },
          {
            "location": "header",
            "path": "headers.traceparent",
            "required": false,
            "type": "string",
            "description": "Optional W3C Trace Context for the Kafka publisher attempt."
          },
          {
            "location": "header",
            "path": "headers.tracestate",
            "required": false,
            "type": "string",
            "description": "Optional W3C Trace Context tracestate value; omitted when empty."
          },
          {
            "location": "kafka-key",
            "path": "message.key",
            "required": null,
            "type": "string",
            "description": "Tenant-scoped aggregate ordering key; never an authentication credential."
          }
        ],
        "summary": "Identifier, reference, trace, and Kafka-key fields are listed from the canonical schemas and message bindings."
      },
      "ordering": {
        "state": "contract-only",
        "scope": null,
        "key": {
          "type": "string",
          "pattern": "^(checkout_|deal_)[A-Za-z0-9._:/-]{1,120}$",
          "description": "Tenant-scoped aggregate ordering key; never an authentication credential."
        },
        "summary": "A Kafka key schema is documented for compatibility, but runtime ordering is not claimed while publication is NOT_PRODUCED."
      },
      "retry": {
        "state": "not-applicable",
        "guarantee": null,
        "deduplicationKey": null,
        "deduplicationScope": null,
        "summary": "Kafka retry and redelivery semantics do not apply while the canonical publication state is NOT_PRODUCED. Other transport retries are separate contracts."
      },
      "relatedOpenApiTags": ["Crypto Checkout"]
    },
    {
      "id": "event-certarail-checkout-partner-delivery-v1",
      "name": "certarail.checkout.partner-delivery.v1",
      "title": "Crypto Checkout partner webhook delivery event v1",
      "summary": "Sandbox Inbox digest candidate derived from an existing outbox fact; Kafka NOT_PRODUCED.",
      "description": "PostgreSQL-backed sandbox Inbox delivery evidence exists and\ncheckout.completed is linked to the tenant movement outbox fact. The\ncurrent runtime does not emit this candidate as a Kafka event.",
      "channel": {
        "key": "checkoutPartnerDeliveries",
        "topic": "certarail.checkout.partner-delivery.v1",
        "description": "The sandbox Webhook Inbox persists signed delivery attempts in\nPostgreSQL. A checkout.completed delivery is bound by\nsource_outbox_event_id to the existing tenant movement outbox fact; the\nretry job is transport state, not a second event source. This Kafka\nchannel itself remains unpublished. The candidate payload carries only\nan endpoint reference and digest of the exact replayed body; it excludes\nthe endpoint URL, signing secret, customer reference, amounts, and\nprovider references. QUARANTINED requires an operator-owned remediation\npath; this schema does not authorize requeue by itself."
      },
      "publication": {
        "state": "not-produced",
        "marker": "NOT_PRODUCED",
        "summary": "Canonical AsyncAPI marks this Kafka event as NOT_PRODUCED. Its schema is browsable, but it is not evidence of a running publisher."
      },
      "producer": {
        "state": "not-produced",
        "operations": [],
        "summary": "No producer operation is declared because the canonical Kafka publication state is NOT_PRODUCED."
      },
      "consumer": {
        "state": "not-declared",
        "operations": [],
        "summary": "No named consumer operation is declared in canonical AsyncAPI; the catalog does not infer one."
      },
      "payload": {
        "schemaId": "urn:certarail:schema:event:certarail.checkout.partner-delivery.v1",
        "schemaTitle": "CertaRail checkout partner delivery event v1",
        "schemaFormat": "application/schema+json;version=draft-2020-12",
        "schemaHref": "/events/certarail.checkout.partner-delivery.v1.schema.json",
        "schemaSha256": "878a065b058642e7fc32165bafc65f052f9aa49241c2bfb1df970fa491643851",
        "required": [
          "delivery_event_id",
          "event_type",
          "event_version",
          "tenant_id",
          "aggregate_id",
          "correlation_id",
          "occurred_at",
          "partner_endpoint_reference",
          "key_id",
          "body_sha256",
          "attempt",
          "state",
          "safety"
        ],
        "properties": [
          {
            "name": "delivery_event_id",
            "required": true,
            "type": "string",
            "description": "",
            "constraints": ["pattern ^webhook_evt_[A-Za-z0-9._:/-]{1,111}$"]
          },
          {
            "name": "event_type",
            "required": true,
            "type": "string",
            "description": "",
            "constraints": ["const \"certarail.checkout.partner-delivery.v1\""]
          },
          {
            "name": "event_version",
            "required": true,
            "type": "number",
            "description": "",
            "constraints": ["const 1"]
          },
          {
            "name": "tenant_id",
            "required": true,
            "type": "string",
            "description": "",
            "constraints": ["minLength 1", "maxLength 128"]
          },
          {
            "name": "aggregate_id",
            "required": true,
            "type": "string",
            "description": "",
            "constraints": [
              "pattern ^(checkout_|deal_)[A-Za-z0-9._:/-]{1,120}$"
            ]
          },
          {
            "name": "correlation_id",
            "required": true,
            "type": "string",
            "description": "",
            "constraints": ["minLength 1", "maxLength 128"]
          },
          {
            "name": "occurred_at",
            "required": true,
            "type": "string",
            "description": "",
            "constraints": ["format date-time"]
          },
          {
            "name": "partner_endpoint_reference",
            "required": true,
            "type": "string",
            "description": "",
            "constraints": ["minLength 1", "maxLength 160"]
          },
          {
            "name": "key_id",
            "required": true,
            "type": "string",
            "description": "",
            "constraints": ["minLength 1", "maxLength 96"]
          },
          {
            "name": "body_sha256",
            "required": true,
            "type": "string",
            "description": "",
            "constraints": ["pattern ^[a-f0-9]{64}$"]
          },
          {
            "name": "attempt",
            "required": true,
            "type": "integer",
            "description": "",
            "constraints": ["minimum 1", "maximum 32"]
          },
          {
            "name": "state",
            "required": true,
            "type": "string",
            "description": "",
            "constraints": [
              "PENDING | IN_FLIGHT | DELIVERED | RETRY_SCHEDULED | +1"
            ]
          },
          {
            "name": "next_attempt_at",
            "required": false,
            "type": "string",
            "description": "",
            "constraints": ["format date-time"]
          },
          {
            "name": "delivered_at",
            "required": false,
            "type": "string",
            "description": "",
            "constraints": ["format date-time"]
          },
          {
            "name": "safety",
            "required": true,
            "type": "object",
            "description": "",
            "constraints": []
          }
        ],
        "schema": {
          "$schema": "https://json-schema.org/draft/2020-12/schema",
          "$id": "urn:certarail:schema:event:certarail.checkout.partner-delivery.v1",
          "title": "CertaRail checkout partner delivery event v1",
          "description": "Durable, PII-minimized partner-webhook delivery evidence. The exact body bytes are replayed for retries; URLs and signing secrets are deliberately excluded.",
          "type": "object",
          "additionalProperties": false,
          "required": [
            "delivery_event_id",
            "event_type",
            "event_version",
            "tenant_id",
            "aggregate_id",
            "correlation_id",
            "occurred_at",
            "partner_endpoint_reference",
            "key_id",
            "body_sha256",
            "attempt",
            "state",
            "safety"
          ],
          "properties": {
            "delivery_event_id": {
              "type": "string",
              "pattern": "^webhook_evt_[A-Za-z0-9._:/-]{1,111}$"
            },
            "event_type": {
              "const": "certarail.checkout.partner-delivery.v1"
            },
            "event_version": {
              "const": 1
            },
            "tenant_id": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            },
            "aggregate_id": {
              "type": "string",
              "pattern": "^(checkout_|deal_)[A-Za-z0-9._:/-]{1,120}$"
            },
            "correlation_id": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128
            },
            "occurred_at": {
              "type": "string",
              "format": "date-time"
            },
            "partner_endpoint_reference": {
              "type": "string",
              "minLength": 1,
              "maxLength": 160
            },
            "key_id": {
              "type": "string",
              "minLength": 1,
              "maxLength": 96
            },
            "body_sha256": {
              "type": "string",
              "pattern": "^[a-f0-9]{64}$"
            },
            "attempt": {
              "type": "integer",
              "minimum": 1,
              "maximum": 32
            },
            "state": {
              "enum": [
                "PENDING",
                "IN_FLIGHT",
                "DELIVERED",
                "RETRY_SCHEDULED",
                "QUARANTINED"
              ]
            },
            "next_attempt_at": {
              "type": "string",
              "format": "date-time"
            },
            "delivered_at": {
              "type": "string",
              "format": "date-time"
            },
            "safety": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "environment",
                "execution_mode",
                "external_calls",
                "monetary",
                "production_enforceable"
              ],
              "properties": {
                "environment": {
                  "const": "SANDBOX"
                },
                "execution_mode": {
                  "const": "SANDBOX"
                },
                "external_calls": {
                  "const": 0
                },
                "monetary": {
                  "const": false
                },
                "production_enforceable": {
                  "const": false
                }
              }
            }
          }
        }
      },
      "example": {
        "delivery_event_id": "webhook_evt_A",
        "event_type": "certarail.checkout.partner-delivery.v1",
        "event_version": 1,
        "tenant_id": "tenant_example",
        "aggregate_id": "checkout_A",
        "correlation_id": "correlation_example",
        "occurred_at": "2026-01-01T00:00:00Z",
        "partner_endpoint_reference": "example",
        "key_id": "key_example",
        "body_sha256": "0000000000000000000000000000000000000000000000000000000000000000",
        "attempt": 1,
        "state": "PENDING",
        "safety": {
          "environment": "SANDBOX",
          "execution_mode": "SANDBOX",
          "external_calls": 0,
          "monetary": false,
          "production_enforceable": false
        }
      },
      "version": {
        "label": "v1",
        "value": 1,
        "asyncApiDocument": "1.3.1",
        "transportHeader": "1"
      },
      "correlationFields": {
        "state": "declared",
        "fields": [
          {
            "location": "payload",
            "path": "payload.delivery_event_id",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.tenant_id",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.aggregate_id",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.correlation_id",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.partner_endpoint_reference",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "payload",
            "path": "payload.key_id",
            "required": true,
            "type": "string",
            "description": ""
          },
          {
            "location": "header",
            "path": "headers.certarail-event-id",
            "required": true,
            "type": "string",
            "description": "Stable consumer deduplication identifier; equal to payload event_id."
          },
          {
            "location": "header",
            "path": "headers.traceparent",
            "required": false,
            "type": "string",
            "description": "Optional W3C Trace Context for the Kafka publisher attempt."
          },
          {
            "location": "header",
            "path": "headers.tracestate",
            "required": false,
            "type": "string",
            "description": "Optional W3C Trace Context tracestate value; omitted when empty."
          },
          {
            "location": "kafka-key",
            "path": "message.key",
            "required": null,
            "type": "string",
            "description": "Tenant-scoped aggregate ordering key; never an endpoint or signing secret."
          }
        ],
        "summary": "Identifier, reference, trace, and Kafka-key fields are listed from the canonical schemas and message bindings."
      },
      "ordering": {
        "state": "contract-only",
        "scope": null,
        "key": {
          "type": "string",
          "pattern": "^(checkout_|deal_)[A-Za-z0-9._:/-]{1,120}$",
          "description": "Tenant-scoped aggregate ordering key; never an endpoint or signing secret."
        },
        "summary": "A Kafka key schema is documented for compatibility, but runtime ordering is not claimed while publication is NOT_PRODUCED."
      },
      "retry": {
        "state": "not-applicable",
        "guarantee": null,
        "deduplicationKey": null,
        "deduplicationScope": null,
        "summary": "Kafka retry and redelivery semantics do not apply while the canonical publication state is NOT_PRODUCED. Other transport retries are separate contracts."
      },
      "relatedOpenApiTags": ["Crypto Checkout"]
    }
  ]
}
