{
 "openapi": "3.0.3",
 "info": {
  "title": "StateSet EDI",
  "description": "X12 EDI platform for StateSet commerce: inbound 850/860/945/997 translation to VES events, outbound 855/856/810/940 generation, 997/TA1 acknowledgments, and trading partner management.\n\nAuthenticate with `Authorization: Bearer <token>` \u2014 either the admin token or a partner API key scoped to that partner's routes.",
  "contact": {
   "name": "Stateset Inc."
  },
  "license": {
   "name": "BUSL-1.1"
  },
  "version": "0.4.0"
 },
 "paths": {
  "/health": {
   "get": {
    "tags": [
     "system"
    ],
    "operationId": "health",
    "responses": {
     "200": {
      "description": "Service health and outbox depth"
     }
    }
   }
  },
  "/live": {
   "get": {
    "tags": [
     "system"
    ],
    "summary": "Liveness probe: is the process up and the async runtime responsive? This",
    "description": "deliberately does NOT probe the database. A liveness probe that fails on a\nDB outage makes the kubelet restart every replica, turning a recoverable\ndependency blip into a self-inflicted crash-loop. Readiness (`/health`)\nowns dependency health and load-balancer eviction; liveness only owns\n\"should this container be killed and recreated\".",
    "operationId": "live",
    "responses": {
     "200": {
      "description": "Process is alive"
     }
    }
   }
  },
  "/v1/adapters": {
   "get": {
    "tags": [
     "partners"
    ],
    "summary": "The packaged back-end integration catalog (ERP/WMS/TMS/e-commerce/carrier),",
    "description": "optionally filtered by system class or the event type an adapter consumes.",
    "operationId": "list_adapters",
    "parameters": [
     {
      "name": "kind",
      "in": "query",
      "description": "System class filter",
      "required": false,
      "schema": {
       "type": "string",
       "nullable": true
      }
     },
     {
      "name": "consumes",
      "in": "query",
      "description": "Canonical event type filter",
      "required": false,
      "schema": {
       "type": "string",
       "nullable": true
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Back-end adapter catalog",
      "content": {
       "application/json": {
        "schema": {
         "type": "array",
         "items": {
          "$ref": "#/components/schemas/AdapterDescriptor"
         }
        }
       }
      }
     }
    }
   }
  },
  "/v1/adapters/plan": {
   "post": {
    "tags": [
     "partners"
    ],
    "summary": "Plans the back-end actions a canonical event would trigger across every",
    "description": "catalogued adapter that consumes it \u2014 the routing preview for the event\nstream. Body is a VES event (`event_type`, `entity_type`, `entity_id`).",
    "operationId": "plan_adapters",
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/EdiEvent"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "description": "Planned back-end actions",
      "content": {
       "application/json": {
        "schema": {
         "type": "array",
         "items": {
          "$ref": "#/components/schemas/AdapterAction"
         }
        }
       }
      }
     },
     "422": {
      "description": "Unparseable event"
     }
    }
   }
  },
  "/v1/analytics": {
   "get": {
    "tags": [
     "operations"
    ],
    "summary": "Operational analytics: volume, error rate, throughput trend, and",
    "description": "order-to-cash cycle time by partner and transaction set.",
    "operationId": "analytics",
    "responses": {
     "200": {
      "description": "Analytics report",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/AnalyticsReport"
        }
       }
      }
     },
     "403": {
      "description": "Admin credential required"
     }
    }
   }
  },
  "/v1/analytics/export": {
   "get": {
    "tags": [
     "operations"
    ],
    "summary": "Per-partner analytics as a CSV download.",
    "operationId": "analytics_export",
    "responses": {
     "200": {
      "description": "Per-partner analytics CSV"
     },
     "403": {
      "description": "Admin credential required"
     }
    }
   }
  },
  "/v1/artifacts/conformance": {
   "get": {
    "tags": [
     "operations"
    ],
    "summary": "WS-1 acceptance evidence: for each packaged retail connector, instantiate the",
    "description": "partner and generate the GS1 carton label, packing slip (PDF), commercial\ninvoice, and 856 from one canonical shipment, then validate each against the\npartner's spec. Returns a pass/fail conformance matrix.",
    "operationId": "artifacts_conformance",
    "parameters": [
     {
      "name": "limit",
      "in": "query",
      "description": "Run only the first N connectors",
      "required": false,
      "schema": {
       "type": "integer",
       "nullable": true,
       "minimum": 0
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Per-connector artifact conformance matrix"
     }
    }
   }
  },
  "/v1/as1/inbound": {
   "post": {
    "tags": [
     "inbound"
    ],
    "summary": "Inbound AS1 (EDI-over-email) receive path: the mail service forwards a",
    "description": "received email as JSON; we extract the EDI interchange and run it through\nthe standard inbound pipeline (parse \u2192 validate \u2192 acknowledge \u2192 translate \u2192\nsync). Bearer-authenticated \u2014 the mail service is a trusted first-party\ncaller carrying the platform token.",
    "operationId": "as1_inbound",
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/crate.as1.As1InboundEmail"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "description": "Processing result with 997/TA1 acknowledgment",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/InboundResult"
        }
       }
      }
     },
     "404": {
      "description": "No partner matches the ISA sender"
     },
     "409": {
      "description": "Duplicate interchange control number"
     },
     "422": {
      "description": "Email carries no EDI attachment/body, or unparseable"
     }
    }
   }
  },
  "/v1/as2": {
   "post": {
    "tags": [
     "inbound"
    ],
    "summary": "Inbound AS2 endpoint: receives an EDI document over AS2 and returns a",
    "description": "synchronous MDN receipt.\n\nUnauthenticated by transport design \u2014 AS2 partners are identified by their\n`AS2-From`/`AS2-To` headers (and, once the `Security` seam lands, by their\nS/MIME signature), not by our bearer token. Per AS2 semantics the MDN is\nreturned with HTTP 200 even when the EDI is rejected; the *disposition*\ninside the MDN carries the accept/reject verdict. Only transport-level\nfailures produce a non-200.",
    "operationId": "as2_inbound",
    "requestBody": {
     "description": "AS2 message body (EDI payload)",
     "content": {
      "application/edi-x12": {
       "schema": {
        "type": "string"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "description": "MDN receipt (multipart/report)"
     }
    }
   }
  },
  "/v1/as2/identity": {
   "post": {
    "tags": [
     "operations"
    ],
    "summary": "Rotates the AS2 signing/decryption identity without a restart. The new",
    "description": "key + certificate are validated (parseable, not expired) before the\natomic swap; in-flight requests finish with the identity they started\nwith. The cert-expiry monitor tracks the new certificate immediately.",
    "operationId": "rotate_as2_identity",
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/RotateAs2IdentityBody"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "description": "Identity rotated"
     },
     "403": {
      "description": "Platform-admin credential required"
     },
     "422": {
      "description": "Key/certificate invalid or expired"
     }
    }
   }
  },
  "/v1/as2/mdn": {
   "post": {
    "tags": [
     "operations"
    ],
    "summary": "Receives an **asynchronous MDN**: a partner POSTs the receipt for a message",
    "description": "we sent earlier (AS2 async mode). We match it to the tracked delivery by\n`Original-Message-ID`, verify the disposition and \u2014 recomputing the MIC from\nthe delivery's stored payload \u2014 the integrity check, then flip the delivery\nto `delivered` (or `failed` with the partner's reason). Unauthenticated by\nAS2 design; the match is to a Message-ID we minted, and a signed MDN must\nverify against the partner's configured certificate before it can change\ndelivery state.",
    "operationId": "as2_mdn",
    "requestBody": {
     "description": "",
     "content": {
      "application/octet-stream": {
       "schema": {
        "type": "string",
        "format": "binary"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "description": "MDN processed (matched or ignored)"
     },
     "422": {
      "description": "Body is not a parseable MDN"
     }
    }
   }
  },
  "/v1/business-reconciliation": {
   "get": {
    "tags": [
     "operations"
    ],
    "summary": "Business-level reconciliation across PO / ASN / 945 / invoice / payment.",
    "operationId": "business_reconciliation",
    "responses": {
     "200": {
      "description": "Order-chain match status per reference"
     }
    }
   }
  },
  "/v1/catalog": {
   "get": {
    "tags": [
     "operations"
    ],
    "summary": "The item master (assortment) for the tenant, optionally by partner.",
    "operationId": "list_catalog",
    "parameters": [
     {
      "name": "partner_id",
      "in": "query",
      "description": "Filter to one partner",
      "required": false,
      "schema": {
       "type": "string",
       "nullable": true
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Item-master records",
      "content": {
       "application/json": {
        "schema": {
         "type": "array",
         "items": {
          "$ref": "#/components/schemas/CatalogItemRecord"
         }
        }
       }
      }
     },
     "403": {
      "description": "Admin credential required"
     }
    }
   }
  },
  "/v1/catalog/ingest/{partner_id}": {
   "post": {
    "tags": [
     "operations"
    ],
    "summary": "Ingests an 832 price/sales catalog into the partner's item master, bumping a",
    "description": "per-item version only where attributes changed. Returns a created/updated/\nunchanged summary.",
    "operationId": "ingest_catalog",
    "parameters": [
     {
      "name": "partner_id",
      "in": "path",
      "description": "Partner ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/Catalog832"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "description": "Ingest summary",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/IngestSummary"
        }
       }
      }
     },
     "403": {
      "description": "Not this credential's partner"
     }
    }
   }
  },
  "/v1/commercial-invoice/{partner_id}": {
   "post": {
    "tags": [
     "outbound"
    ],
    "summary": "Generates a commercial invoice / customs document from a canonical",
    "description": "commercial-invoice payload. Emits a signed `edi.commercial_invoice.generated`\nVES event. The response flags whether every line carries the HS code and\ncountry of origin a compliant declaration needs.",
    "operationId": "commercial_invoice",
    "parameters": [
     {
      "name": "partner_id",
      "in": "path",
      "description": "Partner ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/CommercialInvoice"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "description": "Commercial invoice (structured + HTML)"
     },
     "403": {
      "description": "Not this credential's partner"
     },
     "422": {
      "description": "Invalid payload"
     }
    }
   }
  },
  "/v1/connector-sdk/certify": {
   "post": {
    "tags": [
     "partners"
    ],
    "summary": "Certify a connector manifest: validate it, then instantiate a sample partner",
    "description": "and run the artifact conformance suite. With `?publish=true`, a passing\nconnector is published to the shared template library (the reuse flywheel),\nwhere any tenant can inherit it \u2014 the SDK's self-publish path.",
    "operationId": "certify_connector_manifest",
    "parameters": [
     {
      "name": "publish",
      "in": "query",
      "description": "Publish to the template library on pass",
      "required": false,
      "schema": {
       "type": "boolean",
       "nullable": true
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/ConnectorManifest"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "description": "Validation + conformance verdict, and the published template when requested"
     }
    }
   }
  },
  "/v1/connector-sdk/validate": {
   "post": {
    "tags": [
     "partners"
    ],
    "summary": "Validate a connector manifest (SDK) without persisting \u2014 structure, a",
    "description": "supported X12 version, and that every declared transaction set is supported.",
    "operationId": "validate_connector_manifest",
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/ConnectorManifest"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "description": "Manifest validation issues"
     }
    }
   }
  },
  "/v1/connectors": {
   "get": {
    "tags": [
     "partners"
    ],
    "summary": "Lists the built-in retailer connectors, optionally filtered by vertical.",
    "operationId": "list_connectors",
    "parameters": [
     {
      "name": "category",
      "in": "query",
      "description": "Retail vertical, e.g. beauty",
      "required": false,
      "schema": {
       "type": "string",
       "nullable": true
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Available retailer connectors",
      "content": {
       "application/json": {
        "schema": {
         "type": "array",
         "items": {
          "$ref": "#/components/schemas/Connector"
         }
        }
       }
      }
     },
     "403": {
      "description": "Admin credential required"
     }
    }
   }
  },
  "/v1/connectors/{name}": {
   "get": {
    "tags": [
     "partners"
    ],
    "summary": "Returns one retailer connector, including its starter validation guide.",
    "operationId": "get_connector",
    "parameters": [
     {
      "name": "name",
      "in": "path",
      "description": "Connector name, e.g. walmart",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Connector profile",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Connector"
        }
       }
      }
     },
     "403": {
      "description": "Admin credential required"
     },
     "404": {
      "description": "Unknown connector"
     }
    }
   }
  },
  "/v1/connectors/{name}/partners/{id}": {
   "post": {
    "tags": [
     "partners"
    ],
    "summary": "Creates (or updates) a trading partner from a retailer connector, filling",
    "description": "in the retailer's qualifiers, version, delimiters, and starter guide; the\nbody supplies the relationship-specific identifiers.",
    "operationId": "create_partner_from_connector",
    "parameters": [
     {
      "name": "name",
      "in": "path",
      "description": "Connector name, e.g. walmart",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "id",
      "in": "path",
      "description": "Internal partner ID to create",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/ConnectorPartnerParams"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "description": "The created partner (key hash redacted)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/TradingPartner"
        }
       }
      }
     },
     "403": {
      "description": "Admin credential required"
     },
     "404": {
      "description": "Unknown connector"
     }
    }
   }
  },
  "/v1/customs/postal/{partner_id}": {
   "post": {
    "tags": [
     "outbound"
    ],
    "summary": "Generates a CN22/CN23 postal customs declaration from a commercial-invoice",
    "description": "payload (the form is chosen by goods value). Emits a signed\n`edi.postal_declaration.generated` event.",
    "operationId": "postal_declaration",
    "parameters": [
     {
      "name": "partner_id",
      "in": "path",
      "description": "Partner ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/CommercialInvoice"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "description": "Postal declaration (structured + HTML)"
     },
     "403": {
      "description": "Not this credential's partner"
     },
     "422": {
      "description": "Invalid payload"
     }
    }
   }
  },
  "/v1/deadletter": {
   "get": {
    "tags": [
     "operations"
    ],
    "summary": "Events the sequencer permanently rejected and that were moved out of the",
    "description": "active queue after exhausting delivery attempts.",
    "operationId": "deadletter",
    "responses": {
     "200": {
      "description": "Dead-lettered events with rejection reasons"
     },
     "403": {
      "description": "Admin credential required"
     }
    }
   }
  },
  "/v1/deadletter/replay": {
   "post": {
    "tags": [
     "operations"
    ],
    "summary": "Replays every dead-lettered event back into the active outbox so the next",
    "description": "flush re-attempts delivery to the sequencer. Safe to call repeatedly: the\nsequencer dedups by event ID.",
    "operationId": "replay_deadletter",
    "responses": {
     "200": {
      "description": "Dead-lettered events returned to the queue"
     },
     "403": {
      "description": "Admin credential required"
     }
    }
   }
  },
  "/v1/deductions": {
   "get": {
    "tags": [
     "operations"
    ],
    "summary": "Lists deductions for the tenant with an exposure/recovery summary.",
    "operationId": "list_deductions",
    "responses": {
     "200": {
      "description": "Deductions + summary",
      "content": {
       "application/json": {
        "schema": {
         "type": "array",
         "items": {
          "$ref": "#/components/schemas/Deduction"
         }
        }
       }
      }
     },
     "403": {
      "description": "Admin credential required"
     }
    }
   },
   "post": {
    "tags": [
     "operations"
    ],
    "summary": "Captures a deduction (from an inbound 812 or keyed by an operator). The ID is",
    "description": "derived from the partner + adjustment number so re-capturing the same\nchargeback updates rather than duplicates.",
    "operationId": "capture_deduction",
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/DeductionCapture"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "description": "Captured deduction",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Deduction"
        }
       }
      }
     },
     "403": {
      "description": "Admin credential required"
     }
    }
   }
  },
  "/v1/deductions/{id}": {
   "get": {
    "tags": [
     "operations"
    ],
    "summary": "One deduction with its dispute history.",
    "operationId": "get_deduction",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "description": "Deduction ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Deduction",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Deduction"
        }
       }
      }
     },
     "404": {
      "description": "Unknown deduction"
     }
    }
   }
  },
  "/v1/deductions/{id}/categorize": {
   "post": {
    "tags": [
     "operations"
    ],
    "summary": "Assigns a root-cause category to a deduction.",
    "operationId": "categorize_deduction",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "description": "Deduction ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Updated deduction",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Deduction"
        }
       }
      }
     }
    }
   }
  },
  "/v1/deductions/{id}/dispute": {
   "post": {
    "tags": [
     "operations"
    ],
    "summary": "Opens a dispute on a deduction.",
    "operationId": "dispute_deduction",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "description": "Deduction ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Updated deduction",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Deduction"
        }
       }
      }
     },
     "422": {
      "description": "Already resolved"
     }
    }
   }
  },
  "/v1/deductions/{id}/evidence": {
   "post": {
    "tags": [
     "operations"
    ],
    "summary": "Attaches supporting evidence (a note + optional link) to a deduction \u2014 the",
    "description": "chain of custody a dispute is won on.",
    "operationId": "add_deduction_evidence",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "description": "Deduction ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Updated deduction",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Deduction"
        }
       }
      }
     }
    }
   }
  },
  "/v1/deductions/{id}/resolve": {
   "post": {
    "tags": [
     "operations"
    ],
    "summary": "Resolves a deduction to a terminal outcome (recovered / denied / written off).",
    "operationId": "resolve_deduction",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "description": "Deduction ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Resolved deduction",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Deduction"
        }
       }
      }
     },
     "422": {
      "description": "Invalid outcome or recovery amount"
     }
    }
   }
  },
  "/v1/deliveries": {
   "get": {
    "tags": [
     "operations"
    ],
    "summary": "Outbound AS2 deliveries and their status (pending / delivered / failed),",
    "description": "scoped to the caller's tenant. Payloads are redacted.",
    "operationId": "list_deliveries",
    "responses": {
     "200": {
      "description": "Tracked AS2 deliveries with retry status"
     },
     "403": {
      "description": "Admin credential required"
     }
    }
   }
  },
  "/v1/deliveries/redeliver-bulk": {
   "post": {
    "tags": [
     "operations"
    ],
    "summary": "Bulk re-drives every **failed** delivery (optionally for one partner) back to",
    "description": "pending so the worker retries them \u2014 e.g. after a partner endpoint recovers.\nIdempotent at the AS2 layer; capped at 500.",
    "operationId": "redeliver_bulk",
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/RedeliverBulkBody"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "description": "Bulk redeliver summary"
     },
     "403": {
      "description": "Admin credential required"
     }
    }
   }
  },
  "/v1/deliveries/{id}/redeliver": {
   "post": {
    "tags": [
     "operations"
    ],
    "summary": "Re-drives a failed (or stuck) AS2 delivery: resets it to pending and due now",
    "description": "so the delivery worker re-attempts it. Idempotent at the AS2 layer \u2014 a\nmessage the partner already accepted won't double-apply.",
    "operationId": "redeliver",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "description": "Delivery ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Delivery re-queued for the worker"
     },
     "403": {
      "description": "Admin credential required"
     },
     "404": {
      "description": "Unknown delivery"
     }
    }
   }
  },
  "/v1/documents": {
   "get": {
    "tags": [
     "operations"
    ],
    "summary": "Paged: `data` stays a plain array (newest first) and `page` carries",
    "description": "`{total, limit, offset}` so existing consumers keep working while new ones\ncan walk the full log.",
    "operationId": "documents",
    "parameters": [
     {
      "name": "limit",
      "in": "query",
      "description": "Page size (default 200, max 1000)",
      "required": false,
      "schema": {
       "type": "integer",
       "nullable": true,
       "minimum": 0
      }
     },
     {
      "name": "offset",
      "in": "query",
      "description": "Documents to skip, newest first (default 0)",
      "required": false,
      "schema": {
       "type": "integer",
       "nullable": true,
       "minimum": 0
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Recent processed documents, newest first",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/PagedDocuments"
        }
       }
      }
     },
     "403": {
      "description": "Admin credential required"
     }
    }
   }
  },
  "/v1/documents/manual": {
   "post": {
    "tags": [
     "operations"
    ],
    "summary": "Manual document entry for partners without back-end integration: an operator",
    "description": "pastes a raw inbound interchange and the gateway processes it through the\nnormal pipeline (validation \u2192 translation \u2192 acknowledgment), recording it as\noperator-entered. Idempotent like any inbound; a duplicate control number is\nrejected.",
    "operationId": "manual_document_entry",
    "requestBody": {
     "description": "Raw X12/EDIFACT interchange keyed by an operator",
     "content": {
      "application/edi-x12": {
       "schema": {
        "type": "string"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "description": "Processing result with acknowledgment",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/InboundResult"
        }
       }
      }
     },
     "403": {
      "description": "Admin credential required"
     },
     "409": {
      "description": "Duplicate interchange control number"
     }
    }
   }
  },
  "/v1/documents/reprocess-bulk": {
   "post": {
    "tags": [
     "operations"
    ],
    "summary": "Bulk-reprocesses stored **inbound** documents matching a filter \u2014 e.g.",
    "description": "re-drive every rejected 850 for a partner after a guide fix. Idempotent like\nsingle reprocess; capped at 500 documents per call.",
    "operationId": "reprocess_bulk",
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/ReprocessBulkBody"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "description": "Bulk reprocess summary"
     },
     "403": {
      "description": "Admin credential required"
     }
    }
   }
  },
  "/v1/documents/{id}": {
   "get": {
    "tags": [
     "operations"
    ],
    "operationId": "document_detail",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "description": "Document audit ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Document drill-down detail",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/DocumentDetail"
        }
       }
      }
     },
     "403": {
      "description": "Admin credential required"
     },
     "404": {
      "description": "Unknown document"
     }
    }
   }
  },
  "/v1/documents/{id}/evidence": {
   "get": {
    "tags": [
     "operations"
    ],
    "summary": "Compliance evidence bundle for one document and its related order chain.",
    "operationId": "document_evidence",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "description": "Document ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Evidence bundle for the document and its order chain"
     },
     "404": {
      "description": "Unknown document"
     }
    }
   }
  },
  "/v1/documents/{id}/reprocess": {
   "post": {
    "tags": [
     "operations"
    ],
    "summary": "Reprocesses a stored **inbound** document: re-runs validation, translation,",
    "description": "and acknowledgment against the partner's current implementation guide. The\ndeterministic dedup event ID means re-deriving events from the same wire\ncollapses in the outbox \u2014 no duplicate orders.",
    "operationId": "reprocess_document",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "description": "Document audit ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Reprocessing result with fresh acknowledgment"
     },
     "403": {
      "description": "Admin credential required"
     },
     "404": {
      "description": "Unknown document"
     },
     "422": {
      "description": "Document is outbound (use re-deliver) or unparseable"
     }
    }
   }
  },
  "/v1/edi/inbound": {
   "post": {
    "tags": [
     "inbound"
    ],
    "operationId": "inbound",
    "requestBody": {
     "description": "Raw X12 interchange",
     "content": {
      "application/edi-x12": {
       "schema": {
        "type": "string"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "description": "Processing result with 997 (or TA1) acknowledgment",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/InboundResult"
        }
       }
      }
     },
     "404": {
      "description": "No partner matches the ISA sender"
     },
     "409": {
      "description": "Duplicate interchange control number"
     },
     "422": {
      "description": "Unparseable X12"
     }
    }
   }
  },
  "/v1/edi/inbound/{partner_id}": {
   "post": {
    "tags": [
     "inbound"
    ],
    "operationId": "inbound_for",
    "parameters": [
     {
      "name": "partner_id",
      "in": "path",
      "description": "Partner ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "description": "Raw X12 interchange",
     "content": {
      "application/edi-x12": {
       "schema": {
        "type": "string"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "description": "Processing result with 997 (or TA1) acknowledgment",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/InboundResult"
        }
       }
      }
     },
     "403": {
      "description": "Not this credential's partner"
     },
     "409": {
      "description": "Duplicate interchange control number"
     }
    }
   }
  },
  "/v1/edi/outbound/204/{partner_id}": {
   "post": {
    "tags": [
     "outbound"
    ],
    "operationId": "outbound_204",
    "parameters": [
     {
      "name": "partner_id",
      "in": "path",
      "description": "Partner ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/Tender204"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "description": "Wire-ready X12 204 load tender"
     },
     "403": {
      "description": "Not this credential's partner"
     },
     "422": {
      "description": "Invalid payload or delimiter collision"
     }
    }
   }
  },
  "/v1/edi/outbound/270/{partner_id}": {
   "post": {
    "tags": [
     "outbound"
    ],
    "operationId": "outbound_270",
    "parameters": [
     {
      "name": "partner_id",
      "in": "path",
      "description": "Partner ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/EligibilityInquiry270"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "description": "Wire-ready X12 270 eligibility inquiry"
     },
     "403": {
      "description": "Not this credential's partner"
     },
     "422": {
      "description": "Invalid payload or delimiter collision"
     }
    }
   }
  },
  "/v1/edi/outbound/810/{partner_id}": {
   "post": {
    "tags": [
     "outbound"
    ],
    "operationId": "outbound_810",
    "parameters": [
     {
      "name": "partner_id",
      "in": "path",
      "description": "Partner ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/Invoice810"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "description": "Wire-ready X12 810 interchange"
     },
     "403": {
      "description": "Not this credential's partner"
     },
     "422": {
      "description": "Invalid payload or delimiter collision"
     }
    }
   }
  },
  "/v1/edi/outbound/832/{partner_id}": {
   "post": {
    "tags": [
     "outbound"
    ],
    "summary": "Publishes an outbound 832 price/sales catalog to a partner.",
    "operationId": "outbound_832",
    "parameters": [
     {
      "name": "partner_id",
      "in": "path",
      "description": "Partner ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/Catalog832"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "description": "Wire-ready X12 832 interchange"
     },
     "403": {
      "description": "Not this credential's partner"
     },
     "422": {
      "description": "Invalid payload"
     }
    }
   }
  },
  "/v1/edi/outbound/846/{partner_id}": {
   "post": {
    "tags": [
     "outbound"
    ],
    "operationId": "outbound_846",
    "parameters": [
     {
      "name": "partner_id",
      "in": "path",
      "description": "Partner ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/crate.transactions.inventory846.InventoryAdvice846"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "description": "Wire-ready X12 846 interchange"
     },
     "403": {
      "description": "Not this credential's partner"
     },
     "422": {
      "description": "Invalid payload or delimiter collision"
     }
    }
   }
  },
  "/v1/edi/outbound/855/{partner_id}": {
   "post": {
    "tags": [
     "outbound"
    ],
    "operationId": "outbound_855",
    "parameters": [
     {
      "name": "partner_id",
      "in": "path",
      "description": "Partner ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/Ack855"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "description": "Wire-ready X12 855 interchange"
     },
     "403": {
      "description": "Not this credential's partner"
     },
     "422": {
      "description": "Invalid payload or delimiter collision"
     }
    }
   }
  },
  "/v1/edi/outbound/856/{partner_id}": {
   "post": {
    "tags": [
     "outbound"
    ],
    "operationId": "outbound_856",
    "parameters": [
     {
      "name": "partner_id",
      "in": "path",
      "description": "Partner ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/Asn856"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "description": "Wire-ready X12 856 interchange"
     },
     "403": {
      "description": "Not this credential's partner"
     },
     "422": {
      "description": "Invalid payload or delimiter collision"
     }
    }
   }
  },
  "/v1/edi/outbound/865/{partner_id}": {
   "post": {
    "tags": [
     "outbound"
    ],
    "operationId": "outbound_865",
    "parameters": [
     {
      "name": "partner_id",
      "in": "path",
      "description": "Partner ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/crate.transactions.ack865.Ack865"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "description": "Wire-ready X12 865 interchange"
     },
     "403": {
      "description": "Not this credential's partner"
     },
     "422": {
      "description": "Invalid payload or delimiter collision"
     }
    }
   }
  },
  "/v1/edi/outbound/940/{partner_id}": {
   "post": {
    "tags": [
     "outbound"
    ],
    "operationId": "outbound_940",
    "parameters": [
     {
      "name": "partner_id",
      "in": "path",
      "description": "Partner ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/Ship940"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "description": "Wire-ready X12 940 interchange"
     },
     "403": {
      "description": "Not this credential's partner"
     },
     "422": {
      "description": "Invalid payload or delimiter collision"
     }
    }
   }
  },
  "/v1/edi/outbound/943/{partner_id}": {
   "post": {
    "tags": [
     "outbound"
    ],
    "operationId": "outbound_943",
    "parameters": [
     {
      "name": "partner_id",
      "in": "path",
      "description": "Partner ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/Transfer943"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "description": "Wire-ready X12 943 interchange"
     },
     "403": {
      "description": "Not this credential's partner"
     },
     "422": {
      "description": "Invalid payload or delimiter collision"
     }
    }
   }
  },
  "/v1/edi/parse": {
   "post": {
    "tags": [
     "operations"
    ],
    "summary": "Parses arbitrary X12 and returns the envelope structure \u2014 a debugging aid.",
    "operationId": "parse_document",
    "requestBody": {
     "description": "Raw X12 interchange",
     "content": {
      "application/edi-x12": {
       "schema": {
        "type": "string"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "description": "Parsed envelope structure"
     },
     "422": {
      "description": "Unparseable or invalid X12"
     }
    }
   }
  },
  "/v1/edi/validate": {
   "post": {
    "tags": [
     "inbound"
    ],
    "summary": "Dry-run validation against the ISA-resolved partner's implementation guide.",
    "operationId": "validate_document",
    "requestBody": {
     "description": "Raw X12 interchange",
     "content": {
      "application/edi-x12": {
       "schema": {
        "type": "string"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "description": "Validation report (no side effects)"
     },
     "404": {
      "description": "No partner matches the ISA sender"
     },
     "422": {
      "description": "Unparseable X12"
     }
    }
   }
  },
  "/v1/edi/validate/{partner_id}": {
   "post": {
    "tags": [
     "inbound"
    ],
    "summary": "Dry-run validation against a specific partner's implementation guide.",
    "operationId": "validate_document_for",
    "parameters": [
     {
      "name": "partner_id",
      "in": "path",
      "description": "Partner ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "description": "Raw X12 interchange",
     "content": {
      "application/edi-x12": {
       "schema": {
        "type": "string"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "description": "Validation report (no side effects)"
     },
     "403": {
      "description": "Not this credential's partner"
     }
    }
   }
  },
  "/v1/edifact/outbound/desadv/{partner_id}": {
   "post": {
    "tags": [
     "outbound"
    ],
    "operationId": "edifact_outbound_desadv",
    "parameters": [
     {
      "name": "partner_id",
      "in": "path",
      "description": "Partner ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Wire-ready UN/EDIFACT DESADV interchange"
     },
     "403": {
      "description": "Not this credential's partner"
     },
     "422": {
      "description": "Invalid payload"
     }
    }
   }
  },
  "/v1/edifact/outbound/invoic/{partner_id}": {
   "post": {
    "tags": [
     "outbound"
    ],
    "operationId": "edifact_outbound_invoic",
    "parameters": [
     {
      "name": "partner_id",
      "in": "path",
      "description": "Partner ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Wire-ready UN/EDIFACT INVOIC interchange"
     },
     "403": {
      "description": "Not this credential's partner"
     },
     "422": {
      "description": "Invalid payload"
     }
    }
   }
  },
  "/v1/einvoice/ubl/{partner_id}": {
   "post": {
    "tags": [
     "outbound"
    ],
    "summary": "Generates a Peppol BIS Billing 3.0 UBL e-invoice from a canonical invoice",
    "description": "payload. Emits a signed `edi.einvoice.generated` VES event. The response\nreports BIS completeness and the delivery status \u2014 generation is performed\nhere; transmission to a government / Peppol network requires a certified\naccess-point partner (the `delivery` seam), per the deliberate A- scope.",
    "operationId": "einvoice_ubl",
    "parameters": [
     {
      "name": "partner_id",
      "in": "path",
      "description": "Partner ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/UblInvoiceInput"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "description": "UBL e-invoice (XML + validation + delivery status)"
     },
     "403": {
      "description": "Not this credential's partner"
     },
     "422": {
      "description": "Invalid payload"
     }
    }
   }
  },
  "/v1/einvoice/ubl/{partner_id}/validate": {
   "post": {
    "tags": [
     "outbound"
    ],
    "summary": "Validates a Peppol-BIS invoice payload against the BIS Billing 3.0 business",
    "description": "rules (EN 16931 + PEPPOL) without generating or persisting \u2014 the conformance\ngate before handing UBL to an access point.",
    "operationId": "einvoice_ubl_validate",
    "parameters": [
     {
      "name": "partner_id",
      "in": "path",
      "description": "Partner ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/UblInvoiceInput"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "description": "BIS validation result (valid + per-rule issues)"
     }
    }
   }
  },
  "/v1/evidence/{reference}": {
   "get": {
    "tags": [
     "operations"
    ],
    "summary": "Compliance evidence bundle for a PO / shipment / invoice reference.",
    "operationId": "reference_evidence",
    "parameters": [
     {
      "name": "reference",
      "in": "path",
      "description": "PO / shipment / invoice reference",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Evidence bundle for every document carrying the reference"
     }
    }
   }
  },
  "/v1/fulfillment": {
   "get": {
    "tags": [
     "operations"
    ],
    "summary": "3PL / fulfillment scorecard: fill rate, perfect-order rate, and at-risk",
    "description": "orders (chargeback exposure) aggregated across all reconciled orders.",
    "operationId": "fulfillment_scorecard",
    "responses": {
     "200": {
      "description": "Fulfillment scorecard",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/FulfillmentScorecard"
        }
       }
      }
     },
     "403": {
      "description": "Admin credential required"
     }
    }
   }
  },
  "/v1/labels/856/{partner_id}": {
   "post": {
    "tags": [
     "outbound"
    ],
    "summary": "Generates a UCC-128 shipping label (SSCC-18 + ZPL) from an 856 ASN body.",
    "description": "Requires `EDI_GS1_COMPANY_PREFIX`. One label per shipment.",
    "operationId": "label_856",
    "parameters": [
     {
      "name": "partner_id",
      "in": "path",
      "description": "Partner ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/Asn856"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "description": "SSCC + ZPL shipping label"
     },
     "403": {
      "description": "Not this credential's partner"
     },
     "422": {
      "description": "GS1 company prefix not configured, or invalid ASN"
     }
    }
   }
  },
  "/v1/labels/856/{partner_id}/cartons": {
   "post": {
    "tags": [
     "outbound"
    ],
    "summary": "Generates one UCC-128 GS1-128 label per carton from an 856 ASN's carton",
    "description": "breakdown, each with its own SSCC-18 and a \"CARTON i OF n\" mark. Emits a\nsigned `edi.carton_labels.generated` event. Returns 422 if the ASN has no\ncarton breakdown (use `/v1/labels/856/:id` for a shipment-level label).",
    "operationId": "carton_labels_856",
    "parameters": [
     {
      "name": "partner_id",
      "in": "path",
      "description": "Partner ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/Asn856"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "description": "Per-carton SSCC labels"
     },
     "403": {
      "description": "Not this credential's partner"
     },
     "422": {
      "description": "ASN has no carton breakdown"
     }
    }
   }
  },
  "/v1/labels/856/{partner_id}/level/{level}": {
   "post": {
    "tags": [
     "outbound"
    ],
    "summary": "Generates GS1 labels at a specific pack **level** \u2014 `carton` (SSCC, AI 00),",
    "description": "`inner` (a case of one trade item: GTIN AI 02 + count AI 37), or `each` (a\nsingle unit: GTIN AI 01) \u2014 applying the partner's [`LabelProfile`] placement\n(size, darkness, required mark). Pallet labels come from the carton endpoint\nwith `?pallet_sscc=`.",
    "operationId": "labels_for_level",
    "parameters": [
     {
      "name": "partner_id",
      "in": "path",
      "description": "Partner ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "level",
      "in": "path",
      "description": "Pack level: carton | inner | each",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/Asn856"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "description": "Labels for the requested pack level"
     },
     "403": {
      "description": "Not this credential's partner"
     },
     "422": {
      "description": "Unknown level or invalid ASN"
     }
    }
   }
  },
  "/v1/leads": {
   "get": {
    "tags": [
     "operations"
    ],
    "summary": "Lists recent captured leads (operator view). Leads come from the public",
    "description": "marketing funnel and carry no tenant attribution, so this is a platform\nsurface: only the global admin token may read them \u2014 a tenant or partner\nkey must not see other prospects' contact details.",
    "operationId": "list_leads",
    "parameters": [
     {
      "name": "limit",
      "in": "query",
      "description": "Max leads to return (default 100)",
      "required": false,
      "schema": {
       "type": "integer",
       "nullable": true,
       "minimum": 0
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Recent leads, newest first"
     },
     "403": {
      "description": "Not the platform admin"
     }
    }
   },
   "post": {
    "tags": [
     "operations"
    ],
    "summary": "Captures an inbound sales lead from the public checker / landing page.",
    "description": "Public: no bearer token. The lead is stored durably and, when a CRM webhook\nis configured (`EDI_LEAD_WEBHOOK_URL`), forwarded best-effort in the\nbackground so a slow CRM never delays the response.",
    "operationId": "capture_lead",
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/crate.leads.NewLead"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "description": "Lead captured"
     },
     "422": {
      "description": "Invalid submission (e.g. missing/invalid email)"
     }
    }
   }
  },
  "/v1/lifecycle/{reference}": {
   "get": {
    "tags": [
     "operations"
    ],
    "summary": "Order lifecycle trace for one PO / shipment / invoice reference.",
    "operationId": "lifecycle_trace",
    "parameters": [
     {
      "name": "reference",
      "in": "path",
      "description": "PO / shipment / invoice reference",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Lifecycle events for the reference, oldest first"
     }
    }
   }
  },
  "/v1/monitoring": {
   "get": {
    "tags": [
     "operations"
    ],
    "summary": "Real-time monitoring snapshot: per-partner acknowledgment SLA status,",
    "description": "dead-letter and failed-delivery counts, and active alerts.",
    "operationId": "monitoring",
    "responses": {
     "200": {
      "description": "Monitoring snapshot",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/MonitoringSnapshot"
        }
       }
      }
     },
     "403": {
      "description": "Admin credential required"
     }
    }
   }
  },
  "/v1/monitoring/evaluate": {
   "post": {
    "tags": [
     "operations"
    ],
    "summary": "Evaluates monitoring and **fires** every critical alert through the",
    "description": "configured alerter (webhook/email) \u2014 the push hook a scheduler calls.\nReturns the snapshot and how many alerts were dispatched.",
    "operationId": "monitoring_evaluate",
    "responses": {
     "200": {
      "description": "Snapshot + count of alerts fired"
     },
     "403": {
      "description": "Admin credential required"
     }
    }
   }
  },
  "/v1/network/readiness": {
   "get": {
    "tags": [
     "operations"
    ],
    "summary": "Trading-network readiness across partners in the selected tenant.",
    "operationId": "network_readiness",
    "responses": {
     "200": {
      "description": "Per-partner go-live readiness summary"
     }
    }
   }
  },
  "/v1/onboarding": {
   "get": {
    "tags": [
     "partners"
    ],
    "summary": "All onboarding records for the tenant, newest activity first.",
    "operationId": "list_onboarding",
    "responses": {
     "200": {
      "description": "Onboarding records",
      "content": {
       "application/json": {
        "schema": {
         "type": "array",
         "items": {
          "$ref": "#/components/schemas/OnboardingRecord"
         }
        }
       }
      }
     },
     "403": {
      "description": "Admin credential required"
     }
    }
   }
  },
  "/v1/outbox": {
   "get": {
    "tags": [
     "operations"
    ],
    "operationId": "outbox",
    "responses": {
     "200": {
      "description": "Pending VES events",
      "content": {
       "application/json": {
        "schema": {
         "type": "array",
         "items": {
          "$ref": "#/components/schemas/EdiEvent"
         }
        }
       }
      }
     },
     "403": {
      "description": "Admin credential required"
     }
    }
   }
  },
  "/v1/outbox/flush": {
   "post": {
    "tags": [
     "operations"
    ],
    "operationId": "outbox_flush",
    "responses": {
     "200": {
      "description": "Events pushed to the StateSet sequencer"
     },
     "403": {
      "description": "Admin credential required"
     },
     "502": {
      "description": "Sequencer unreachable"
     }
    }
   }
  },
  "/v1/packing-slip/856/{partner_id}": {
   "post": {
    "tags": [
     "outbound"
    ],
    "summary": "Generates a packing slip (printable HTML + ZPL summary label) from an 856",
    "description": "ASN body, bound to the shipment \u2192 order \u2192 pack \u2192 item hierarchy. Emits a\nsigned `edi.packing_slip.generated` VES event so the artifact is\nreproducible and auditable.",
    "operationId": "packing_slip_856",
    "parameters": [
     {
      "name": "partner_id",
      "in": "path",
      "description": "Partner ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/Asn856"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "description": "Packing slip (structured + HTML + ZPL)"
     },
     "403": {
      "description": "Not this credential's partner"
     },
     "422": {
      "description": "Invalid ASN payload"
     }
    }
   }
  },
  "/v1/packing-slip/856/{partner_id}/pdf": {
   "post": {
    "tags": [
     "outbound"
    ],
    "summary": "Same canonical 856 \u2192 ASN as [`packing_slip_856`], but streams the **native",
    "description": "PDF** bytes (`application/pdf`) for direct printing/download.",
    "operationId": "packing_slip_856_pdf",
    "parameters": [
     {
      "name": "partner_id",
      "in": "path",
      "description": "Partner ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/Asn856"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "description": "Packing slip as a native PDF"
     },
     "403": {
      "description": "Not this credential's partner"
     },
     "422": {
      "description": "Invalid ASN payload"
     }
    }
   }
  },
  "/v1/partners": {
   "get": {
    "tags": [
     "partners"
    ],
    "operationId": "list_partners",
    "responses": {
     "200": {
      "description": "All trading partners (key hashes redacted)",
      "content": {
       "application/json": {
        "schema": {
         "type": "array",
         "items": {
          "$ref": "#/components/schemas/TradingPartner"
         }
        }
       }
      }
     },
     "403": {
      "description": "Admin credential required"
     }
    }
   }
  },
  "/v1/partners/{id}": {
   "get": {
    "tags": [
     "partners"
    ],
    "operationId": "get_partner",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "description": "Partner ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Partner record, key hash redacted",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/TradingPartner"
        }
       }
      }
     },
     "403": {
      "description": "Not this credential's partner"
     },
     "404": {
      "description": "Unknown partner"
     }
    }
   },
   "put": {
    "tags": [
     "partners"
    ],
    "operationId": "upsert_partner",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "description": "Partner ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/TradingPartner"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "description": "Stored partner (credentials are never set this way)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/TradingPartner"
        }
       }
      }
     },
     "403": {
      "description": "Admin credential required"
     }
    }
   }
  },
  "/v1/partners/{id}/api-key": {
   "post": {
    "tags": [
     "partners"
    ],
    "summary": "Issues (or rotates) a partner API key. The plaintext is returned exactly",
    "description": "once; only its SHA-256 is stored.",
    "operationId": "issue_partner_key",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "description": "Partner ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "New API key \u2014 shown exactly once; replaces any previous key"
     },
     "403": {
      "description": "Admin credential required"
     },
     "404": {
      "description": "Unknown partner"
     }
    }
   }
  },
  "/v1/partners/{id}/certification/run": {
   "post": {
    "tags": [
     "partners"
    ],
    "summary": "Runs a certification test pack against a partner: every sample interchange",
    "description": "is validated (side-effect-free) against the partner's implementation guide\nand checked against its expected outcome. When the pack passes and the\npartner's onboarding is at the `testing` stage, it auto-advances to\n`certified`. Emits a signed `edi.operator.certification_run` audit event.",
    "operationId": "run_certification",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "description": "Partner ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/TestPack"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "description": "Certification report",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/CertificationReport"
        }
       }
      }
     },
     "403": {
      "description": "Not this credential's partner"
     },
     "404": {
      "description": "Unknown partner"
     },
     "422": {
      "description": "Invalid test pack"
     }
    }
   }
  },
  "/v1/partners/{id}/certification/run-standard": {
   "post": {
    "tags": [
     "partners"
    ],
    "summary": "Runs the prebuilt retail-baseline certification pack \u2014 generated for this",
    "description": "partner's envelope \u2014 so a customer can certify without authoring samples.",
    "operationId": "run_standard_certification",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "description": "Partner ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Certification report",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/CertificationReport"
        }
       }
      }
     },
     "403": {
      "description": "Not this credential's partner"
     },
     "404": {
      "description": "Unknown partner"
     }
    }
   }
  },
  "/v1/partners/{id}/guide/diff": {
   "get": {
    "tags": [
     "partners"
    ],
    "summary": "Field-level diff between two guide versions.",
    "operationId": "diff_guide",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "description": "Partner ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "from",
      "in": "query",
      "description": "Base version",
      "required": true,
      "schema": {
       "type": "integer",
       "format": "int32",
       "minimum": 0
      }
     },
     {
      "name": "to",
      "in": "query",
      "description": "Target version",
      "required": true,
      "schema": {
       "type": "integer",
       "format": "int32",
       "minimum": 0
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Guide diff",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/GuideDiff"
        }
       }
      }
     },
     "404": {
      "description": "Unknown version"
     }
    }
   }
  },
  "/v1/partners/{id}/guide/rollback/{version}": {
   "post": {
    "tags": [
     "partners"
    ],
    "summary": "Rolls a partner's guide back to an earlier version: restores that version's",
    "description": "validation + overlay onto the partner and records the restore as a new\nversion (history is append-only, never rewritten).",
    "operationId": "rollback_guide",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "description": "Partner ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "version",
      "in": "path",
      "description": "Version to restore",
      "required": true,
      "schema": {
       "type": "integer",
       "format": "int32",
       "minimum": 0
      }
     }
    ],
    "responses": {
     "200": {
      "description": "New version recording the rollback",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/GuideSnapshot"
        }
       }
      }
     },
     "404": {
      "description": "Unknown partner or version"
     }
    }
   }
  },
  "/v1/partners/{id}/guide/snapshot": {
   "post": {
    "tags": [
     "partners"
    ],
    "summary": "Captures the partner's current implementation guide (validation + overlay) as",
    "description": "the next immutable version.",
    "operationId": "snapshot_guide",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "description": "Partner ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "The captured guide version",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/GuideSnapshot"
        }
       }
      }
     },
     "404": {
      "description": "Unknown partner"
     }
    }
   }
  },
  "/v1/partners/{id}/guide/validate": {
   "post": {
    "tags": [
     "partners"
    ],
    "summary": "Validates a partner's current guide (validation rules + overlay) without",
    "description": "publishing \u2014 the editor's pre-flight check. Returns errors and warnings.",
    "operationId": "validate_guide",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "description": "Partner ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Guide validation report",
      "content": {
       "application/json": {
        "schema": {
         "type": "array",
         "items": {
          "$ref": "#/components/schemas/GuideIssue"
         }
        }
       }
      }
     }
    }
   }
  },
  "/v1/partners/{id}/guide/versions": {
   "get": {
    "tags": [
     "partners"
    ],
    "summary": "Lists a partner's guide versions (oldest first).",
    "operationId": "list_guide_versions",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "description": "Partner ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Guide versions",
      "content": {
       "application/json": {
        "schema": {
         "type": "array",
         "items": {
          "$ref": "#/components/schemas/GuideSnapshot"
         }
        }
       }
      }
     }
    }
   }
  },
  "/v1/partners/{id}/network-mailbox": {
   "get": {
    "tags": [
     "partners"
    ],
    "summary": "stateset-mail managed mailbox readiness for a partner transport mailbox.",
    "operationId": "network_mailbox",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "description": "Partner ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Managed AS1 mailbox readiness for the partner"
     },
     "404": {
      "description": "Unknown partner"
     }
    }
   }
  },
  "/v1/partners/{id}/onboarding": {
   "get": {
    "tags": [
     "partners"
    ],
    "summary": "One partner's onboarding record.",
    "operationId": "get_onboarding",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "description": "Partner ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Onboarding record",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/OnboardingRecord"
        }
       }
      }
     },
     "404": {
      "description": "Onboarding not started"
     }
    }
   }
  },
  "/v1/partners/{id}/onboarding/blocker": {
   "post": {
    "tags": [
     "partners"
    ],
    "summary": "Sets or clears the blocker on a partner's onboarding.",
    "operationId": "set_onboarding_blocker",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "description": "Partner ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Updated onboarding record",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/OnboardingRecord"
        }
       }
      }
     },
     "404": {
      "description": "Onboarding not started"
     }
    }
   }
  },
  "/v1/partners/{id}/onboarding/start": {
   "post": {
    "tags": [
     "partners"
    ],
    "summary": "Starts onboarding for a partner at the `connected` stage (idempotent).",
    "operationId": "start_onboarding",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "description": "Partner ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Onboarding record",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/OnboardingRecord"
        }
       }
      }
     },
     "404": {
      "description": "Unknown partner"
     }
    }
   }
  },
  "/v1/partners/{id}/onboarding/transition": {
   "post": {
    "tags": [
     "partners"
    ],
    "summary": "Transitions a partner's onboarding to a new stage (one step forward, or any",
    "description": "step back for rework).",
    "operationId": "transition_onboarding",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "description": "Partner ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Updated onboarding record",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/OnboardingRecord"
        }
       }
      }
     },
     "404": {
      "description": "Onboarding not started"
     },
     "422": {
      "description": "Illegal transition"
     }
    }
   }
  },
  "/v1/partners/{id}/overlay": {
   "put": {
    "tags": [
     "partners"
    ],
    "summary": "Replace a partner's companion-guide **overlay** (extra segments + element",
    "description": "overrides) without touching any other field \u2014 the save path behind the\nvisual mapping editor. Validate-before-publish is enforced: an overlay with\nblocking errors is rejected. An empty overlay clears it.",
    "operationId": "set_overlay",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "description": "Partner ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/PartnerOverlay"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "description": "Overlay saved (returns the redacted partner + validation warnings)"
     },
     "422": {
      "description": "Overlay has blocking errors"
     }
    }
   }
  },
  "/v1/partners/{id}/publish-template": {
   "post": {
    "tags": [
     "partners"
    ],
    "summary": "Publishes a partner's guide+map to the shared library as a reusable template",
    "description": "(relationship IDs and credentials stripped). Usually triggered automatically\non a certification pass; this is the explicit path.",
    "operationId": "publish_template",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "description": "Partner ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Published template",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/PartnerTemplate"
        }
       }
      }
     },
     "404": {
      "description": "Unknown partner"
     }
    }
   }
  },
  "/v1/partners/{id}/van/poll": {
   "post": {
    "tags": [
     "partners"
    ],
    "summary": "Poll a partner's file-backed VAN inbound mailbox.",
    "operationId": "van_poll",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "description": "Partner ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Files fetched from the partner's VAN mailbox"
     },
     "404": {
      "description": "Unknown partner"
     }
    }
   }
  },
  "/v1/partners/{id}/van/status": {
   "get": {
    "tags": [
     "partners"
    ],
    "summary": "File-backed VAN mailbox status for a partner.",
    "operationId": "van_status",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "description": "Partner ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "VAN mailbox status for the partner"
     },
     "404": {
      "description": "Unknown partner"
     }
    }
   }
  },
  "/v1/reconciliation": {
   "get": {
    "tags": [
     "operations"
    ],
    "summary": "Acknowledgment status of outbound documents (matched against inbound 997s).",
    "operationId": "reconciliation",
    "parameters": [
     {
      "name": "outstanding",
      "in": "query",
      "description": "Only un-acknowledged documents",
      "required": false,
      "schema": {
       "type": "boolean",
       "nullable": true
      }
     },
     {
      "name": "overdue",
      "in": "query",
      "description": "Only documents overdue past the ack SLA",
      "required": false,
      "schema": {
       "type": "boolean",
       "nullable": true
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Outbound documents and their 997 status",
      "content": {
       "application/json": {
        "schema": {
         "type": "array",
         "items": {
          "$ref": "#/components/schemas/OutboundAck"
         }
        }
       }
      }
     },
     "403": {
      "description": "Admin credential required"
     }
    }
   }
  },
  "/v1/replay/{reference}": {
   "post": {
    "tags": [
     "operations"
    ],
    "summary": "Replays a document set from the stream: re-derives the VES events for every",
    "description": "stored **inbound** document under `reference` (PO / shipment / invoice).\nIdempotent by construction \u2014 each event's deterministic ID collapses in the\noutbox and the sequencer, so a replay produces no duplicate orders, acks, or\ndeliveries. This is the sandbox demonstration of replay-from-stream.",
    "operationId": "replay_reference",
    "parameters": [
     {
      "name": "reference",
      "in": "path",
      "description": "PO / shipment / invoice reference",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Replay summary per document"
     },
     "403": {
      "description": "Admin credential required"
     },
     "404": {
      "description": "No inbound documents for the reference"
     }
    }
   }
  },
  "/v1/retailer-profiles": {
   "get": {
    "tags": [
     "operations"
    ],
    "summary": "Lists the built-in retailer companion-guide profiles (Walmart, Target,",
    "description": "Amazon, plus Sephora/Ulta placeholders). Public: the \"which retailers do you\nsupport\" surface behind the marketing site and the free compliance checker.",
    "operationId": "list_retailer_profiles",
    "responses": {
     "200": {
      "description": "Built-in retailer companion-guide profiles"
     }
    }
   }
  },
  "/v1/retailer-profiles/{key}/certification-pack": {
   "get": {
    "tags": [
     "operations"
    ],
    "summary": "Returns the auto-generated certification pack for a retailer profile \u2014 the",
    "description": "exact compliant + rejection cases that certify a relationship against that\nretailer's guide. Public, so a prospect can see what conformance requires.",
    "operationId": "retailer_certification_pack",
    "parameters": [
     {
      "name": "key",
      "in": "path",
      "description": "Retailer profile key, e.g. walmart",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Generated certification test pack"
     },
     "404": {
      "description": "Unknown retailer profile"
     }
    }
   }
  },
  "/v1/retailer-profiles/{key}/check": {
   "post": {
    "tags": [
     "operations"
    ],
    "summary": "Free compliance checker: validate a raw X12 file against a retailer's",
    "description": "published implementation guide, with no account and no side effects. Returns\nthe per-document conformance verdict and every guide violation. This is the\nlead-magnet engine \u2014 a supplier pastes the PO/ASN their retailer rejected and\nsees exactly why.",
    "operationId": "check_retailer_profile",
    "parameters": [
     {
      "name": "key",
      "in": "path",
      "description": "Retailer profile key, e.g. walmart / target / amazon",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "description": "Raw X12 interchange",
     "content": {
      "application/edi-x12": {
       "schema": {
        "type": "string"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "description": "Conformance report against the retailer's guide"
     },
     "404": {
      "description": "Unknown retailer profile"
     }
    }
   }
  },
  "/v1/retailer-profiles/{key}/sample": {
   "get": {
    "tags": [
     "operations"
    ],
    "summary": "Returns a ready-to-edit, guide-compliant sample 850 for a retailer profile \u2014",
    "description": "public, so the checker/landing page can prefill a per-retailer example.",
    "operationId": "retailer_profile_sample",
    "parameters": [
     {
      "name": "key",
      "in": "path",
      "description": "Retailer profile key, e.g. walmart",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "A compliant sample X12 850"
     },
     "404": {
      "description": "Unknown retailer profile"
     }
    }
   }
  },
  "/v1/signing-key": {
   "get": {
    "tags": [
     "operations"
    ],
    "summary": "Returns the Ed25519 public key used to sign VES events, plus a ready-made",
    "description": "payload for registering it with the sequencer's `POST /v1/agents/keys`.",
    "operationId": "signing_key",
    "responses": {
     "200": {
      "description": "The active signing public key"
     },
     "403": {
      "description": "Admin credential required"
     },
     "404": {
      "description": "Signing is disabled"
     }
    }
   }
  },
  "/v1/status-board": {
   "get": {
    "tags": [
     "operations"
    ],
    "summary": "Per-partner operational status board: volume, compliance rate, open",
    "description": "exceptions, and last activity, derived from the documents log and ack SLA.",
    "operationId": "status_board",
    "responses": {
     "200": {
      "description": "Per-partner operational health",
      "content": {
       "application/json": {
        "schema": {
         "type": "array",
         "items": {
          "$ref": "#/components/schemas/StatusBoardEntry"
         }
        }
       }
      }
     },
     "403": {
      "description": "Admin credential required"
     }
    }
   }
  },
  "/v1/templates": {
   "get": {
    "tags": [
     "partners"
    ],
    "summary": "Browses the cross-tenant template library (most-reused first) with a",
    "description": "network-effect summary. A template certified by any tenant is inheritable\nhere.",
    "operationId": "list_templates",
    "responses": {
     "200": {
      "description": "Shared partner templates + library summary",
      "content": {
       "application/json": {
        "schema": {
         "type": "array",
         "items": {
          "$ref": "#/components/schemas/PartnerTemplate"
         }
        }
       }
      }
     },
     "403": {
      "description": "Admin credential required"
     }
    }
   }
  },
  "/v1/templates/{id}": {
   "get": {
    "tags": [
     "partners"
    ],
    "summary": "One shared partner template.",
    "operationId": "get_template",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "description": "Template ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Partner template",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/PartnerTemplate"
        }
       }
      }
     },
     "404": {
      "description": "Unknown template"
     }
    }
   }
  },
  "/v1/templates/{template_id}/instantiate/{partner_id}": {
   "post": {
    "tags": [
     "partners"
    ],
    "summary": "Inherits a shared template into the caller's tenant: creates a trading",
    "description": "partner from the template's guide+map plus the relationship identifiers in\nthe body, and increments the template's reuse count (the flywheel turning).",
    "operationId": "instantiate_template",
    "parameters": [
     {
      "name": "template_id",
      "in": "path",
      "description": "Template to inherit",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "partner_id",
      "in": "path",
      "description": "Internal partner ID to create",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/ConnectorPartnerParams"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "description": "Created partner (key hash redacted)",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/TradingPartner"
        }
       }
      }
     },
     "404": {
      "description": "Unknown template"
     }
    }
   }
  },
  "/v1/tenants": {
   "get": {
    "tags": [
     "partners"
    ],
    "summary": "Lists tenants. Admin-only; the platform operator sees the full catalog.",
    "operationId": "list_tenants",
    "responses": {
     "200": {
      "description": "All tenants",
      "content": {
       "application/json": {
        "schema": {
         "type": "array",
         "items": {
          "$ref": "#/components/schemas/Tenant"
         }
        }
       }
      }
     },
     "403": {
      "description": "Admin credential required"
     }
    }
   },
   "post": {
    "tags": [
     "partners"
    ],
    "summary": "Provisions (or updates) a tenant. Used by the dashboard gateway to create a",
    "description": "tenant per WorkOS organization. Requires Postgres.",
    "operationId": "create_tenant",
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/Tenant"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "description": "The provisioned tenant",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Tenant"
        }
       }
      }
     },
     "403": {
      "description": "Admin credential required"
     },
     "422": {
      "description": "Single-tenant deployment (no DATABASE_URL)"
     }
    }
   }
  },
  "/v1/tenants/{id}": {
   "get": {
    "tags": [
     "partners"
    ],
    "operationId": "get_tenant",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "description": "Tenant ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Tenant record",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Tenant"
        }
       }
      }
     },
     "404": {
      "description": "Unknown tenant"
     }
    }
   }
  },
  "/v1/tenants/{id}/api-keys": {
   "get": {
    "tags": [
     "partners"
    ],
    "summary": "Lists a tenant's API keys (metadata only \u2014 hashes are never returned).",
    "description": "Platform-admin only.",
    "operationId": "list_tenant_keys",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "description": "Tenant ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "The tenant's API keys"
     }
    }
   },
   "post": {
    "tags": [
     "partners"
    ],
    "summary": "Mints a tenant-scoped API key for external REST callers. The key authenticates",
    "description": "as the tenant (full access within it, no platform operations). The plaintext\nis returned **once** and never stored. Platform-admin only.",
    "operationId": "mint_tenant_key",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "description": "Tenant ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "$ref": "#/components/schemas/MintTenantKeyBody"
       }
      }
     },
     "required": true
    },
    "responses": {
     "200": {
      "description": "The new key \u2014 plaintext shown once"
     },
     "403": {
      "description": "Platform-admin credential required"
     },
     "404": {
      "description": "Unknown tenant"
     }
    }
   }
  },
  "/v1/tenants/{id}/api-keys/{key_id}": {
   "delete": {
    "tags": [
     "partners"
    ],
    "summary": "Revokes (deletes) a tenant API key. The key stops authenticating immediately.",
    "description": "Platform-admin only.",
    "operationId": "revoke_tenant_key",
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "description": "Tenant ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "key_id",
      "in": "path",
      "description": "Key ID",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Key revoked"
     },
     "404": {
      "description": "Unknown key"
     }
    }
   }
  },
  "/v1/transport/operations": {
   "get": {
    "tags": [
     "operations"
    ],
    "summary": "Transport operations center: AS2/SFTP/VAN/cert/MDN go-live posture.",
    "operationId": "transport_operations",
    "responses": {
     "200": {
      "description": "Per-partner transport + certificate posture"
     }
    }
   }
  },
  "/v1/usage": {
   "get": {
    "tags": [
     "operations"
    ],
    "summary": "The tenant's consumption ledger rollup \u2014 documents processed and",
    "description": "generated, delivery attempts \u2014 per kind, transaction set, and partner.\nThe billing-grade counterpart to the Prometheus counters.",
    "operationId": "usage_summary",
    "parameters": [
     {
      "name": "from",
      "in": "query",
      "description": "Period start (RFC 3339). Defaults to 30 days ago.",
      "required": false,
      "schema": {
       "type": "string",
       "format": "date-time",
       "nullable": true
      }
     },
     {
      "name": "to",
      "in": "query",
      "description": "Period end, exclusive (RFC 3339). Defaults to now.",
      "required": false,
      "schema": {
       "type": "string",
       "format": "date-time",
       "nullable": true
      }
     }
    ],
    "responses": {
     "200": {
      "description": "Aggregated consumption for the period",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/crate.usage.UsageSummary"
        }
       }
      }
     },
     "403": {
      "description": "Admin or tenant credential required"
     }
    }
   }
  },
  "/v1/van/providers": {
   "get": {
    "tags": [
     "operations"
    ],
    "summary": "Supported VAN providers and whether the local file-backed VAN is enabled.",
    "operationId": "van_providers",
    "responses": {
     "200": {
      "description": "Supported VAN providers"
     }
    }
   }
  },
  "/v1/verify": {
   "post": {
    "tags": [
     "operations"
    ],
    "summary": "Independently verifies the Ed25519 signatures on a set of VES events. This",
    "description": "is the buyer-facing proof of the verifiable-event architecture: anyone\nholding the public key can confirm an event chain is authentic and\nuntampered. The same check runs client-side with `signing::verify`.",
    "operationId": "verify_events",
    "responses": {
     "200": {
      "description": "Per-event verification result"
     },
     "422": {
      "description": "No public key available or unparseable body"
     }
    }
   }
  },
  "/v1/x12/capabilities": {
   "get": {
    "tags": [
     "operations"
    ],
    "summary": "X12 capability discovery: the transaction sets the gateway can parse inbound",
    "description": "and build outbound, and the envelope versions it supports. A buyer can\nconfirm coverage without a sales call.",
    "operationId": "x12_capabilities",
    "responses": {
     "200": {
      "description": "Supported transaction sets and X12 versions"
     }
    }
   }
  }
 },
 "components": {
  "schemas": {
   "Ack855": {
    "type": "object",
    "required": [
     "po_number",
     "ack_date",
     "lines"
    ],
    "properties": {
     "ack_date": {
      "type": "string",
      "format": "date"
     },
     "ack_type": {
      "type": "string",
      "description": "BAK02 acknowledgment type: AC accept, AD accept with detail,\nAK acknowledge no detail, RJ reject."
     },
     "lines": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/AckLine"
      }
     },
     "po_date": {
      "type": "string",
      "format": "date",
      "nullable": true
     },
     "po_number": {
      "type": "string"
     }
    }
   },
   "Ack865": {
    "type": "object",
    "required": [
     "po_number",
     "ack_date",
     "lines"
    ],
    "properties": {
     "ack_date": {
      "type": "string",
      "format": "date"
     },
     "ack_type": {
      "type": "string",
      "description": "BCA02 acknowledgment type: AC accept, AD accept with detail,\nAK acknowledge no detail, RJ reject."
     },
     "lines": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/ChangeAckLine"
      }
     },
     "po_date": {
      "type": "string",
      "format": "date",
      "description": "BCA06 \u2014 original PO date.",
      "nullable": true
     },
     "po_number": {
      "type": "string",
      "description": "BCA03 \u2014 the changed PO being acknowledged."
     }
    }
   },
   "Ack997": {
    "type": "object",
    "description": "A parsed (or to-be-generated) functional acknowledgment.",
    "required": [
     "functional_code",
     "group_control_number",
     "group_status",
     "included",
     "received",
     "accepted",
     "transactions"
    ],
    "properties": {
     "accepted": {
      "type": "integer",
      "minimum": 0
     },
     "functional_code": {
      "type": "string",
      "description": "AK101 \u2014 functional code of the group being acknowledged."
     },
     "group_control_number": {
      "type": "string",
      "description": "AK102 \u2014 GS06 control number of the group being acknowledged."
     },
     "group_status": {
      "type": "string",
      "description": "AK901 \u2014 A accepted, E accepted with errors, R rejected, P partial."
     },
     "included": {
      "type": "integer",
      "description": "AK902/AK903/AK904 \u2014 included / received / accepted counts.",
      "minimum": 0
     },
     "received": {
      "type": "integer",
      "minimum": 0
     },
     "transactions": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/TxAck"
      }
     }
    }
   },
   "AckLine": {
    "type": "object",
    "required": [
     "line_number",
     "quantity"
    ],
    "properties": {
     "ids": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/ProductId"
      }
     },
     "line_number": {
      "type": "string"
     },
     "quantity": {
      "type": "string"
     },
     "status": {
      "type": "string",
      "description": "ACK01 line status: IA item accepted, IB backordered, IQ quantity\nchanged, IR item rejected."
     },
     "status_quantity": {
      "type": "string",
      "description": "ACK02 \u2014 quantity the status applies to; defaults to the line quantity.",
      "nullable": true
     },
     "unit_price": {
      "type": "string",
      "nullable": true
     },
     "uom": {
      "type": "string"
     }
    }
   },
   "AckLineParsed": {
    "type": "object",
    "properties": {
     "ids": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/ProductId"
      }
     },
     "line_number": {
      "type": "string",
      "nullable": true
     },
     "quantity": {
      "type": "string",
      "nullable": true
     },
     "status": {
      "type": "string",
      "description": "ACK01 line status: IA accepted, IB backordered, IR rejected,\nIQ quantity changed.",
      "nullable": true
     },
     "status_quantity": {
      "type": "string",
      "description": "ACK02 \u2014 quantity the status applies to.",
      "nullable": true
     },
     "uom": {
      "type": "string",
      "nullable": true
     }
    }
   },
   "ActiveAlert": {
    "type": "object",
    "description": "An active monitoring alert.",
    "required": [
     "severity",
     "kind",
     "message",
     "count"
    ],
    "properties": {
     "count": {
      "type": "integer",
      "minimum": 0
     },
     "kind": {
      "type": "string",
      "description": "`sla_breach`, `deadletter`, or `delivery_failure`."
     },
     "message": {
      "type": "string"
     },
     "partner_id": {
      "type": "string",
      "nullable": true
     },
     "severity": {
      "type": "string",
      "description": "`warning` or `critical`."
     }
    }
   },
   "AdapterAction": {
    "type": "object",
    "description": "A planned back-end action for one event \u2014 what a live adapter would perform.",
    "required": [
     "adapter",
     "target_system",
     "operation",
     "event_type",
     "entity_type",
     "entity_id"
    ],
    "properties": {
     "adapter": {
      "type": "string"
     },
     "entity_id": {
      "type": "string"
     },
     "entity_type": {
      "type": "string"
     },
     "event_type": {
      "type": "string"
     },
     "operation": {
      "type": "string",
      "description": "Human-readable operation, e.g. `create sales order`."
     },
     "target_system": {
      "type": "string"
     }
    }
   },
   "AdapterDescriptor": {
    "type": "object",
    "description": "A packaged back-end adapter's capability profile.",
    "required": [
     "name",
     "display_name",
     "vendor",
     "kind",
     "status",
     "consumes_events",
     "emits_documents",
     "notes"
    ],
    "properties": {
     "consumes_events": {
      "type": "array",
      "items": {
       "type": "string"
      },
      "description": "Inbound canonical VES event types this adapter writes into the back end."
     },
     "display_name": {
      "type": "string"
     },
     "emits_documents": {
      "type": "array",
      "items": {
       "type": "string"
      },
      "description": "Outbound X12 transaction sets this adapter originates from back-end state."
     },
     "kind": {
      "$ref": "#/components/schemas/AdapterKind"
     },
     "name": {
      "type": "string",
      "description": "Stable lookup key, e.g. `netsuite`."
     },
     "notes": {
      "type": "string"
     },
     "status": {
      "$ref": "#/components/schemas/AdapterStatus"
     },
     "vendor": {
      "type": "string"
     }
    }
   },
   "AdapterKind": {
    "type": "string",
    "description": "The class of system an adapter integrates.",
    "enum": [
     "erp",
     "wms",
     "tms",
     "ecommerce",
     "carrier"
    ]
   },
   "AdapterStatus": {
    "type": "string",
    "description": "Delivery maturity of a packaged adapter.",
    "enum": [
     "ga",
     "beta",
     "planned"
    ]
   },
   "Address": {
    "type": "object",
    "description": "A flattened postal block for rendering.",
    "required": [
     "name"
    ],
    "properties": {
     "lines": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "locality": {
      "type": "string"
     },
     "name": {
      "type": "string"
     }
    }
   },
   "Adjustment812": {
    "type": "object",
    "required": [
     "adjustment_number"
    ],
    "properties": {
     "adjustment_date": {
      "type": "string",
      "format": "date",
      "description": "BGN03 \u2014 adjustment date.",
      "nullable": true
     },
     "adjustment_number": {
      "type": "string",
      "description": "BGN02 \u2014 the adjustment / chargeback document number."
     },
     "amounts": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/AdjustmentAmount"
      },
      "description": "Monetary amounts by AMT01 qualifier."
     },
     "invoice_number": {
      "type": "string",
      "description": "The invoice the deduction is taken against, resolved from REF*IA/IV/IK.",
      "nullable": true
     },
     "parties": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/Party"
      },
      "description": "N1 parties (RE remit-to, etc.)."
     },
     "purpose": {
      "type": "string",
      "description": "BGN01 \u2014 transaction purpose code (`00` original, `01` cancellation, \u2026).",
      "nullable": true
     },
     "reason_codes": {
      "type": "array",
      "items": {
       "type": "string"
      },
      "description": "Adjustment reason codes seen in the document (ITA03 / ADX01 style)."
     },
     "references": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/Reference"
      },
      "description": "All REF references, preserved by qualifier."
     },
     "total_amount": {
      "type": "string",
      "description": "Net deduction amount: the `TT` total when present, else the first amount.",
      "nullable": true
     }
    }
   },
   "AdjustmentAmount": {
    "type": "object",
    "required": [
     "qualifier",
     "amount"
    ],
    "properties": {
     "amount": {
      "type": "string",
      "description": "AMT02 \u2014 monetary amount."
     },
     "qualifier": {
      "type": "string",
      "description": "AMT01 \u2014 amount qualifier code (`TT` total, `N` net, \u2026)."
     }
    }
   },
   "Advice945": {
    "type": "object",
    "required": [
     "order_number",
     "lines"
    ],
    "properties": {
     "carrier_scac": {
      "type": "string",
      "nullable": true
     },
     "lines": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/AdviceLine"
      }
     },
     "order_number": {
      "type": "string",
      "description": "W0602 \u2014 our order number (echoed from the 940)."
     },
     "parties": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/Party"
      }
     },
     "po_number": {
      "type": "string",
      "description": "W0606 \u2014 customer PO, when echoed.",
      "nullable": true
     },
     "ship_date": {
      "type": "string",
      "format": "date",
      "description": "W0603.",
      "nullable": true
     },
     "shipment_id": {
      "type": "string",
      "description": "W0604 \u2014 the warehouse's shipment identification.",
      "nullable": true
     },
     "total_units_shipped": {
      "type": "string",
      "description": "W0301 \u2014 total units shipped, when the warehouse provides it.",
      "nullable": true
     },
     "transport_method": {
      "type": "string",
      "description": "W27 carrier detail.",
      "nullable": true
     }
    }
   },
   "AdviceError": {
    "type": "object",
    "properties": {
     "code": {
      "type": "string",
      "description": "TED01 \u2014 application error condition code.",
      "nullable": true
     },
     "description": {
      "type": "string",
      "description": "TED02 \u2014 free-form error description.",
      "nullable": true
     }
    }
   },
   "AdviceItem": {
    "type": "object",
    "required": [
     "status",
     "status_code"
    ],
    "properties": {
     "errors": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/AdviceError"
      },
      "description": "TED technical error descriptions attached to this item."
     },
     "group_control_number": {
      "type": "string",
      "description": "OTI08 \u2014 the group control number of the advised document.",
      "nullable": true
     },
     "reference_id": {
      "type": "string",
      "description": "OTI03 \u2014 the reference id of the document being advised (e.g. our invoice\nnumber).",
      "nullable": true
     },
     "reference_qualifier": {
      "type": "string",
      "description": "OTI02 \u2014 reference identification qualifier of the advised document.",
      "nullable": true
     },
     "status": {
      "type": "string",
      "description": "Human-readable status mapped from OTI01: `accepted` (TA),\n`accepted_with_errors` (TE), `rejected` (TR), else the raw code."
     },
     "status_code": {
      "type": "string",
      "description": "OTI01 \u2014 raw application acknowledgment code."
     },
     "transaction_set": {
      "type": "string",
      "description": "OTI10 \u2014 the transaction set the advice concerns (e.g. `810`).",
      "nullable": true
     }
    }
   },
   "AdviceLine": {
    "type": "object",
    "required": [
     "status",
     "quantity_shipped"
    ],
    "properties": {
     "ids": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/ProductId"
      },
      "description": "W1207+ qualifier/value pairs (W1206 UPC slot is folded in when set)."
     },
     "quantity_difference": {
      "type": "string",
      "nullable": true
     },
     "quantity_ordered": {
      "type": "string",
      "description": "W1202 / W1203 / W1204.",
      "nullable": true
     },
     "quantity_shipped": {
      "type": "string"
     },
     "status": {
      "type": "string",
      "description": "W1201 \u2014 shipment order status: CC shipped complete, CP partial,\nCN cancelled."
     },
     "uom": {
      "type": "string",
      "description": "W1205.",
      "nullable": true
     }
    }
   },
   "Allowance": {
    "type": "object",
    "description": "One SAC allowance or charge. `amount` is a positive magnitude; `indicator`\n(`A` allowance / `C` charge) carries the direction.",
    "required": [
     "indicator",
     "code",
     "amount"
    ],
    "properties": {
     "amount": {
      "type": "string",
      "description": "SAC05 \u2014 amount in the invoice currency (serialized N2, two implied\ndecimals)."
     },
     "code": {
      "type": "string",
      "description": "SAC02 \u2014 service/promotion/allowance/charge code, e.g. `D240` freight,\n`A170` discount, `G830` handling."
     },
     "description": {
      "type": "string",
      "description": "SAC15 \u2014 free-text description.",
      "nullable": true
     },
     "indicator": {
      "type": "string",
      "description": "SAC01 \u2014 `A` allowance (reduces the invoice), `C` charge (adds to it)."
     }
    }
   },
   "AnalyticsReport": {
    "type": "object",
    "description": "The full analytics report.",
    "required": [
     "total_documents",
     "inbound",
     "outbound",
     "accepted",
     "rejected",
     "by_partner",
     "by_transaction_set",
     "by_day",
     "cycle_time"
    ],
    "properties": {
     "accepted": {
      "type": "integer",
      "minimum": 0
     },
     "by_day": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/DayVolume"
      }
     },
     "by_partner": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/PartnerVolume"
      }
     },
     "by_transaction_set": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/SetVolume"
      }
     },
     "cycle_time": {
      "$ref": "#/components/schemas/CycleTime"
     },
     "error_rate": {
      "type": "integer",
      "format": "int32",
      "description": "Overall error rate, percent 0\u2013100.",
      "nullable": true,
      "minimum": 0
     },
     "inbound": {
      "type": "integer",
      "minimum": 0
     },
     "outbound": {
      "type": "integer",
      "minimum": 0
     },
     "rejected": {
      "type": "integer",
      "minimum": 0
     },
     "total_documents": {
      "type": "integer",
      "minimum": 0
     }
    }
   },
   "AppAdvice824": {
    "type": "object",
    "required": [
     "items"
    ],
    "properties": {
     "date": {
      "type": "string",
      "description": "BGN03 \u2014 date (CCYYMMDD), as transmitted.",
      "nullable": true
     },
     "items": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/AdviceItem"
      }
     },
     "purpose": {
      "type": "string",
      "description": "BGN01 \u2014 transaction set purpose code.",
      "nullable": true
     },
     "reference_id": {
      "type": "string",
      "description": "BGN02 \u2014 the advice's own reference id.",
      "nullable": true
     }
    }
   },
   "As1Config": {
    "type": "object",
    "description": "Per-partner AS1 settings: the address we email outbound documents to.",
    "required": [
     "partner_email"
    ],
    "properties": {
     "partner_email": {
      "type": "string",
      "description": "The partner mailbox that receives our EDI attachments."
     }
    }
   },
   "As1InboundAttachment": {
    "type": "object",
    "description": "One attachment on an inbound AS1 email.",
    "properties": {
     "base64": {
      "type": "boolean"
     },
     "content": {
      "type": "string",
      "description": "Attachment content: base64 when `base64` is true, otherwise plain text."
     },
     "content_type": {
      "type": "string"
     },
     "filename": {
      "type": "string"
     }
    }
   },
   "As1InboundEmail": {
    "type": "object",
    "description": "An inbound EDI email forwarded to us by the mail service (the AS1 receive\npath). The mail service parses the raw message and POSTs this to\n`/v1/as1/inbound`; we extract the interchange and run it through the normal\ninbound pipeline (parse \u2192 validate \u2192 acknowledge \u2192 translate \u2192 sync).",
    "properties": {
     "attachments": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/As1InboundAttachment"
      },
      "description": "Decoded attachments; the EDI is normally the first `application/edi-*`."
     },
     "body": {
      "type": "string",
      "description": "Plain-text body \u2014 the fallback EDI source when there is no attachment."
     },
     "from": {
      "type": "string",
      "description": "Sender address, for logging/audit."
     },
     "partner_id": {
      "type": "string",
      "description": "Optional explicit partner id; when absent the ISA sender resolves it.",
      "nullable": true
     },
     "subject": {
      "type": "string"
     }
    }
   },
   "As2Config": {
    "type": "object",
    "description": "Per-partner AS2 relationship settings. Lives alongside the X12 envelope\nconfig on a trading partner; absent for partners that exchange files only.",
    "required": [
     "our_as2_id",
     "partner_as2_id",
     "partner_url"
    ],
    "properties": {
     "compress_outbound": {
      "type": "boolean",
      "description": "Compress outbound payloads (CMS CompressedData, RFC 5402). Applied\ninnermost: compress \u2192 sign \u2192 encrypt."
     },
     "encrypt_outbound": {
      "type": "boolean",
      "description": "Encrypt outbound payloads (S/MIME). Requires a [`Security`] signer."
     },
     "mdn_mode": {
      "$ref": "#/components/schemas/MdnMode"
     },
     "mic_algorithm": {
      "$ref": "#/components/schemas/MicAlgorithm"
     },
     "our_as2_id": {
      "type": "string",
      "description": "Our AS2 identifier (the value partners address messages to)."
     },
     "partner_as2_id": {
      "type": "string",
      "description": "The partner's AS2 identifier."
     },
     "partner_cert_pem": {
      "type": "string",
      "description": "The partner's X.509 certificate (PEM) \u2014 used to verify their inbound\nsignatures and (later) to encrypt outbound payloads for them.",
      "nullable": true
     },
     "partner_url": {
      "type": "string",
      "description": "The partner's AS2 endpoint URL we POST outbound documents to."
     },
     "request_signed_mdn": {
      "type": "boolean",
      "description": "Request a *signed* MDN (transport-level non-repudiation of receipt).\nRequires a configured [`Security`] signer to verify; until then we\naccept unsigned MDNs."
     },
     "require_encrypted_inbound": {
      "type": "boolean",
      "description": "Require inbound messages from this partner to be encrypted. When set, a\ncleartext inbound message is rejected with a failure MDN. Defaults to\n`false`."
     },
     "require_signed_inbound": {
      "type": "boolean",
      "description": "Require inbound messages from this partner to be signed. When set, an\nunsigned inbound message is rejected with a failure MDN instead of\nprocessed. Defaults to `false` (accept unsigned) to preserve existing\nbehavior; enable it \u2014 together with `partner_cert_pem` \u2014 to mandate\nmessage authentication for a partner. Verification of the signature\nitself still depends on a configured certificate."
     },
     "sign_outbound": {
      "type": "boolean",
      "description": "Sign outbound payloads (S/MIME). Requires a [`Security`] signer."
     }
    }
   },
   "Asn856": {
    "type": "object",
    "required": [
     "shipment_id",
     "ship_date",
     "orders"
    ],
    "properties": {
     "bol_number": {
      "type": "string",
      "description": "REF*BM \u2014 bill of lading.",
      "nullable": true
     },
     "carrier_scac": {
      "type": "string",
      "description": "TD503 \u2014 Standard Carrier Alpha Code.",
      "nullable": true
     },
     "orders": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/AsnOrder"
      }
     },
     "packages": {
      "type": "integer",
      "format": "int32",
      "description": "TD101 / TD102 \u2014 packaging code and lading quantity (e.g. CTN25 \u00d7 3).",
      "nullable": true,
      "minimum": 0
     },
     "ship_date": {
      "type": "string",
      "format": "date"
     },
     "ship_from": {
      "allOf": [
       {
        "$ref": "#/components/schemas/Party"
       }
      ],
      "nullable": true
     },
     "ship_time": {
      "type": "string",
      "description": "HHMM; defaults to 0000 on the wire when absent.",
      "nullable": true
     },
     "ship_to": {
      "allOf": [
       {
        "$ref": "#/components/schemas/Party"
       }
      ],
      "nullable": true
     },
     "shipment_id": {
      "type": "string",
      "description": "BSN02 \u2014 shipment identification."
     },
     "tracking_number": {
      "type": "string",
      "description": "REF*CN \u2014 carrier pro / tracking number.",
      "nullable": true
     },
     "transport_method": {
      "type": "string",
      "description": "TD504 \u2014 transportation method (M motor, A air, ...).",
      "nullable": true
     },
     "weight": {
      "type": "string",
      "description": "TD107/TD108 \u2014 total weight and unit.",
      "nullable": true
     },
     "weight_uom": {
      "type": "string",
      "nullable": true
     }
    }
   },
   "Asn856In": {
    "type": "object",
    "description": "Parsed inbound 856, flattening the S/O/I HL hierarchy into shipment-level\ndetail plus orders and their items.",
    "required": [
     "shipment_id",
     "orders"
    ],
    "properties": {
     "bol_number": {
      "type": "string",
      "description": "REF*BM.",
      "nullable": true
     },
     "carrier_scac": {
      "type": "string",
      "description": "TD503.",
      "nullable": true
     },
     "orders": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/AsnOrderIn"
      }
     },
     "ship_date": {
      "type": "string",
      "format": "date",
      "description": "BSN03.",
      "nullable": true
     },
     "shipment_id": {
      "type": "string",
      "description": "BSN02."
     },
     "tracking_number": {
      "type": "string",
      "description": "REF*CN.",
      "nullable": true
     }
    }
   },
   "AsnItem": {
    "type": "object",
    "required": [
     "sku",
     "quantity"
    ],
    "properties": {
     "quantity": {
      "type": "string"
     },
     "sku": {
      "type": "string"
     },
     "sku_qualifier": {
      "type": "string",
      "description": "LIN qualifier for the identifier, e.g. SK / VN / UP."
     },
     "uom": {
      "type": "string"
     }
    }
   },
   "AsnItemIn": {
    "type": "object",
    "properties": {
     "quantity": {
      "type": "string",
      "description": "SN102.",
      "nullable": true
     },
     "sku": {
      "type": "string",
      "description": "LIN03.",
      "nullable": true
     },
     "sku_qualifier": {
      "type": "string",
      "description": "LIN02 \u2014 identifier qualifier.",
      "nullable": true
     },
     "uom": {
      "type": "string",
      "description": "SN103.",
      "nullable": true
     }
    }
   },
   "AsnOrder": {
    "type": "object",
    "required": [
     "po_number"
    ],
    "properties": {
     "cartons": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/AsnPack"
      },
      "description": "Carton/pack level: each carton carries an SSCC-18 (emitted as `HL*\u2026*P`\nwith `MAN*GM`) and the items packed in it. When non-empty, the ASN uses\nthe S\u2192O\u2192P\u2192I hierarchy retailers like QVC require, and `items` is ignored."
     },
     "items": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/AsnItem"
      },
      "description": "Items shipped directly under the order (no carton breakdown). Used when\n`cartons` is empty."
     },
     "po_number": {
      "type": "string",
      "description": "PRF01 \u2014 the buyer's PO number this shipment fulfills."
     }
    }
   },
   "AsnOrderIn": {
    "type": "object",
    "required": [
     "po_number"
    ],
    "properties": {
     "cartons": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/AsnPackIn"
      },
      "description": "Cartons (HL*P) and the items packed in each, when the ASN is\ncarton-level."
     },
     "items": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/AsnItemIn"
      },
      "description": "Items reported directly under the order (no carton breakdown)."
     },
     "po_number": {
      "type": "string",
      "description": "PRF01 \u2014 the PO this shipment fulfills."
     }
    }
   },
   "AsnPack": {
    "type": "object",
    "required": [
     "sscc",
     "items"
    ],
    "properties": {
     "items": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/AsnItem"
      }
     },
     "sscc": {
      "type": "string",
      "description": "SSCC-18 marked on the carton's GS1-128 label (MAN*GM). Must match the\nphysical label so the carton scans against the ASN."
     }
    }
   },
   "AsnPackIn": {
    "type": "object",
    "required": [
     "items"
    ],
    "properties": {
     "items": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/AsnItemIn"
      }
     },
     "sscc": {
      "type": "string",
      "description": "MAN*GM \u2014 the carton's SSCC-18.",
      "nullable": true
     }
    }
   },
   "AtRiskOrder": {
    "type": "object",
    "description": "An order with at least one variance \u2014 a chargeback risk.",
    "required": [
     "reference",
     "variance_count",
     "top_issue",
     "severity"
    ],
    "properties": {
     "reference": {
      "type": "string"
     },
     "severity": {
      "type": "string"
     },
     "top_issue": {
      "type": "string",
      "description": "The most severe variance kind on the order."
     },
     "variance_count": {
      "type": "integer",
      "minimum": 0
     }
    }
   },
   "BisIssue": {
    "type": "object",
    "description": "A Peppol BIS Billing 3.0 validation finding, tagged with its rule id.",
    "required": [
     "rule",
     "severity",
     "message"
    ],
    "properties": {
     "message": {
      "type": "string"
     },
     "rule": {
      "type": "string",
      "description": "Rule identifier, e.g. `BR-02`, `PEPPOL-EN16931-R020`, `BR-CO-15`."
     },
     "severity": {
      "type": "string",
      "description": "`error` (an access point would reject) or `warning` (advisory)."
     }
    }
   },
   "CardinalityRule": {
    "type": "object",
    "description": "Bounds how many times a segment may occur in a transaction set.",
    "required": [
     "segment"
    ],
    "properties": {
     "max": {
      "type": "integer",
      "description": "Maximum occurrences (`None` = unbounded).",
      "nullable": true,
      "minimum": 0
     },
     "min": {
      "type": "integer",
      "description": "Minimum occurrences (0 = optional).",
      "minimum": 0
     },
     "segment": {
      "type": "string",
      "description": "Segment tag, e.g. `BEG`."
     }
    }
   },
   "CaseResult": {
    "type": "object",
    "description": "The outcome of one certification case.",
    "required": [
     "name",
     "expected_valid",
     "actual_valid",
     "passed"
    ],
    "properties": {
     "actual_valid": {
      "type": "boolean"
     },
     "detail": {
      "type": "string",
      "description": "Why the validator reached its verdict \u2014 structural error or the first\nrejected document's reason \u2014 surfaced so a failing case is debuggable.",
      "nullable": true
     },
     "expected_valid": {
      "type": "boolean"
     },
     "name": {
      "type": "string"
     },
     "passed": {
      "type": "boolean"
     }
    }
   },
   "Catalog832": {
    "type": "object",
    "required": [
     "items"
    ],
    "properties": {
     "catalog_number": {
      "type": "string",
      "description": "BCT02 \u2014 catalog number / identifier.",
      "nullable": true
     },
     "description": {
      "type": "string",
      "description": "BCT07 \u2014 catalog description, when present.",
      "nullable": true
     },
     "items": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/CatalogItem"
      }
     },
     "purpose": {
      "type": "string",
      "description": "BCT01 \u2014 catalog purpose code (e.g. `00` original, `01` cancel, `05`\nreplace).",
      "nullable": true
     }
    }
   },
   "CatalogChange": {
    "type": "object",
    "description": "One entry in an item's changelog.",
    "required": [
     "version",
     "at",
     "changed_fields"
    ],
    "properties": {
     "at": {
      "type": "string",
      "format": "date-time"
     },
     "changed_fields": {
      "type": "array",
      "items": {
       "type": "string"
      },
      "description": "Which attributes changed (`description`, `prices`, `pack_size`, `ids`)."
     },
     "version": {
      "type": "integer",
      "format": "int32",
      "minimum": 0
     }
    }
   },
   "CatalogItem": {
    "type": "object",
    "properties": {
     "description": {
      "type": "string",
      "description": "PID-05 \u2014 free-form item description.",
      "nullable": true
     },
     "ids": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/ProductId"
      },
      "description": "LIN qualifier/value identifier pairs (UP UPC, VN vendor part, BP buyer\npart, \u2026)."
     },
     "pack_size": {
      "type": "string",
      "description": "PO4 pack size (PO4-01 inner pack quantity), when present.",
      "nullable": true
     },
     "prices": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/CatalogPrice"
      },
      "description": "CTP pricing by price type code (CTP-02 qualifier \u2192 CTP-03 price)."
     }
    }
   },
   "CatalogItemRecord": {
    "type": "object",
    "description": "One item in the master, with its change version.",
    "required": [
     "tenant_id",
     "partner_id",
     "sku",
     "version",
     "updated_at"
    ],
    "properties": {
     "description": {
      "type": "string",
      "nullable": true
     },
     "history": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/CatalogChange"
      },
      "description": "Append-only changelog of which attributes changed at each version bump."
     },
     "ids": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/ProductId"
      }
     },
     "pack_size": {
      "type": "string",
      "nullable": true
     },
     "partner_id": {
      "type": "string"
     },
     "prices": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/CatalogPrice"
      }
     },
     "sku": {
      "type": "string"
     },
     "tenant_id": {
      "type": "string"
     },
     "updated_at": {
      "type": "string",
      "format": "date-time"
     },
     "version": {
      "type": "integer",
      "format": "int32",
      "description": "Bumped each time the attributes change; 1 on first ingest.",
      "minimum": 0
     }
    }
   },
   "CatalogPrice": {
    "type": "object",
    "required": [
     "qualifier",
     "price"
    ],
    "properties": {
     "price": {
      "type": "string",
      "description": "CTP-03 unit price."
     },
     "qualifier": {
      "type": "string",
      "description": "CTP-02 price-qualifier code (e.g. `RES` resale, `UCP` unit cost, `LIS`\nlist). Defaults to an empty qualifier when the segment omits it."
     }
    }
   },
   "CategoryRecovery": {
    "type": "object",
    "description": "Deduction roll-up for one root-cause category.",
    "required": [
     "category",
     "count",
     "total_amount",
     "recovered_amount"
    ],
    "properties": {
     "category": {
      "type": "string"
     },
     "count": {
      "type": "integer",
      "minimum": 0
     },
     "recovered_amount": {
      "type": "string"
     },
     "total_amount": {
      "type": "string"
     }
    }
   },
   "CertificationReport": {
    "type": "object",
    "description": "The full certification report for a partner against a pack.",
    "required": [
     "partner_id",
     "pack_name",
     "passed",
     "total",
     "passed_count",
     "results"
    ],
    "properties": {
     "pack_name": {
      "type": "string"
     },
     "partner_id": {
      "type": "string"
     },
     "passed": {
      "type": "boolean",
      "description": "True only when every case passed."
     },
     "passed_count": {
      "type": "integer",
      "minimum": 0
     },
     "results": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/CaseResult"
      }
     },
     "total": {
      "type": "integer",
      "minimum": 0
     }
    }
   },
   "ChangeAckLine": {
    "type": "object",
    "required": [
     "line_number",
     "quantity"
    ],
    "properties": {
     "change_type": {
      "type": "string",
      "description": "POC02 change/response type: CA changes, QD quantity decrease,\nQI quantity increase, DI delete item, AI add item, NC no change."
     },
     "ids": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/ProductId"
      }
     },
     "line_number": {
      "type": "string"
     },
     "quantity": {
      "type": "string",
      "description": "POC03 \u2014 quantity ordered after the change."
     },
     "status": {
      "type": "string",
      "description": "ACK01 line status: IA accepted, IB backordered, IQ quantity changed,\nIR rejected."
     },
     "status_quantity": {
      "type": "string",
      "description": "ACK02 \u2014 quantity the status applies to; defaults to the line quantity.",
      "nullable": true
     },
     "unit_price": {
      "type": "string",
      "nullable": true
     },
     "uom": {
      "type": "string"
     }
    }
   },
   "ChangeAckLineParsed": {
    "type": "object",
    "properties": {
     "change_type": {
      "type": "string",
      "nullable": true
     },
     "ids": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/ProductId"
      }
     },
     "line_number": {
      "type": "string",
      "nullable": true
     },
     "quantity": {
      "type": "string",
      "nullable": true
     },
     "status": {
      "type": "string",
      "nullable": true
     },
     "status_quantity": {
      "type": "string",
      "nullable": true
     },
     "uom": {
      "type": "string",
      "nullable": true
     }
    }
   },
   "ChangeLine": {
    "type": "object",
    "required": [
     "line_number",
     "change_type"
    ],
    "properties": {
     "change_type": {
      "type": "string",
      "description": "POC02 \u2014 change type: AI add item, CA changes, DI delete item,\nQI quantity increase, QD quantity decrease, PC price change, RZ\nreplace all values."
     },
     "description": {
      "type": "string",
      "nullable": true
     },
     "ids": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/ProductId"
      },
      "description": "POC08+ qualifier/value pairs."
     },
     "line_number": {
      "type": "string",
      "description": "POC01 \u2014 buyer's line number."
     },
     "quantity_left": {
      "type": "string",
      "nullable": true
     },
     "quantity_ordered": {
      "type": "string",
      "description": "POC03 / POC04 \u2014 quantity ordered and quantity left to receive.",
      "nullable": true
     },
     "unit_price": {
      "type": "string",
      "description": "POC06 (POC07 is the basis).",
      "nullable": true
     },
     "uom": {
      "type": "string",
      "description": "POC05.",
      "nullable": true
     }
    }
   },
   "CommercialInvoice": {
    "type": "object",
    "description": "The canonical commercial-invoice payload.",
    "required": [
     "invoice_number",
     "invoice_date",
     "seller",
     "buyer",
     "lines"
    ],
    "properties": {
     "buyer": {
      "$ref": "#/components/schemas/CustomsParty"
     },
     "currency": {
      "type": "string",
      "description": "ISO currency code the values are expressed in."
     },
     "freight": {
      "type": "string",
      "description": "Freight charge added to the customs value (when DDP/CIF style terms).",
      "nullable": true
     },
     "incoterms": {
      "type": "string",
      "description": "Incoterms 2020 three-letter rule, e.g. `DAP`, `DDP`, `EXW`.",
      "nullable": true
     },
     "incoterms_place": {
      "type": "string",
      "description": "Named place for the incoterm, e.g. `Rotterdam`.",
      "nullable": true
     },
     "insurance": {
      "type": "string",
      "description": "Insurance charge added to the customs value.",
      "nullable": true
     },
     "invoice_date": {
      "type": "string"
     },
     "invoice_number": {
      "type": "string"
     },
     "lines": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/CustomsLine"
      }
     },
     "po_number": {
      "type": "string",
      "nullable": true
     },
     "reason_for_export": {
      "type": "string",
      "description": "Why the goods are being exported (sale, sample, return, gift) \u2014 a CN22/23\nand many national customs forms require it.",
      "nullable": true
     },
     "seller": {
      "$ref": "#/components/schemas/CustomsParty"
     },
     "ship_to": {
      "allOf": [
       {
        "$ref": "#/components/schemas/CustomsParty"
       }
      ],
      "nullable": true
     }
    }
   },
   "ConditionalRule": {
    "type": "object",
    "description": "An if-then implementation-guide rule: when the trigger element matches,\nthe listed requirements must hold. Covers the common companion-guide\npattern \"if BEG02 = SA then DTM is required\" that flat constraints can't\nexpress.",
    "required": [
     "when_segment",
     "when_element"
    ],
    "properties": {
     "equals": {
      "type": "array",
      "items": {
       "type": "string"
      },
      "description": "Trigger values. Empty means \"when the element is present (non-empty)\"."
     },
     "require_element": {
      "allOf": [
       {
        "$ref": "#/components/schemas/ElementRef"
       }
      ],
      "nullable": true
     },
     "require_segment": {
      "type": "string",
      "description": "Then this segment must be present somewhere in the transaction.",
      "nullable": true
     },
     "when_element": {
      "type": "integer",
      "minimum": 0
     },
     "when_segment": {
      "type": "string",
      "description": "Trigger: segment tag + 1-based element position."
     }
    }
   },
   "ConformanceCheck": {
    "type": "object",
    "description": "One validated property of a generated artifact.",
    "required": [
     "name",
     "ok",
     "detail"
    ],
    "properties": {
     "detail": {
      "type": "string"
     },
     "name": {
      "type": "string"
     },
     "ok": {
      "type": "boolean"
     }
    }
   },
   "ConformanceResult": {
    "type": "object",
    "description": "The conformance verdict for one connector.",
    "required": [
     "connector",
     "partner_name",
     "passed",
     "checks"
    ],
    "properties": {
     "checks": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/ConformanceCheck"
      }
     },
     "connector": {
      "type": "string"
     },
     "partner_name": {
      "type": "string"
     },
     "passed": {
      "type": "boolean"
     }
    }
   },
   "Connector": {
    "type": "object",
    "description": "A retailer EDI profile.",
    "required": [
     "name",
     "display_name",
     "partner_isa_qualifier",
     "version",
     "inbound_sets",
     "outbound_sets",
     "validation",
     "notes"
    ],
    "properties": {
     "category": {
      "type": "string",
      "description": "Retail vertical, e.g. `beauty`, `department`, `club`, `off-price`. Lets\ncallers narrow the catalog (a beauty vendor wants the beauty channels)."
     },
     "delimiters": {
      "$ref": "#/components/schemas/Delimiters"
     },
     "display_name": {
      "type": "string"
     },
     "inbound_sets": {
      "type": "array",
      "items": {
       "type": "string"
      },
      "description": "Transaction sets the retailer sends us (we parse and acknowledge)."
     },
     "name": {
      "type": "string",
      "description": "Stable lookup key, e.g. `walmart`."
     },
     "notes": {
      "type": "string"
     },
     "outbound_sets": {
      "type": "array",
      "items": {
       "type": "string"
      },
      "description": "Transaction sets we send the retailer."
     },
     "partner_isa_qualifier": {
      "type": "string",
      "description": "The retailer's typical ISA interchange ID qualifier (01 DUNS,\n08 UCC/EAN, 12 phone, ZZ mutually defined). Override per relationship."
     },
     "validation": {
      "$ref": "#/components/schemas/PartnerValidation"
     },
     "version": {
      "type": "string",
      "description": "GS08 version/release, e.g. `004010`."
     }
    }
   },
   "ConnectorManifest": {
    "type": "object",
    "description": "An authorable connector definition \u2014 the SDK's unit of distribution.",
    "required": [
     "name",
     "display_name",
     "partner_isa_qualifier",
     "version"
    ],
    "properties": {
     "category": {
      "type": "string"
     },
     "delimiters": {
      "$ref": "#/components/schemas/Delimiters"
     },
     "display_name": {
      "type": "string"
     },
     "inbound_sets": {
      "type": "array",
      "items": {
       "type": "string"
      },
      "description": "Transaction sets the retailer sends (we parse + acknowledge)."
     },
     "name": {
      "type": "string",
      "description": "Stable lookup key, e.g. `acme-retail`."
     },
     "notes": {
      "type": "string"
     },
     "outbound_sets": {
      "type": "array",
      "items": {
       "type": "string"
      },
      "description": "Transaction sets we send the retailer."
     },
     "overlay": {
      "allOf": [
       {
        "$ref": "#/components/schemas/PartnerOverlay"
       }
      ],
      "nullable": true
     },
     "partner_isa_qualifier": {
      "type": "string",
      "description": "The retailer's ISA qualifier (01 DUNS, 08 UCC/EAN, 12 phone, ZZ)."
     },
     "validation": {
      "$ref": "#/components/schemas/PartnerValidation"
     },
     "version": {
      "type": "string",
      "description": "GS08 version/release, e.g. `004010`."
     }
    }
   },
   "ConnectorPartnerParams": {
    "type": "object",
    "description": "Relationship-specific fields supplied when instantiating a partner from a\nconnector.",
    "required": [
     "partner_isa_id",
     "our_isa_qualifier",
     "our_isa_id"
    ],
    "properties": {
     "name": {
      "type": "string",
      "description": "Override the display name.",
      "nullable": true
     },
     "our_isa_id": {
      "type": "string",
      "description": "Our ISA interchange ID (our DUNS or the ID the retailer assigned us)."
     },
     "our_isa_qualifier": {
      "type": "string",
      "description": "Our ISA qualifier for this relationship (often `01` DUNS or `ZZ`)."
     },
     "partner_isa_id": {
      "type": "string",
      "description": "The retailer's ISA interchange ID (their assigned identifier)."
     },
     "partner_isa_qualifier": {
      "type": "string",
      "description": "Override the connector's default partner ISA qualifier.",
      "nullable": true
     },
     "usage": {
      "type": "string",
      "description": "`P` production (default) or `T` test.",
      "nullable": true
     }
    }
   },
   "CountRule": {
    "type": "object",
    "description": "A counter element must equal the number of occurrences of another segment \u2014\nthe `CTT01 == count(PO1)` companion-guide staple.",
    "required": [
     "counter_segment",
     "counter_element",
     "counted_segment"
    ],
    "properties": {
     "counted_segment": {
      "type": "string",
      "description": "Segment being counted, e.g. `PO1`."
     },
     "counter_element": {
      "type": "integer",
      "description": "1-based element position of the count, e.g. `1`.",
      "minimum": 0
     },
     "counter_segment": {
      "type": "string",
      "description": "Segment carrying the count, e.g. `CTT`."
     }
    }
   },
   "CustomsCategory": {
    "type": "string",
    "description": "The reason category a postal declaration must state.",
    "enum": [
     "gift",
     "commercial_sample",
     "returned_goods",
     "sale_of_goods",
     "documents",
     "other"
    ]
   },
   "CustomsLine": {
    "type": "object",
    "description": "One declared line on the commercial invoice.",
    "required": [
     "description",
     "quantity",
     "unit_price"
    ],
    "properties": {
     "country_of_origin": {
      "type": "string",
      "description": "ISO country of origin (where the goods were manufactured).",
      "nullable": true
     },
     "description": {
      "type": "string"
     },
     "hs_code": {
      "type": "string",
      "description": "Harmonized System tariff code (6\u201310 digits). Customs assesses duty by\nthis code, so it is required for a compliant declaration.",
      "nullable": true
     },
     "net_weight_kg": {
      "type": "string",
      "description": "Net weight in kilograms for this line \u2014 required by postal customs\ndeclarations (CN22/CN23).",
      "nullable": true
     },
     "quantity": {
      "type": "string"
     },
     "sku": {
      "type": "string",
      "nullable": true
     },
     "unit_price": {
      "type": "string"
     },
     "uom": {
      "type": "string"
     }
    }
   },
   "CustomsLineMeta": {
    "type": "object",
    "properties": {
     "country_of_origin": {
      "type": "string",
      "nullable": true
     },
     "description": {
      "type": "string",
      "nullable": true
     },
     "hs_code": {
      "type": "string",
      "nullable": true
     }
    }
   },
   "CustomsOverlay": {
    "type": "object",
    "description": "Customs metadata layered over an EDI invoice that the X12/EDIFACT payload\ndoesn't carry.",
    "properties": {
     "currency": {
      "type": "string"
     },
     "freight": {
      "type": "string",
      "nullable": true
     },
     "incoterms": {
      "type": "string",
      "nullable": true
     },
     "incoterms_place": {
      "type": "string",
      "nullable": true
     },
     "insurance": {
      "type": "string",
      "nullable": true
     },
     "lines": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/CustomsLineMeta"
      },
      "description": "Per-line customs metadata, matched positionally to the invoice lines."
     },
     "reason_for_export": {
      "type": "string",
      "nullable": true
     },
     "ship_to": {
      "allOf": [
       {
        "$ref": "#/components/schemas/CustomsParty"
       }
      ],
      "nullable": true
     }
    }
   },
   "CustomsParty": {
    "type": "object",
    "description": "A party on the customs document (exporter, importer, or consignee).",
    "required": [
     "name"
    ],
    "properties": {
     "address_lines": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "city": {
      "type": "string",
      "nullable": true
     },
     "country": {
      "type": "string",
      "description": "ISO country code or name \u2014 required for the importer/exporter blocks.",
      "nullable": true
     },
     "name": {
      "type": "string"
     },
     "postal_code": {
      "type": "string",
      "nullable": true
     },
     "state": {
      "type": "string",
      "nullable": true
     },
     "tax_id": {
      "type": "string",
      "description": "Tax / EORI / VAT registration, when the destination requires it.",
      "nullable": true
     }
    }
   },
   "CycleTime": {
    "type": "object",
    "description": "Order-to-cash cycle time across references that span multiple documents.",
    "required": [
     "references_measured"
    ],
    "properties": {
     "max_hours": {
      "type": "integer",
      "format": "int64",
      "nullable": true
     },
     "median_hours": {
      "type": "integer",
      "format": "int64",
      "nullable": true
     },
     "p95_hours": {
      "type": "integer",
      "format": "int64",
      "nullable": true
     },
     "references_measured": {
      "type": "integer",
      "description": "References with at least two documents (an order and a downstream doc).",
      "minimum": 0
     }
    }
   },
   "DayVolume": {
    "type": "object",
    "description": "Document count for one day.",
    "required": [
     "date",
     "count"
    ],
    "properties": {
     "count": {
      "type": "integer",
      "minimum": 0
     },
     "date": {
      "type": "string"
     }
    }
   },
   "Deduction": {
    "type": "object",
    "description": "A captured deduction and its dispute state.",
    "required": [
     "id",
     "tenant_id",
     "partner_id",
     "adjustment_number",
     "amount",
     "status",
     "history",
     "created_at",
     "updated_at"
    ],
    "properties": {
     "adjustment_number": {
      "type": "string",
      "description": "The 812 adjustment / chargeback number."
     },
     "amount": {
      "type": "string"
     },
     "category": {
      "type": "string",
      "description": "Operator-assigned root-cause category (e.g. `shortage`, `label`, `asn`).",
      "nullable": true
     },
     "created_at": {
      "type": "string",
      "format": "date-time"
     },
     "currency": {
      "type": "string"
     },
     "evidence": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/EvidenceNote"
      },
      "description": "Supporting evidence attached for the dispute."
     },
     "history": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/DeductionEvent"
      }
     },
     "id": {
      "type": "string"
     },
     "invoice_number": {
      "type": "string",
      "nullable": true
     },
     "partner_id": {
      "type": "string"
     },
     "reason_codes": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "recovered_amount": {
      "type": "string",
      "description": "Amount recovered when disputed successfully (\u2264 `amount`).",
      "nullable": true
     },
     "status": {
      "$ref": "#/components/schemas/DeductionStatus"
     },
     "tenant_id": {
      "type": "string"
     },
     "updated_at": {
      "type": "string",
      "format": "date-time"
     }
    }
   },
   "DeductionCapture": {
    "type": "object",
    "description": "Fields needed to capture a new deduction.",
    "required": [
     "partner_id",
     "adjustment_number",
     "amount"
    ],
    "properties": {
     "adjustment_number": {
      "type": "string"
     },
     "amount": {
      "type": "string"
     },
     "category": {
      "type": "string",
      "nullable": true
     },
     "currency": {
      "type": "string",
      "nullable": true
     },
     "invoice_number": {
      "type": "string",
      "nullable": true
     },
     "partner_id": {
      "type": "string"
     },
     "reason_codes": {
      "type": "array",
      "items": {
       "type": "string"
      }
     }
    }
   },
   "DeductionEvent": {
    "type": "object",
    "description": "One entry in a deduction's audit trail.",
    "required": [
     "at",
     "actor",
     "action"
    ],
    "properties": {
     "action": {
      "type": "string"
     },
     "actor": {
      "type": "string"
     },
     "at": {
      "type": "string",
      "format": "date-time"
     },
     "note": {
      "type": "string",
      "nullable": true
     }
    }
   },
   "DeductionStatus": {
    "type": "string",
    "description": "Lifecycle state of a deduction.",
    "enum": [
     "open",
     "disputed",
     "recovered",
     "denied",
     "written_off"
    ]
   },
   "DeductionSummary": {
    "type": "object",
    "description": "Roll-up of deduction exposure and recovery for a tenant.",
    "required": [
     "total",
     "open",
     "disputed",
     "recovered",
     "denied",
     "written_off",
     "at_risk_amount",
     "recovered_amount",
     "denied_amount",
     "by_category"
    ],
    "properties": {
     "at_risk_amount": {
      "type": "string",
      "description": "Sum of amounts not yet terminal \u2014 money still at risk."
     },
     "by_category": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/CategoryRecovery"
      },
      "description": "Exposure and recovery broken out by root-cause category."
     },
     "denied": {
      "type": "integer",
      "minimum": 0
     },
     "denied_amount": {
      "type": "string",
      "description": "Sum of original amounts on lost (denied) disputes."
     },
     "disputed": {
      "type": "integer",
      "minimum": 0
     },
     "open": {
      "type": "integer",
      "minimum": 0
     },
     "recovered": {
      "type": "integer",
      "minimum": 0
     },
     "recovered_amount": {
      "type": "string",
      "description": "Sum of recovered amounts on recovered deductions."
     },
     "recovery_rate": {
      "type": "integer",
      "format": "int32",
      "description": "Recovered \u00f7 (recovered + denied) by amount, percent 0\u2013100 \u2014 how well\ndisputes are converting. `None` until at least one dispute is resolved\nwith a monetary outcome.",
      "nullable": true,
      "minimum": 0
     },
     "total": {
      "type": "integer",
      "minimum": 0
     },
     "written_off": {
      "type": "integer",
      "minimum": 0
     }
    }
   },
   "Delimiters": {
    "type": "object",
    "description": "The four delimiters that frame an X12 interchange. The element separator\nand segment terminator are dictated by the ISA segment itself; the\ncomponent separator is ISA16. The repetition separator (ISA11) only\nexists in 00501+ interchanges.",
    "required": [
     "element",
     "component",
     "segment"
    ],
    "properties": {
     "component": {
      "type": "string",
      "example": ">"
     },
     "element": {
      "type": "string",
      "example": "*"
     },
     "repetition": {
      "type": "string",
      "nullable": true
     },
     "segment": {
      "type": "string",
      "example": "~"
     }
    }
   },
   "DeliveryStatus": {
    "oneOf": [
     {
      "type": "object",
      "description": "No access point configured: the UBL is generated and validated but not\ntransmitted. This is the honest default \u2014 Peppol delivery requires a\ncertified access-point partner and the customer's jurisdiction.",
      "required": [
       "reason",
       "state"
      ],
      "properties": {
       "reason": {
        "type": "string"
       },
       "state": {
        "type": "string",
        "enum": [
         "generation_only"
        ]
       }
      }
     }
    ],
    "description": "Where a generated e-invoice stands on delivery. The gateway generates and\nvalidates; transmission to a government / Peppol network is performed by a\ncertified access point, which is configured per deployment and jurisdiction.",
    "discriminator": {
     "propertyName": "state"
    }
   },
   "DiffEntry": {
    "type": "object",
    "description": "One field-level change between two guide versions.",
    "required": [
     "path",
     "change"
    ],
    "properties": {
     "after": {
      "type": "object"
     },
     "before": {
      "type": "object"
     },
     "change": {
      "type": "string",
      "description": "`added`, `removed`, or `changed`."
     },
     "path": {
      "type": "string",
      "description": "Dotted path, e.g. `validation.rules[0].mandatory`."
     }
    }
   },
   "DocumentDetail": {
    "type": "object",
    "description": "Drill-down audit detail for a processed document. The summary record is\nintentionally compact; this companion record keeps the heavier artifacts\noperators need during an EDI incident: raw wire, parsed/canonical data,\nsegment list, validation failure, and the generated acknowledgment.",
    "required": [
     "document",
     "raw"
    ],
    "properties": {
     "acknowledgment": {
      "type": "string",
      "description": "Generated 997 / TA1 / CONTRL acknowledgment for inbound documents.",
      "nullable": true
     },
     "document": {
      "$ref": "#/components/schemas/DocumentRecord"
     },
     "parsed": {
      "description": "Canonical parsed payload returned by the transaction parser.",
      "nullable": true
     },
     "raw": {
      "type": "string",
      "description": "Full raw interchange or outbound wire that produced this record."
     },
     "segments": {
      "type": "array",
      "items": {
       "type": "object"
      },
      "description": "X12 segment list when available. Empty for EDIFACT until message-level\nsegment rendering is promoted into the EDIFACT crate API."
     },
     "validation_error": {
      "type": "string",
      "description": "Partner-guide or parser failure when the document was rejected.",
      "nullable": true
     },
     "validation_issues": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/crate.partners.ValidationIssue"
      },
      "description": "Structured guide violations behind `validation_error`, with 999-grade\nsegment/element positions \u2014 everything a partner needs to fix the file."
     }
    }
   },
   "DocumentRecord": {
    "type": "object",
    "description": "An entry in the processed-document log.",
    "required": [
     "id",
     "direction",
     "partner_id",
     "transaction_set",
     "control_number",
     "status",
     "reference",
     "processed_at"
    ],
    "properties": {
     "control_number": {
      "type": "string"
     },
     "correlation_id": {
      "type": "string",
      "description": "Ties this record to the request's logs (and, for outbound, its delivery).\nDefaulted for log lines written before correlation tracking existed."
     },
     "direction": {
      "type": "string",
      "description": "`inbound` or `outbound`."
     },
     "id": {
      "type": "string"
     },
     "partner_id": {
      "type": "string"
     },
     "processed_at": {
      "type": "string",
      "format": "date-time"
     },
     "reference": {
      "type": "string",
      "description": "Human-readable handle: PO number, shipment ID, invoice number."
     },
     "status": {
      "type": "string",
      "description": "`accepted`, `rejected`, or `sent`."
     },
     "transaction_set": {
      "type": "string",
      "description": "Transaction set ID, e.g. `850`."
     }
    }
   },
   "DocumentValidation": {
    "type": "object",
    "required": [
     "transaction_set",
     "control_number",
     "accepted"
    ],
    "properties": {
     "accepted": {
      "type": "boolean"
     },
     "control_number": {
      "type": "string"
     },
     "reason": {
      "type": "string",
      "nullable": true
     },
     "transaction_set": {
      "type": "string"
     }
    }
   },
   "EInvoiceParty": {
    "type": "object",
    "description": "A party on a Peppol invoice. `endpoint_id` + `endpoint_scheme` are the\nPeppol participant identifier (e.g. scheme `0088` GLN, `9930` DE:VAT) that\nrouting depends on; `vat_id` and `country` are BIS-mandatory.",
    "required": [
     "name"
    ],
    "properties": {
     "city": {
      "type": "string",
      "nullable": true
     },
     "country": {
      "type": "string",
      "description": "ISO 3166-1 alpha-2 country code (BIS-mandatory).",
      "nullable": true
     },
     "endpoint_id": {
      "type": "string",
      "description": "Peppol participant ID (the value), e.g. a GLN or VAT number.",
      "nullable": true
     },
     "endpoint_scheme": {
      "type": "string",
      "description": "Peppol electronic-address scheme (EAS code), e.g. `0088`, `9930`.",
      "nullable": true
     },
     "name": {
      "type": "string"
     },
     "postal_code": {
      "type": "string",
      "nullable": true
     },
     "street": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "vat_id": {
      "type": "string",
      "nullable": true
     }
    }
   },
   "EdiEvent": {
    "type": "object",
    "description": "One VES event, shaped for `POST /v1/ves/events/ingest` on the sequencer.",
    "required": [
     "event_id",
     "event_type",
     "entity_type",
     "entity_id",
     "occurred_at",
     "payload"
    ],
    "properties": {
     "entity_id": {
      "type": "string"
     },
     "entity_type": {
      "type": "string"
     },
     "event_id": {
      "type": "string"
     },
     "event_type": {
      "type": "string"
     },
     "occurred_at": {
      "type": "string",
      "format": "date-time"
     },
     "payload": {
      "type": "object"
     },
     "signature": {
      "type": "string",
      "description": "Ed25519 signature (hex) over the canonical event message. Absent when\nsigning is disabled. See [`crate::signing`].",
      "nullable": true
     }
    }
   },
   "ElementConstraint": {
    "type": "object",
    "description": "Constrains one positional element of a segment: it may be required and/or\nrestricted to an allowed value set. Because segment tags are specific to a\ntransaction set (PO1\u2192850, IT1\u2192810, ...), a constraint naturally applies\nonly where its segment occurs.",
    "required": [
     "segment",
     "element"
    ],
    "properties": {
     "allowed": {
      "type": "array",
      "items": {
       "type": "string"
      },
      "description": "If non-empty, the element must be one of these values."
     },
     "element": {
      "type": "integer",
      "description": "1-based element position, e.g. `3` for the PO1 unit of measure.",
      "minimum": 0
     },
     "format": {
      "allOf": [
       {
        "$ref": "#/components/schemas/ElementFormat"
       }
      ],
      "nullable": true
     },
     "max_len": {
      "type": "integer",
      "description": "Maximum length (in characters) when the element is present.",
      "nullable": true,
      "minimum": 0
     },
     "min_len": {
      "type": "integer",
      "description": "Minimum length (in characters) when the element is present.",
      "nullable": true,
      "minimum": 0
     },
     "required": {
      "type": "boolean",
      "description": "If true, the element must be present (non-empty)."
     },
     "segment": {
      "type": "string",
      "description": "Segment tag, e.g. `PO1`."
     }
    }
   },
   "ElementFormat": {
    "type": "string",
    "description": "X12 data-type formats an element can be pinned to. Deliberately the\nhigh-value subset: numeric identifiers, decimal amounts, and the CCYYMMDD /\nHHMM(SS) date-time shapes that reject the malformed values retailers\ncharge back over. Anything not listed validates as free text.",
    "enum": [
     "numeric",
     "decimal",
     "date",
     "time"
    ]
   },
   "ElementOverride": {
    "type": "object",
    "required": [
     "segment",
     "element",
     "value"
    ],
    "properties": {
     "element": {
      "type": "integer",
      "description": "1-based element position (element 1 is the first after the segment tag).",
      "minimum": 0
     },
     "segment": {
      "type": "string"
     },
     "transaction_set": {
      "type": "string",
      "nullable": true
     },
     "value": {
      "type": "string"
     }
    }
   },
   "ElementRef": {
    "type": "object",
    "description": "A (segment tag, 1-based element position) pair.",
    "required": [
     "segment",
     "element"
    ],
    "properties": {
     "element": {
      "type": "integer",
      "minimum": 0
     },
     "segment": {
      "type": "string"
     }
    }
   },
   "EligibilityInquiry270": {
    "type": "object",
    "required": [
     "trace_number",
     "inquiry_date",
     "payer_name",
     "payer_id",
     "provider_name",
     "provider_npi",
     "subscriber"
    ],
    "properties": {
     "inquiry_date": {
      "type": "string",
      "format": "date",
      "description": "BHT04 \u2014 inquiry date."
     },
     "payer_id": {
      "type": "string"
     },
     "payer_name": {
      "type": "string",
      "description": "2100A NM1*PR \u2014 payer name and id (PI)."
     },
     "provider_name": {
      "type": "string",
      "description": "2100B NM1*1P \u2014 provider name and NPI (XX)."
     },
     "provider_npi": {
      "type": "string"
     },
     "service_types": {
      "type": "array",
      "items": {
       "type": "string"
      },
      "description": "2110C EQ \u2014 service type codes (default `30`, health benefit plan coverage)."
     },
     "subscriber": {
      "$ref": "#/components/schemas/Subscriber"
     },
     "trace_number": {
      "type": "string",
      "description": "TRN02 \u2014 trace number tying the response back to this inquiry."
     }
    }
   },
   "EvidenceNote": {
    "type": "object",
    "description": "A piece of supporting evidence attached to a deduction \u2014 the chain of\ncustody a dispute is won on (a POD reference, a signed BOL link, a note).",
    "required": [
     "at",
     "actor",
     "note"
    ],
    "properties": {
     "actor": {
      "type": "string"
     },
     "at": {
      "type": "string",
      "format": "date-time"
     },
     "note": {
      "type": "string"
     },
     "url": {
      "type": "string",
      "description": "Link to the supporting artifact (an evidence-bundle export, a POD scan).",
      "nullable": true
     }
    }
   },
   "FulfillmentScorecard": {
    "type": "object",
    "description": "Program-level fulfillment health aggregated across all reconciled orders.",
    "required": [
     "orders",
     "orders_with_shipment",
     "total_ordered",
     "total_shipped",
     "total_warehouse_shipped",
     "perfect_orders",
     "variance_counts",
     "at_risk"
    ],
    "properties": {
     "at_risk": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/AtRiskOrder"
      },
      "description": "Orders carrying chargeback risk, worst first."
     },
     "fill_rate": {
      "type": "integer",
      "format": "int32",
      "description": "`min(shipped, ordered) / ordered` as a percent 0\u2013100 \u2014 the true fill\nrate (over-shipping doesn't inflate it; it shows up as a variance).",
      "nullable": true,
      "minimum": 0
     },
     "orders": {
      "type": "integer",
      "description": "Orders with a purchase order.",
      "minimum": 0
     },
     "orders_with_shipment": {
      "type": "integer",
      "description": "Orders that also have a shipment notice or warehouse advice.",
      "minimum": 0
     },
     "perfect_order_rate": {
      "type": "integer",
      "format": "int32",
      "description": "`perfect_orders / orders` percent.",
      "nullable": true,
      "minimum": 0
     },
     "perfect_orders": {
      "type": "integer",
      "description": "Orders with zero variances.",
      "minimum": 0
     },
     "total_ordered": {
      "type": "string"
     },
     "total_shipped": {
      "type": "string"
     },
     "total_warehouse_shipped": {
      "type": "string"
     },
     "variance_counts": {
      "type": "object",
      "description": "Variance count by kind (`short_shipped`, `over_shipped`, \u2026).",
      "additionalProperties": {
       "type": "integer",
       "minimum": 0
      }
     },
     "warehouse_fill_rate": {
      "type": "integer",
      "format": "int32",
      "description": "`min(warehouse_shipped, ordered) / ordered` percent \u2014 3PL execution.",
      "nullable": true,
      "minimum": 0
     }
    }
   },
   "GuideDiff": {
    "type": "object",
    "description": "The diff between two guide versions.",
    "required": [
     "from_version",
     "to_version",
     "changes"
    ],
    "properties": {
     "changes": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/DiffEntry"
      }
     },
     "from_version": {
      "type": "integer",
      "format": "int32",
      "minimum": 0
     },
     "to_version": {
      "type": "integer",
      "format": "int32",
      "minimum": 0
     }
    }
   },
   "GuideIssue": {
    "type": "object",
    "description": "One problem found while validating a guide before publish.",
    "required": [
     "severity",
     "field",
     "message"
    ],
    "properties": {
     "field": {
      "type": "string"
     },
     "message": {
      "type": "string"
     },
     "severity": {
      "type": "string",
      "description": "`error` blocks publish; `warning` is advisory."
     }
    }
   },
   "GuideSnapshot": {
    "type": "object",
    "description": "An immutable snapshot of a partner's guide at a point in time.",
    "required": [
     "partner_id",
     "tenant_id",
     "version",
     "validation",
     "author",
     "created_at"
    ],
    "properties": {
     "author": {
      "type": "string",
      "description": "Who captured it (`admin`, `partner:{id}`)."
     },
     "created_at": {
      "type": "string",
      "format": "date-time"
     },
     "note": {
      "type": "string",
      "nullable": true
     },
     "overlay": {
      "allOf": [
       {
        "$ref": "#/components/schemas/PartnerOverlay"
       }
      ],
      "nullable": true
     },
     "partner_id": {
      "type": "string"
     },
     "tenant_id": {
      "type": "string"
     },
     "validation": {
      "$ref": "#/components/schemas/PartnerValidation"
     },
     "version": {
      "type": "integer",
      "format": "int32",
      "description": "Monotonic version, starting at 1.",
      "minimum": 0
     }
    }
   },
   "InboundDocument": {
    "type": "object",
    "required": [
     "transaction_set",
     "control_number",
     "status",
     "reference"
    ],
    "properties": {
     "control_number": {
      "type": "string"
     },
     "error": {
      "type": "string",
      "nullable": true
     },
     "parsed": {
      "type": "object",
      "nullable": true
     },
     "reference": {
      "type": "string"
     },
     "status": {
      "type": "string"
     },
     "transaction_set": {
      "type": "string"
     }
    }
   },
   "InboundResult": {
    "type": "object",
    "required": [
     "partner_id",
     "interchange_control_number",
     "status",
     "documents",
     "events_queued"
    ],
    "properties": {
     "ack_997": {
      "type": "string",
      "description": "Serialized 997 interchange acknowledging what we received. `None` when\nthe inbound interchange only contained FA groups or was rejected.",
      "nullable": true
     },
     "ack_contrl": {
      "type": "string",
      "description": "Serialized EDIFACT CONTRL acknowledgment, for inbound EDIFACT interchanges.",
      "nullable": true
     },
     "ack_ta1": {
      "type": "string",
      "description": "Serialized TA1 interchange rejection, when envelope validation failed.",
      "nullable": true
     },
     "documents": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/InboundDocument"
      }
     },
     "error": {
      "type": "string",
      "nullable": true
     },
     "events_queued": {
      "type": "integer",
      "minimum": 0
     },
     "interchange_control_number": {
      "type": "string"
     },
     "partner_id": {
      "type": "string"
     },
     "status": {
      "type": "string",
      "description": "`processed` or `interchange_rejected`."
     }
    }
   },
   "IngestSummary": {
    "type": "object",
    "description": "Summary of an 832 ingest.",
    "required": [
     "items",
     "created",
     "updated",
     "unchanged",
     "skipped"
    ],
    "properties": {
     "created": {
      "type": "integer",
      "minimum": 0
     },
     "items": {
      "type": "integer",
      "minimum": 0
     },
     "skipped": {
      "type": "integer",
      "minimum": 0
     },
     "unchanged": {
      "type": "integer",
      "minimum": 0
     },
     "updated": {
      "type": "integer",
      "minimum": 0
     }
    }
   },
   "InventoryAdvice846": {
    "type": "object",
    "required": [
     "purpose",
     "report_type",
     "reference_id",
     "items"
    ],
    "properties": {
     "date": {
      "type": "string",
      "format": "date",
      "description": "BIA04.",
      "nullable": true
     },
     "items": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/InventoryItem"
      }
     },
     "parties": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/Party"
      }
     },
     "purpose": {
      "type": "string",
      "description": "BIA01 \u2014 transaction set purpose (00 original, 05 replace, ...)."
     },
     "reference_id": {
      "type": "string",
      "description": "BIA03 \u2014 the sender's reference identification for this report."
     },
     "report_type": {
      "type": "string",
      "description": "BIA02 \u2014 report type code (e.g. `PQ` product activity, `SI` current\nsummary inventory)."
     }
    }
   },
   "InventoryItem": {
    "type": "object",
    "required": [
     "ids",
     "quantities"
    ],
    "properties": {
     "description": {
      "type": "string",
      "description": "PID05 of the F-format description, when present.",
      "nullable": true
     },
     "ids": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/ProductId"
      },
      "description": "LIN02+ qualifier/value identifier pairs (UP UPC, SK seller SKU, ...)."
     },
     "line_number": {
      "type": "string",
      "description": "LIN01 \u2014 assigned line number (optional in the spec).",
      "nullable": true
     },
     "quantities": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/InventoryQuantity"
      },
      "description": "QTY segments for this item, one per reported quantity kind."
     }
    }
   },
   "InventoryQuantity": {
    "type": "object",
    "required": [
     "qualifier",
     "quantity"
    ],
    "properties": {
     "qualifier": {
      "type": "string",
      "description": "QTY01 quantity qualifier: `33` available, `17` on-hand/quantity\nreceived, `20` damaged, `83` backorder, `99` quantity remaining, ..."
     },
     "quantity": {
      "type": "string",
      "description": "QTY02."
     },
     "uom": {
      "type": "string",
      "description": "QTY03 \u2014 composite unit of measure (first component is the UOM code).",
      "nullable": true
     }
    }
   },
   "Invoice810": {
    "type": "object",
    "required": [
     "invoice_number",
     "invoice_date",
     "po_number",
     "lines",
     "total_amount"
    ],
    "properties": {
     "allowances": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/Allowance"
      },
      "description": "Header-level allowances and charges (SAC) \u2014 freight, discounts, handling,\npromotional allowances. Retailers chargeback when these don't reconcile,\nso they are first-class, not folded silently into the unit price."
     },
     "invoice_date": {
      "type": "string",
      "format": "date",
      "description": "BIG01."
     },
     "invoice_number": {
      "type": "string",
      "description": "BIG02."
     },
     "lines": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/InvoiceLine"
      }
     },
     "po_number": {
      "type": "string",
      "description": "BIG04 \u2014 the PO being invoiced."
     },
     "terms_discount_days": {
      "type": "integer",
      "format": "int32",
      "nullable": true,
      "minimum": 0
     },
     "terms_discount_percent": {
      "type": "string",
      "nullable": true
     },
     "terms_net_days": {
      "type": "integer",
      "format": "int32",
      "description": "ITD payment terms, e.g. net days.",
      "nullable": true,
      "minimum": 0
     },
     "total_amount": {
      "type": "string",
      "description": "Total invoice amount in the partner's currency. Serialized into TDS\nwith implied two decimals, per spec."
     }
    }
   },
   "InvoiceIn810": {
    "type": "object",
    "description": "Parsed inbound 810.",
    "required": [
     "invoice_number",
     "lines"
    ],
    "properties": {
     "allowances": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/Allowance"
      },
      "description": "Header-level allowances/charges (SAC) on the supplier's invoice."
     },
     "invoice_date": {
      "type": "string",
      "format": "date",
      "description": "BIG01.",
      "nullable": true
     },
     "invoice_number": {
      "type": "string",
      "description": "BIG02."
     },
     "lines": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/InvoiceLineIn"
      }
     },
     "po_number": {
      "type": "string",
      "description": "BIG04 \u2014 the PO this invoice bills against.",
      "nullable": true
     },
     "total_amount": {
      "type": "string",
      "description": "TDS01 total, restored from its implied-two-decimal wire form.",
      "nullable": true
     }
    }
   },
   "InvoiceLine": {
    "type": "object",
    "required": [
     "quantity",
     "unit_price"
    ],
    "properties": {
     "ids": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/ProductId"
      }
     },
     "line_number": {
      "type": "string",
      "nullable": true
     },
     "quantity": {
      "type": "string"
     },
     "unit_price": {
      "type": "string"
     },
     "uom": {
      "type": "string"
     }
    }
   },
   "InvoiceLineIn": {
    "type": "object",
    "properties": {
     "ids": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/ProductId"
      }
     },
     "line_number": {
      "type": "string",
      "nullable": true
     },
     "quantity": {
      "type": "string",
      "nullable": true
     },
     "unit_price": {
      "type": "string",
      "nullable": true
     },
     "uom": {
      "type": "string",
      "nullable": true
     }
    }
   },
   "LabelProfile": {
    "type": "object",
    "description": "Per-partner label **placement profile** \u2014 the label facet of a partner\ncompanion guide. Controls the physical label (print width, length, darkness)\nand an optional partner-required mark. Defaults to a 4\u00d76\" thermal label at\n203 dpi.",
    "properties": {
     "darkness": {
      "type": "integer",
      "format": "int32",
      "description": "Print darkness (ZPL `^MD`, 0\u201330); `None` leaves the printer default.",
      "nullable": true,
      "minimum": 0
     },
     "height_dots": {
      "type": "integer",
      "format": "int32",
      "description": "Label length in dots (ZPL `^LL`). 1218 = 6\" at 203 dpi.",
      "minimum": 0
     },
     "partner_mark": {
      "type": "string",
      "description": "A partner-required mark printed at the label's top edge (e.g. a routing or\ndepartment code the retailer mandates).",
      "nullable": true
     },
     "width_dots": {
      "type": "integer",
      "format": "int32",
      "description": "Print width in dots (ZPL `^PW`). 812 = 4\" at 203 dpi.",
      "minimum": 0
     }
    }
   },
   "Lead": {
    "type": "object",
    "description": "A captured sales lead.",
    "required": [
     "id",
     "email",
     "created_at"
    ],
    "properties": {
     "company": {
      "type": "string"
     },
     "created_at": {
      "type": "string",
      "format": "date-time"
     },
     "email": {
      "type": "string"
     },
     "id": {
      "type": "string"
     },
     "note": {
      "type": "string"
     },
     "retailer": {
      "type": "string",
      "description": "The retailer guide they were checking against, when known."
     },
     "sample_excerpt": {
      "type": "string",
      "description": "A truncated excerpt of the file they checked, for sales context."
     },
     "source": {
      "type": "string",
      "description": "Where the lead came from: `checker`, `landing`, \u2026"
     }
    }
   },
   "LibrarySummary": {
    "type": "object",
    "description": "Roll-up of the shared library \u2014 the network-effect dashboard.",
    "required": [
     "templates",
     "certified",
     "total_reuse"
    ],
    "properties": {
     "certified": {
      "type": "integer",
      "minimum": 0
     },
     "templates": {
      "type": "integer",
      "minimum": 0
     },
     "total_reuse": {
      "type": "integer",
      "format": "int32",
      "description": "Total inheritances across all templates.",
      "minimum": 0
     }
    }
   },
   "ManifestIssue": {
    "type": "object",
    "description": "An issue found while validating a manifest.",
    "required": [
     "severity",
     "field",
     "message"
    ],
    "properties": {
     "field": {
      "type": "string"
     },
     "message": {
      "type": "string"
     },
     "severity": {
      "type": "string",
      "description": "`error` blocks certification; `warning` is advisory."
     }
    }
   },
   "MdnMode": {
    "type": "string",
    "description": "How a partner returns the MDN receipt for a message we send.",
    "enum": [
     "none",
     "sync",
     "async"
    ]
   },
   "MicAlgorithm": {
    "type": "string",
    "description": "A digest algorithm usable for the AS2 MIC. SHA-1 is intentionally excluded:\nit is cryptographically broken and modern partners negotiate SHA-2.",
    "enum": [
     "sha256",
     "sha384",
     "sha512"
    ]
   },
   "MintTenantKeyBody": {
    "type": "object",
    "required": [
     "name"
    ],
    "properties": {
     "name": {
      "type": "string",
      "description": "Operator label for the key, e.g. `production-orders`."
     }
    }
   },
   "MonitoringSnapshot": {
    "type": "object",
    "description": "A point-in-time monitoring snapshot.",
    "required": [
     "partner_sla",
     "deadletter_count",
     "failed_deliveries",
     "alerts",
     "healthy"
    ],
    "properties": {
     "alerts": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/ActiveAlert"
      }
     },
     "deadletter_count": {
      "type": "integer",
      "minimum": 0
     },
     "failed_deliveries": {
      "type": "integer",
      "minimum": 0
     },
     "healthy": {
      "type": "boolean",
      "description": "True when there are no active alerts."
     },
     "partner_sla": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/PartnerSla"
      }
     }
    }
   },
   "NewLead": {
    "type": "object",
    "description": "The public submission payload (server assigns `id`/`created_at`).",
    "required": [
     "email"
    ],
    "properties": {
     "company": {
      "type": "string"
     },
     "email": {
      "type": "string"
     },
     "note": {
      "type": "string"
     },
     "retailer": {
      "type": "string"
     },
     "sample": {
      "type": "string"
     },
     "source": {
      "type": "string"
     }
    }
   },
   "OnboardingEvent": {
    "type": "object",
    "description": "One transition in the audit trail.",
    "required": [
     "at",
     "actor",
     "to_stage"
    ],
    "properties": {
     "actor": {
      "type": "string",
      "description": "Principal that made the change (`admin`, `partner:{id}`, or a system tag)."
     },
     "at": {
      "type": "string",
      "format": "date-time"
     },
     "from_stage": {
      "allOf": [
       {
        "$ref": "#/components/schemas/OnboardingStage"
       }
      ],
      "nullable": true
     },
     "note": {
      "type": "string",
      "nullable": true
     },
     "to_stage": {
      "$ref": "#/components/schemas/OnboardingStage"
     }
    }
   },
   "OnboardingRecord": {
    "type": "object",
    "description": "The onboarding record for one partner.",
    "required": [
     "partner_id",
     "tenant_id",
     "stage",
     "history",
     "created_at",
     "updated_at"
    ],
    "properties": {
     "blocker": {
      "type": "string",
      "description": "When set, the partner is blocked at the current stage; advancing is\nrefused until cleared.",
      "nullable": true
     },
     "created_at": {
      "type": "string",
      "format": "date-time"
     },
     "history": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/OnboardingEvent"
      }
     },
     "partner_id": {
      "type": "string"
     },
     "stage": {
      "$ref": "#/components/schemas/OnboardingStage"
     },
     "tenant_id": {
      "type": "string"
     },
     "updated_at": {
      "type": "string",
      "format": "date-time"
     }
    }
   },
   "OnboardingStage": {
    "type": "string",
    "description": "Ordered onboarding stages. Advancing moves one step along this sequence;\nthe index is the source of truth for ordering.",
    "enum": [
     "connected",
     "profile_selected",
     "mapped",
     "testing",
     "certified",
     "live"
    ]
   },
   "OutboundAck": {
    "type": "object",
    "description": "The acknowledgment state of one outbound document.",
    "required": [
     "partner_id",
     "transaction_set",
     "control_number",
     "reference",
     "sent_at",
     "status"
    ],
    "properties": {
     "acknowledged_at": {
      "type": "string",
      "format": "date-time",
      "nullable": true
     },
     "control_number": {
      "type": "string"
     },
     "partner_id": {
      "type": "string"
     },
     "reference": {
      "type": "string"
     },
     "sent_at": {
      "type": "string",
      "format": "date-time"
     },
     "status": {
      "type": "string",
      "description": "`pending`, `accepted`, `accepted_with_errors`, `partially_accepted`,\nor `rejected`."
     },
     "transaction_set": {
      "type": "string"
     }
    }
   },
   "OverlaySegment": {
    "type": "object",
    "required": [
     "tag"
    ],
    "properties": {
     "elements": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "tag": {
      "type": "string"
     },
     "transaction_set": {
      "type": "string",
      "description": "Restrict to one transaction set (e.g. `856`); `None` applies to all.",
      "nullable": true
     }
    }
   },
   "PackLevel": {
    "type": "string",
    "description": "A level in the GS1 packaging hierarchy: pallet \u2192 carton \u2192 inner \u2192 each.",
    "enum": [
     "pallet",
     "carton",
     "inner",
     "each"
    ]
   },
   "PackingSlip": {
    "type": "object",
    "description": "A fully-resolved packing slip, ready to render to HTML or ZPL.",
    "required": [
     "shipment_id",
     "ship_date",
     "ship_from",
     "ship_to",
     "orders",
     "carton_count",
     "total_units",
     "profile"
    ],
    "properties": {
     "bol_number": {
      "type": "string",
      "nullable": true
     },
     "carrier_scac": {
      "type": "string",
      "nullable": true
     },
     "carton_count": {
      "type": "integer",
      "description": "Number of cartons across all orders (1 for an order-level ASN).",
      "minimum": 0
     },
     "orders": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/SlipOrder"
      }
     },
     "profile": {
      "$ref": "#/components/schemas/PackingSlipProfile"
     },
     "ship_date": {
      "type": "string"
     },
     "ship_from": {
      "$ref": "#/components/schemas/Address"
     },
     "ship_to": {
      "$ref": "#/components/schemas/Address"
     },
     "shipment_id": {
      "type": "string"
     },
     "total_units": {
      "type": "string",
      "description": "Total units across every line."
     },
     "tracking_number": {
      "type": "string",
      "nullable": true
     }
    }
   },
   "PackingSlipProfile": {
    "type": "object",
    "description": "Per-partner packing-slip presentation. Defaults are sensible for a generic\nslip; a partner overlay overrides the fields its companion guide mandates.",
    "required": [
     "seller_name"
    ],
    "properties": {
     "footer_note": {
      "type": "string",
      "description": "Optional footer note (return policy, compliance marks, partner-required\nstatements).",
      "nullable": true
     },
     "logo_text": {
      "type": "string",
      "description": "Optional logo / brand line printed above the seller name.",
      "nullable": true
     },
     "seller_name": {
      "type": "string",
      "description": "Seller / shipper name printed in the header (the \"from\" identity)."
     },
     "show_sscc": {
      "type": "boolean",
      "description": "When true, render each carton's SSCC alongside its contents \u2014 required\nby retailers that scan the slip against the carton label."
     }
    }
   },
   "PageInfo": {
    "type": "object",
    "description": "Pagination metadata carried alongside a paged list's `data`.",
    "required": [
     "total",
     "limit",
     "offset"
    ],
    "properties": {
     "limit": {
      "type": "integer",
      "description": "The applied page size (after clamping).",
      "minimum": 0
     },
     "offset": {
      "type": "integer",
      "description": "The applied offset.",
      "minimum": 0
     },
     "total": {
      "type": "integer",
      "description": "Total records available (before paging).",
      "minimum": 0
     }
    }
   },
   "PagedDocuments": {
    "type": "object",
    "description": "The `GET /v1/documents` response envelope. Typed (not `json!`) so the\nOpenAPI schema and the wire shape cannot drift apart.",
    "required": [
     "success",
     "data",
     "page"
    ],
    "properties": {
     "data": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/crate.state.DocumentRecord"
      },
      "description": "The requested page, newest first."
     },
     "page": {
      "$ref": "#/components/schemas/PageInfo"
     },
     "success": {
      "type": "boolean"
     }
    }
   },
   "PartnerOverlay": {
    "type": "object",
    "description": "A per-partner outbound overlay: the configurable slice of a companion guide.\nApplied to a built X12 transaction set before enveloping, so the same codec\nserves every partner and their idiosyncrasies live on the partner record.",
    "properties": {
     "element_overrides": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/ElementOverride"
      },
      "description": "Force an element's value on the first matching segment of an outbound\ntransaction (optionally scoped to a set) \u2014 e.g. a fixed qualifier."
     },
     "extra_segments": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/OverlaySegment"
      },
      "description": "Extra segments appended to outbound transactions (optionally scoped to a\ntransaction set) \u2014 e.g. a partner-required `REF`/`N9`/`DTM`."
     }
    }
   },
   "PartnerSla": {
    "type": "object",
    "description": "Per-partner acknowledgment SLA status.",
    "required": [
     "partner_id",
     "sla_hours",
     "outstanding",
     "overdue",
     "breached"
    ],
    "properties": {
     "breached": {
      "type": "boolean"
     },
     "outstanding": {
      "type": "integer",
      "description": "Documents still awaiting a 997.",
      "minimum": 0
     },
     "overdue": {
      "type": "integer",
      "description": "Outstanding documents past this partner's SLA.",
      "minimum": 0
     },
     "partner_id": {
      "type": "string"
     },
     "sla_hours": {
      "type": "integer",
      "format": "int32",
      "minimum": 0
     }
    }
   },
   "PartnerTemplate": {
    "type": "object",
    "description": "A reusable, inheritable partner configuration derived from a (certified)\ntrading partner \u2014 the retailer's guide + map without any relationship data.",
    "required": [
     "id",
     "name",
     "partner_isa_qualifier",
     "version",
     "validation",
     "certified",
     "reuse_count",
     "created_at",
     "updated_at"
    ],
    "properties": {
     "certification_pack": {
      "type": "string",
      "description": "The certification pack the source partner passed, when known.",
      "nullable": true
     },
     "certified": {
      "type": "boolean",
      "description": "Whether this template was published from a partner that passed\ncertification (vs. an ad-hoc publish)."
     },
     "created_at": {
      "type": "string",
      "format": "date-time"
     },
     "delimiters": {
      "$ref": "#/components/schemas/Delimiters"
     },
     "id": {
      "type": "string",
      "description": "Stable id, derived from the partner name + version so re-certifying the\nsame retailer updates rather than duplicates."
     },
     "label": {
      "allOf": [
       {
        "$ref": "#/components/schemas/LabelProfile"
       }
      ],
      "nullable": true
     },
     "name": {
      "type": "string"
     },
     "overlay": {
      "allOf": [
       {
        "$ref": "#/components/schemas/PartnerOverlay"
       }
      ],
      "nullable": true
     },
     "packing_slip": {
      "allOf": [
       {
        "$ref": "#/components/schemas/PackingSlipProfile"
       }
      ],
      "nullable": true
     },
     "partner_isa_qualifier": {
      "type": "string",
      "description": "The retailer's ISA interchange ID qualifier (theirs, not the tenant's)."
     },
     "reuse_count": {
      "type": "integer",
      "format": "int32",
      "description": "How many times another tenant has inherited this template \u2014 the flywheel\nmetric. A high reuse count means the Nth tenant onboards instantly.",
      "minimum": 0
     },
     "updated_at": {
      "type": "string",
      "format": "date-time"
     },
     "validation": {
      "$ref": "#/components/schemas/PartnerValidation"
     },
     "version": {
      "type": "string"
     }
    }
   },
   "PartnerValidation": {
    "type": "object",
    "description": "Per-partner inbound validation. Empty rules accept everything (the default),\nso existing partners are unaffected.",
    "properties": {
     "accepted_inbound": {
      "type": "array",
      "items": {
       "type": "string"
      },
      "description": "If non-empty, inbound transaction sets not in this list are rejected\n(e.g. `[\"850\", \"860\"]` for a partner that only sends orders)."
     },
     "conditional_rules": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/ConditionalRule"
      },
      "description": "If-then rules, e.g. \"when BEG02 is SA, a DTM segment is required\"."
     },
     "count_checks": {
      "type": "object",
      "description": "Count-balancing rules per inbound transaction set \u2014 `CTT01` must equal\nthe number of `PO1` segments and friends. Checked only when the counter\nsegment is present (pair with `required_segments` to mandate it).",
      "additionalProperties": {
       "type": "array",
       "items": {
        "$ref": "#/components/schemas/CountRule"
       }
      }
     },
     "element_constraints": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/ElementConstraint"
      },
      "description": "Element-level constraints applied to matching segments anywhere in an\ninbound document \u2014 e.g. pin PO1-03 (unit of measure) to an allowed set."
     },
     "required_qualified": {
      "type": "object",
      "description": "Qualified-segment requirements per inbound transaction set \u2014 the guide\nstaple `required_references` can't reach beyond REF: \"a DTM*002\n(delivery date) must be present\", \"an N1 loop with N101=ST\". The `\"*\"`\nkey applies to every set.",
      "additionalProperties": {
       "type": "array",
       "items": {
        "$ref": "#/components/schemas/QualifiedSegmentRule"
       }
      }
     },
     "required_references": {
      "type": "object",
      "description": "REF qualifiers that must be present per inbound transaction set, e.g.\n`{\"850\": [\"DP\"]}` to require a department-number reference on every PO.",
      "additionalProperties": {
       "type": "array",
       "items": {
        "type": "string"
       }
      }
     },
     "required_segments": {
      "type": "object",
      "description": "Segment tags that must be present per inbound transaction set, e.g.\n`{\"850\": [\"DTM\", \"REF\"]}` to require a date and reference on every PO.\nThe `\"*\"` key applies to every inbound set.",
      "additionalProperties": {
       "type": "array",
       "items": {
        "type": "string"
       }
      }
     },
     "segment_cardinality": {
      "type": "object",
      "description": "Occurrence bounds per inbound transaction set, e.g.\n`{\"850\": [{\"segment\": \"BEG\", \"min\": 1, \"max\": 1}]}` for \"exactly one\nBEG\" or a guide's \"max 200 PO1 lines\". The `\"*\"` key applies to every\nset; a set-specific rule for the same segment takes precedence.",
      "additionalProperties": {
       "type": "array",
       "items": {
        "$ref": "#/components/schemas/CardinalityRule"
       }
      }
     }
    }
   },
   "PartnerVolume": {
    "type": "object",
    "description": "Volume + quality for one partner.",
    "required": [
     "partner_id",
     "total",
     "inbound",
     "outbound",
     "accepted",
     "rejected"
    ],
    "properties": {
     "accepted": {
      "type": "integer",
      "minimum": 0
     },
     "error_rate": {
      "type": "integer",
      "format": "int32",
      "description": "Rejected \u00f7 (accepted + rejected), percent 0\u2013100. `None` if none decided.",
      "nullable": true,
      "minimum": 0
     },
     "inbound": {
      "type": "integer",
      "minimum": 0
     },
     "outbound": {
      "type": "integer",
      "minimum": 0
     },
     "partner_id": {
      "type": "string"
     },
     "rejected": {
      "type": "integer",
      "minimum": 0
     },
     "total": {
      "type": "integer",
      "minimum": 0
     }
    }
   },
   "Party": {
    "type": "object",
    "description": "An N1 party loop (N1/N2/N3/N4).",
    "required": [
     "role",
     "name"
    ],
    "properties": {
     "address_lines": {
      "type": "array",
      "items": {
       "type": "string"
      }
     },
     "city": {
      "type": "string",
      "nullable": true
     },
     "country": {
      "type": "string",
      "nullable": true
     },
     "id": {
      "type": "string",
      "nullable": true
     },
     "id_qualifier": {
      "type": "string",
      "description": "N103/N104 \u2014 identification qualifier and code (e.g. `92` + store #).",
      "nullable": true
     },
     "name": {
      "type": "string"
     },
     "postal_code": {
      "type": "string",
      "nullable": true
     },
     "role": {
      "type": "string",
      "description": "N101 entity identifier code: ST ship-to, BT bill-to, SF ship-from,\nVN vendor, BY buyer, ..."
     },
     "state": {
      "type": "string",
      "nullable": true
     }
    }
   },
   "PoAck855": {
    "type": "object",
    "description": "Parsed inbound 855. Fields are tolerant (optional) since a supplier may\nsend only header-level acknowledgment.",
    "required": [
     "po_number",
     "ack_type",
     "lines"
    ],
    "properties": {
     "ack_date": {
      "type": "string",
      "format": "date",
      "description": "BAK09 (or BAK04) acknowledgment date.",
      "nullable": true
     },
     "ack_type": {
      "type": "string",
      "description": "BAK02 \u2014 acknowledgment type: AC accept, AD accept w/ detail,\nAK acknowledge, RJ reject."
     },
     "lines": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/AckLineParsed"
      }
     },
     "po_number": {
      "type": "string",
      "description": "BAK03 \u2014 the PO being acknowledged (ours)."
     }
    }
   },
   "PoChange860": {
    "type": "object",
    "required": [
     "po_number",
     "purpose",
     "po_type",
     "lines"
    ],
    "properties": {
     "change_date": {
      "type": "string",
      "format": "date",
      "description": "BCH11 \u2014 date of this change.",
      "nullable": true
     },
     "dates": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/Reference"
      }
     },
     "lines": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/ChangeLine"
      }
     },
     "parties": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/Party"
      }
     },
     "po_date": {
      "type": "string",
      "format": "date",
      "description": "BCH06 \u2014 original PO date.",
      "nullable": true
     },
     "po_number": {
      "type": "string",
      "description": "BCH03."
     },
     "po_type": {
      "type": "string",
      "description": "BCH02 \u2014 PO type."
     },
     "purpose": {
      "type": "string",
      "description": "BCH01 \u2014 transaction set purpose (01 cancellation, 04 change, 05\nreplace)."
     },
     "references": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/Reference"
      }
     }
    }
   },
   "PoChangeAck865": {
    "type": "object",
    "description": "Parsed inbound 865. Tolerant like the inbound 855: header-only\nacknowledgments are valid.",
    "required": [
     "po_number",
     "ack_type",
     "lines"
    ],
    "properties": {
     "ack_date": {
      "type": "string",
      "format": "date",
      "description": "BCA09 (or BCA06) acknowledgment date.",
      "nullable": true
     },
     "ack_type": {
      "type": "string",
      "description": "BCA02 \u2014 acknowledgment type."
     },
     "lines": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/ChangeAckLineParsed"
      }
     },
     "po_number": {
      "type": "string",
      "description": "BCA03 \u2014 the changed PO."
     }
    }
   },
   "PoLine": {
    "type": "object",
    "required": [
     "line_number",
     "quantity",
     "uom"
    ],
    "properties": {
     "description": {
      "type": "string",
      "description": "PID05 of the F-format item description, when present.",
      "nullable": true
     },
     "ids": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/ProductId"
      },
      "description": "PO106+ qualifier/value pairs."
     },
     "line_number": {
      "type": "string",
      "description": "PO101 \u2014 buyer's line number."
     },
     "quantity": {
      "type": "string",
      "description": "PO102 / PO103."
     },
     "unit_price": {
      "type": "string",
      "description": "PO104 (PO105 is the basis, almost always PE = per each).",
      "nullable": true
     },
     "uom": {
      "type": "string"
     }
    }
   },
   "PostalDeclaration": {
    "type": "object",
    "description": "A CN22 or CN23 postal customs declaration derived from a commercial invoice.",
    "required": [
     "form",
     "category",
     "items",
     "total_value",
     "currency",
     "complete"
    ],
    "properties": {
     "category": {
      "$ref": "#/components/schemas/CustomsCategory"
     },
     "complete": {
      "type": "boolean",
      "description": "True when every item carries an HS code, origin, and weight \u2014 what a\ncompliant CN23 needs."
     },
     "currency": {
      "type": "string"
     },
     "destination_country": {
      "type": "string",
      "nullable": true
     },
     "form": {
      "$ref": "#/components/schemas/PostalForm"
     },
     "items": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/PostalItem"
      }
     },
     "origin_country": {
      "type": "string",
      "nullable": true
     },
     "total_value": {
      "type": "string"
     },
     "total_weight_kg": {
      "type": "string",
      "nullable": true
     }
    }
   },
   "PostalForm": {
    "type": "string",
    "description": "The postal customs declaration form. CN22 is the short form for low-value /\nlight parcels; CN23 is the detailed form above the threshold.",
    "enum": [
     "CN22",
     "CN23"
    ]
   },
   "PostalItem": {
    "type": "object",
    "description": "One item line on a postal declaration.",
    "required": [
     "description",
     "quantity",
     "value"
    ],
    "properties": {
     "description": {
      "type": "string"
     },
     "hs_code": {
      "type": "string",
      "nullable": true
     },
     "net_weight_kg": {
      "type": "string",
      "nullable": true
     },
     "origin": {
      "type": "string",
      "nullable": true
     },
     "quantity": {
      "type": "string"
     },
     "value": {
      "type": "string"
     }
    }
   },
   "ProductId": {
    "type": "object",
    "description": "One qualifier/value product identifier pair from a PO1/IT1/LIN segment\n(SK seller SKU, VN vendor part, UP UPC, BP buyer part, IN buyer item, ...).",
    "required": [
     "qualifier",
     "value"
    ],
    "properties": {
     "qualifier": {
      "type": "string"
     },
     "value": {
      "type": "string"
     }
    }
   },
   "ProfileCheckDocument": {
    "type": "object",
    "description": "One transaction set's conformance verdict within a checked interchange.",
    "required": [
     "transaction_set",
     "control_number",
     "accepted"
    ],
    "properties": {
     "accepted": {
      "type": "boolean"
     },
     "control_number": {
      "type": "string"
     },
     "issues": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/ValidationIssue"
      },
      "description": "Every guide violation, with 999-grade segment/element positions."
     },
     "transaction_set": {
      "type": "string"
     }
    }
   },
   "ProfileCheckReport": {
    "type": "object",
    "description": "The result of checking one uploaded interchange against a retailer profile.",
    "required": [
     "retailer",
     "profile_key",
     "guide",
     "status",
     "valid",
     "documents"
    ],
    "properties": {
     "documents": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/ProfileCheckDocument"
      }
     },
     "guide": {
      "type": "string"
     },
     "profile_key": {
      "type": "string"
     },
     "retailer": {
      "type": "string"
     },
     "status": {
      "$ref": "#/components/schemas/ProfileStatus"
     },
     "structural_error": {
      "type": "string",
      "description": "Set when the interchange could not be parsed at all.",
      "nullable": true
     },
     "valid": {
      "type": "boolean",
      "description": "True only when the interchange parsed and every document passed the guide."
     }
    }
   },
   "ProfileStatus": {
    "type": "string",
    "description": "Whether a profile carries real element-level rules from a public guide, or is\na set-list-only stub awaiting the retailer's gated companion guide.",
    "enum": [
     "certified",
     "placeholder"
    ]
   },
   "PurchaseOrder850": {
    "type": "object",
    "required": [
     "po_number",
     "purpose",
     "po_type",
     "lines"
    ],
    "properties": {
     "currency": {
      "type": "string",
      "description": "CUR02.",
      "nullable": true
     },
     "dates": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/Reference"
      },
      "description": "DTM segments keyed by qualifier (002 delivery requested, 010 requested\nship, ...). Stored as (qualifier, CCYYMMDD date)."
     },
     "lines": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/PoLine"
      }
     },
     "parties": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/Party"
      }
     },
     "po_date": {
      "type": "string",
      "format": "date",
      "description": "BEG05.",
      "nullable": true
     },
     "po_number": {
      "type": "string",
      "description": "BEG03."
     },
     "po_type": {
      "type": "string",
      "description": "BEG02 \u2014 PO type (SA stand-alone, NE new order, RL release, ...)."
     },
     "purpose": {
      "type": "string",
      "description": "BEG01 \u2014 transaction set purpose (00 original, 01 cancellation, ...)."
     },
     "references": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/Reference"
      }
     }
    }
   },
   "QualifiedSegmentRule": {
    "type": "object",
    "description": "Requires at least one occurrence of a segment whose qualifier element\ncarries a specific value \u2014 e.g. segment `DTM`, element 1, value `002`.",
    "required": [
     "segment",
     "element",
     "value"
    ],
    "properties": {
     "element": {
      "type": "integer",
      "description": "1-based qualifier element position (usually 1).",
      "minimum": 0
     },
     "segment": {
      "type": "string",
      "description": "Segment tag, e.g. `DTM` or `N1`."
     },
     "value": {
      "type": "string",
      "description": "Required qualifier value, e.g. `002` or `ST`."
     }
    }
   },
   "RedeliverBulkBody": {
    "type": "object",
    "properties": {
     "partner_id": {
      "type": "string",
      "nullable": true
     }
    }
   },
   "Reference": {
    "type": "object",
    "description": "A REF segment.",
    "required": [
     "qualifier",
     "value"
    ],
    "properties": {
     "qualifier": {
      "type": "string"
     },
     "value": {
      "type": "string"
     }
    }
   },
   "Remittance820": {
    "type": "object",
    "required": [
     "total_amount",
     "items"
    ],
    "properties": {
     "credit_debit": {
      "type": "string",
      "description": "BPR03 \u2014 credit/debit flag (`C` credit, `D` debit).",
      "nullable": true
     },
     "items": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/RemittanceItem"
      }
     },
     "parties": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/Party"
      }
     },
     "payment_date": {
      "type": "string",
      "format": "date",
      "description": "BPR16 \u2014 payment effective date.",
      "nullable": true
     },
     "payment_method": {
      "type": "string",
      "description": "BPR04 \u2014 payment method (ACH, CHK, FWT, ...).",
      "nullable": true
     },
     "total_amount": {
      "type": "string",
      "description": "BPR02 \u2014 total payment amount (explicit decimal)."
     },
     "trace_number": {
      "type": "string",
      "description": "TRN02 \u2014 check / EFT trace number.",
      "nullable": true
     }
    }
   },
   "RemittanceItem": {
    "type": "object",
    "required": [
     "invoice_number"
    ],
    "properties": {
     "amount_paid": {
      "type": "string",
      "description": "RMR04 \u2014 amount actually paid for this item.",
      "nullable": true
     },
     "gross_amount": {
      "type": "string",
      "description": "RMR05 \u2014 gross (original) amount of the item.",
      "nullable": true
     },
     "invoice_number": {
      "type": "string",
      "description": "RMR02 \u2014 the invoice (or other) number being settled."
     },
     "reference_qualifier": {
      "type": "string",
      "description": "RMR01 \u2014 reference qualifier (IV invoice, PO purchase order, ...).",
      "nullable": true
     }
    }
   },
   "ReprocessBulkBody": {
    "type": "object",
    "properties": {
     "partner_id": {
      "type": "string",
      "nullable": true
     },
     "status": {
      "type": "string",
      "description": "Only documents in this status (e.g. `rejected`). Omit for all inbound.",
      "nullable": true
     },
     "transaction_set": {
      "type": "string",
      "nullable": true
     }
    }
   },
   "RetailerProfile": {
    "type": "object",
    "description": "A built-in retailer companion-guide profile.",
    "required": [
     "key",
     "name",
     "guide",
     "source",
     "status",
     "validation",
     "notes"
    ],
    "properties": {
     "guide": {
      "type": "string",
      "description": "The guide edition this profile transcribes."
     },
     "key": {
      "type": "string",
      "description": "Stable lookup key, e.g. `walmart`."
     },
     "name": {
      "type": "string",
      "description": "Display name."
     },
     "notes": {
      "type": "array",
      "items": {
       "type": "string"
      },
      "description": "Operator-facing notes (caveats, pending work, direction)."
     },
     "source": {
      "type": "string",
      "description": "Where the rules came from (guide title or public source)."
     },
     "status": {
      "$ref": "#/components/schemas/ProfileStatus"
     },
     "validation": {
      "$ref": "#/components/schemas/PartnerValidation"
     }
    }
   },
   "RotateAs2IdentityBody": {
    "type": "object",
    "description": "Request body for rotating the AS2 S/MIME identity at runtime.",
    "required": [
     "key_pem",
     "cert_pem"
    ],
    "properties": {
     "cert_pem": {
      "type": "string",
      "description": "X.509 certificate PEM."
     },
     "key_pem": {
      "type": "string",
      "description": "PKCS#8 private key PEM."
     }
    }
   },
   "SetVolume": {
    "type": "object",
    "description": "Count for one transaction set.",
    "required": [
     "transaction_set",
     "count"
    ],
    "properties": {
     "count": {
      "type": "integer",
      "minimum": 0
     },
     "transaction_set": {
      "type": "string"
     }
    }
   },
   "Ship940": {
    "type": "object",
    "required": [
     "order_number",
     "items"
    ],
    "properties": {
     "carrier_scac": {
      "type": "string",
      "description": "W6603 \u2014 carrier SCAC for routing.",
      "nullable": true
     },
     "items": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/ShipItem"
      }
     },
     "order_number": {
      "type": "string",
      "description": "W0502 \u2014 depositor (our) order number."
     },
     "po_number": {
      "type": "string",
      "description": "W0503 \u2014 the customer PO this order fulfills, when there is one.",
      "nullable": true
     },
     "requested_ship_date": {
      "type": "string",
      "format": "date",
      "description": "G62*10 \u2014 requested ship date.",
      "nullable": true
     },
     "ship_to": {
      "allOf": [
       {
        "$ref": "#/components/schemas/Party"
       }
      ],
      "nullable": true
     }
    }
   },
   "ShipItem": {
    "type": "object",
    "required": [
     "quantity",
     "sku"
    ],
    "properties": {
     "description": {
      "type": "string",
      "description": "G69 free-form description line.",
      "nullable": true
     },
     "quantity": {
      "type": "string"
     },
     "sku": {
      "type": "string"
     },
     "sku_qualifier": {
      "type": "string",
      "description": "W0104 qualifier for the identifier, e.g. SK / VN / UP."
     },
     "uom": {
      "type": "string"
     }
    }
   },
   "SlipCarton": {
    "type": "object",
    "description": "A carton (pack) and its contents, when the ASN is carton-level.",
    "required": [
     "lines"
    ],
    "properties": {
     "lines": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/SlipLine"
      }
     },
     "sscc": {
      "type": "string",
      "description": "SSCC-18 marked on the carton's GS1-128 label.",
      "nullable": true
     }
    }
   },
   "SlipLine": {
    "type": "object",
    "description": "A single packed line on the slip.",
    "required": [
     "sku",
     "sku_qualifier",
     "quantity",
     "uom"
    ],
    "properties": {
     "quantity": {
      "type": "string"
     },
     "sku": {
      "type": "string"
     },
     "sku_qualifier": {
      "type": "string"
     },
     "uom": {
      "type": "string"
     }
    }
   },
   "SlipOrder": {
    "type": "object",
    "description": "The packed contents under one purchase order.",
    "required": [
     "po_number",
     "cartons"
    ],
    "properties": {
     "cartons": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/SlipCarton"
      },
      "description": "Cartons when the ASN is carton-level; otherwise a single synthetic\ncarton with `sscc: None` holding the order-level items."
     },
     "po_number": {
      "type": "string"
     }
    }
   },
   "StatusBoardEntry": {
    "type": "object",
    "description": "One partner's operational health summary.",
    "required": [
     "partner_id",
     "partner_name",
     "documents_total",
     "inbound",
     "outbound",
     "accepted",
     "rejected",
     "sent",
     "overdue_acks",
     "open_exceptions",
     "health"
    ],
    "properties": {
     "accepted": {
      "type": "integer",
      "minimum": 0
     },
     "compliance_rate": {
      "type": "integer",
      "format": "int32",
      "description": "Accepted \u00f7 (accepted + rejected), as a percentage 0\u2013100. `None` when no\ndocument has a definitive accept/reject verdict yet.",
      "nullable": true,
      "minimum": 0
     },
     "documents_total": {
      "type": "integer",
      "minimum": 0
     },
     "health": {
      "type": "string",
      "description": "Overall health: `healthy`, `attention`, `idle`."
     },
     "inbound": {
      "type": "integer",
      "minimum": 0
     },
     "last_activity": {
      "type": "string",
      "format": "date-time",
      "description": "Most recent document activity, if any.",
      "nullable": true
     },
     "open_exceptions": {
      "type": "integer",
      "description": "Open exceptions needing operator attention (rejections + overdue acks).",
      "minimum": 0
     },
     "outbound": {
      "type": "integer",
      "minimum": 0
     },
     "overdue_acks": {
      "type": "integer",
      "description": "Outbound documents still awaiting a partner 997 past the ack SLA.",
      "minimum": 0
     },
     "partner_id": {
      "type": "string"
     },
     "partner_name": {
      "type": "string"
     },
     "rejected": {
      "type": "integer",
      "minimum": 0
     },
     "sent": {
      "type": "integer",
      "minimum": 0
     }
    }
   },
   "Subscriber": {
    "type": "object",
    "required": [
     "first_name",
     "last_name",
     "member_id"
    ],
    "properties": {
     "date_of_birth": {
      "type": "string",
      "format": "date",
      "description": "DMG02 \u2014 date of birth.",
      "nullable": true
     },
     "first_name": {
      "type": "string"
     },
     "gender": {
      "type": "string",
      "description": "DMG03 \u2014 `M` / `F` / `U`.",
      "nullable": true
     },
     "last_name": {
      "type": "string"
     },
     "member_id": {
      "type": "string",
      "description": "NM109 \u2014 member identification number (qualifier MI)."
     }
    }
   },
   "Tenant": {
    "type": "object",
    "description": "A tenant \u2014 an isolated namespace for partners and the documents they\nexchange. Provisioned by the dashboard gateway (one per WorkOS organization)\nor via the admin API.",
    "required": [
     "id",
     "display_name"
    ],
    "properties": {
     "created_at": {
      "type": "string",
      "format": "date-time",
      "nullable": true
     },
     "display_name": {
      "type": "string"
     },
     "enabled": {
      "type": "boolean"
     },
     "id": {
      "type": "string",
      "description": "Stable tenant identifier (slug), e.g. `acme-com`."
     }
    }
   },
   "TenantApiKeyView": {
    "type": "object",
    "description": "The client-safe projection of a [`TenantApiKey`] \u2014 everything but the hash.",
    "required": [
     "id",
     "tenant_id",
     "name",
     "key_prefix",
     "created_by",
     "created_at"
    ],
    "properties": {
     "created_at": {
      "type": "string",
      "format": "date-time"
     },
     "created_by": {
      "type": "string"
     },
     "id": {
      "type": "string"
     },
     "key_prefix": {
      "type": "string"
     },
     "name": {
      "type": "string"
     },
     "tenant_id": {
      "type": "string"
     }
    }
   },
   "Tender204": {
    "type": "object",
    "required": [
     "shipment_id",
     "carrier_scac",
     "orders"
    ],
    "properties": {
     "bol_number": {
      "type": "string",
      "description": "L11*BM \u2014 bill of lading number.",
      "nullable": true
     },
     "carrier_scac": {
      "type": "string",
      "description": "B202 \u2014 Standard Carrier Alpha Code of the tendered carrier."
     },
     "orders": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/TenderOrder"
      }
     },
     "payment_method": {
      "type": "string",
      "description": "B206 \u2014 method of payment: `PP` prepaid (default), `CC` collect.",
      "nullable": true
     },
     "pickup_date": {
      "type": "string",
      "format": "date",
      "description": "G62*69 \u2014 requested pickup date.",
      "nullable": true
     },
     "ship_from": {
      "allOf": [
       {
        "$ref": "#/components/schemas/Party"
       }
      ],
      "nullable": true
     },
     "ship_to": {
      "allOf": [
       {
        "$ref": "#/components/schemas/Party"
       }
      ],
      "nullable": true
     },
     "shipment_id": {
      "type": "string",
      "description": "B204 \u2014 shipment identification (the carrier echoes it in the 990/214)."
     },
     "weight": {
      "type": "string",
      "description": "AT803 \u2014 total shipment weight.",
      "nullable": true
     },
     "weight_uom": {
      "type": "string",
      "description": "AT802 \u2014 weight unit (default `L` pounds).",
      "nullable": true
     }
    }
   },
   "TenderOrder": {
    "type": "object",
    "required": [
     "po_number",
     "quantity"
    ],
    "properties": {
     "po_number": {
      "type": "string",
      "description": "OID02 \u2014 the purchase order this freight covers."
     },
     "quantity": {
      "type": "string",
      "description": "OID04 \u2014 number of units."
     },
     "weight": {
      "type": "string",
      "description": "OID05/OID06 \u2014 weight, when given per order.",
      "nullable": true
     }
    }
   },
   "TestCase": {
    "type": "object",
    "description": "One certification case: a sample interchange and the outcome the partner's\nimplementation guide requires for it.",
    "required": [
     "name",
     "raw",
     "expect_valid"
    ],
    "properties": {
     "description": {
      "type": "string",
      "nullable": true
     },
     "expect_valid": {
      "type": "boolean",
      "description": "Whether the guide expects this interchange to validate clean. A negative\ncase (`false`) certifies that the partner's rules *reject* a malformed or\nnon-compliant document \u2014 not just that good documents pass."
     },
     "name": {
      "type": "string"
     },
     "raw": {
      "type": "string",
      "description": "Raw X12/EDIFACT interchange to validate."
     }
    }
   },
   "TestPack": {
    "type": "object",
    "description": "A named collection of certification cases for a partner.",
    "required": [
     "name",
     "cases"
    ],
    "properties": {
     "cases": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/TestCase"
      }
     },
     "name": {
      "type": "string"
     }
    }
   },
   "TextItem": {
    "type": "object",
    "properties": {
     "body": {
      "type": "array",
      "items": {
       "type": "string"
      },
      "description": "MSG01 free-form text lines, in order."
     },
     "reference": {
      "type": "string",
      "description": "MIT01 \u2014 message reference identification.",
      "nullable": true
     },
     "subject": {
      "type": "string",
      "description": "MIT02 \u2014 subject of this message.",
      "nullable": true
     }
    }
   },
   "TextMessage864": {
    "type": "object",
    "required": [
     "messages"
    ],
    "properties": {
     "description": {
      "type": "string",
      "description": "BMG02 \u2014 overall description / subject of the message.",
      "nullable": true
     },
     "messages": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/TextItem"
      }
     },
     "purpose": {
      "type": "string",
      "description": "BMG01 \u2014 transaction set purpose code.",
      "nullable": true
     },
     "type_code": {
      "type": "string",
      "description": "BMG03 \u2014 transaction type code.",
      "nullable": true
     }
    }
   },
   "TradingPartner": {
    "type": "object",
    "required": [
     "id",
     "name",
     "partner_isa_qualifier",
     "partner_isa_id",
     "our_isa_qualifier",
     "our_isa_id"
    ],
    "properties": {
     "ack_sla_hours": {
      "type": "integer",
      "format": "int32",
      "description": "Per-partner acknowledgment SLA in hours. Strict retailers chargeback on\nlate 997s, so this overrides the global `EDI_ACK_SLA_HOURS` for monitoring\nand alerting. `None` falls back to the global SLA.",
      "nullable": true,
      "minimum": 0
     },
     "ack_type": {
      "type": "string",
      "description": "Which functional acknowledgment this partner receives: `997` (default)\nor `999` (Implementation Acknowledgment with IK3/IK4 error detail)."
     },
     "api_key_hash": {
      "type": "string",
      "description": "SHA-256 hex of this partner's API key, set via\n`POST /v1/partners/:id/api-key`. The plaintext key is never stored.",
      "nullable": true
     },
     "as1": {
      "allOf": [
       {
        "$ref": "#/components/schemas/As1Config"
       }
      ],
      "nullable": true
     },
     "as2": {
      "allOf": [
       {
        "$ref": "#/components/schemas/As2Config"
       }
      ],
      "nullable": true
     },
     "delimiters": {
      "$ref": "#/components/schemas/Delimiters"
     },
     "id": {
      "type": "string",
      "description": "Stable internal identifier, used in URLs and event payloads."
     },
     "label": {
      "allOf": [
       {
        "$ref": "#/components/schemas/LabelProfile"
       }
      ],
      "nullable": true
     },
     "name": {
      "type": "string"
     },
     "our_gs_id": {
      "type": "string",
      "nullable": true
     },
     "our_isa_id": {
      "type": "string"
     },
     "our_isa_qualifier": {
      "type": "string",
      "description": "Our ISA qualifier/ID for this relationship."
     },
     "overlay": {
      "allOf": [
       {
        "$ref": "#/components/schemas/PartnerOverlay"
       }
      ],
      "nullable": true
     },
     "packing_slip": {
      "allOf": [
       {
        "$ref": "#/components/schemas/PackingSlipProfile"
       }
      ],
      "nullable": true
     },
     "partner_gs_id": {
      "type": "string",
      "description": "GS application codes; default to the ISA IDs when omitted.",
      "nullable": true
     },
     "partner_isa_id": {
      "type": "string"
     },
     "partner_isa_qualifier": {
      "type": "string",
      "description": "The partner's ISA qualifier/ID (they are the receiver on our outbound)."
     },
     "tenant_id": {
      "type": "string",
      "description": "Owning tenant. Every partner belongs to exactly one tenant; an API key\nissued for the partner therefore implies its tenant. Defaults to\n`default` so single-tenant deployments and pre-tenancy records work\nunchanged."
     },
     "usage": {
      "type": "string",
      "description": "ISA15 usage indicator: `P` production, `T` test."
     },
     "validation": {
      "$ref": "#/components/schemas/PartnerValidation"
     },
     "van": {
      "allOf": [
       {
        "$ref": "#/components/schemas/VanConfig"
       }
      ],
      "nullable": true
     },
     "version": {
      "type": "string",
      "description": "GS08 version, e.g. `004010`."
     }
    }
   },
   "Transfer943": {
    "type": "object",
    "required": [
     "shipment_id",
     "transfer_number",
     "ship_date",
     "items"
    ],
    "properties": {
     "carrier_scac": {
      "type": "string",
      "description": "W2702 \u2014 carrier SCAC.",
      "nullable": true
     },
     "items": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/TransferItem"
      }
     },
     "ship_date": {
      "type": "string",
      "format": "date",
      "description": "W0603 / G62*11 \u2014 ship date."
     },
     "ship_from": {
      "allOf": [
       {
        "$ref": "#/components/schemas/Party"
       }
      ],
      "nullable": true
     },
     "ship_to": {
      "allOf": [
       {
        "$ref": "#/components/schemas/Party"
       }
      ],
      "nullable": true
     },
     "shipment_id": {
      "type": "string",
      "description": "W0604 \u2014 the shipment identification for this transfer."
     },
     "transfer_number": {
      "type": "string",
      "description": "W0602 \u2014 depositor (our) order/transfer number."
     }
    }
   },
   "TransferItem": {
    "type": "object",
    "required": [
     "quantity",
     "sku"
    ],
    "properties": {
     "quantity": {
      "type": "string"
     },
     "sku": {
      "type": "string"
     },
     "sku_qualifier": {
      "type": "string",
      "description": "W0404 identifier qualifier (SK / VN / UP)."
     },
     "uom": {
      "type": "string"
     }
    }
   },
   "TxAck": {
    "type": "object",
    "required": [
     "tx_id",
     "control_number",
     "status"
    ],
    "properties": {
     "control_number": {
      "type": "string"
     },
     "status": {
      "type": "string",
      "description": "AK501."
     },
     "tx_id": {
      "type": "string",
      "description": "AK201 / AK202."
     }
    }
   },
   "UblInvoiceInput": {
    "type": "object",
    "description": "The canonical input for a Peppol-BIS invoice.",
    "required": [
     "invoice_number",
     "issue_date",
     "supplier",
     "customer",
     "lines"
    ],
    "properties": {
     "buyer_reference": {
      "type": "string",
      "nullable": true
     },
     "currency": {
      "type": "string",
      "description": "ISO 4217 currency, e.g. `EUR`."
     },
     "customer": {
      "$ref": "#/components/schemas/EInvoiceParty"
     },
     "due_date": {
      "type": "string",
      "nullable": true
     },
     "invoice_number": {
      "type": "string"
     },
     "issue_date": {
      "type": "string",
      "description": "ISO date `YYYY-MM-DD`."
     },
     "lines": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/UblLine"
      }
     },
     "supplier": {
      "$ref": "#/components/schemas/EInvoiceParty"
     },
     "tax_percent": {
      "type": "string",
      "description": "Single VAT rate (percent) applied to the whole invoice \u2014 the common case;\nmulti-rate breakdown is a later refinement."
     }
    }
   },
   "UblLine": {
    "type": "object",
    "description": "One invoice line.",
    "required": [
     "description",
     "quantity",
     "unit_price"
    ],
    "properties": {
     "description": {
      "type": "string"
     },
     "quantity": {
      "type": "string"
     },
     "unit_price": {
      "type": "string"
     },
     "uom": {
      "type": "string"
     }
    }
   },
   "UblTotals": {
    "type": "object",
    "description": "Computed monetary totals for the invoice.",
    "required": [
     "line_extension",
     "tax_exclusive",
     "tax_amount",
     "tax_inclusive",
     "payable"
    ],
    "properties": {
     "line_extension": {
      "type": "string"
     },
     "payable": {
      "type": "string"
     },
     "tax_amount": {
      "type": "string"
     },
     "tax_exclusive": {
      "type": "string"
     },
     "tax_inclusive": {
      "type": "string"
     }
    }
   },
   "UsageRecord": {
    "type": "object",
    "description": "One billable action.",
    "required": [
     "id",
     "tenant_id",
     "kind",
     "quantity",
     "occurred_at"
    ],
    "properties": {
     "id": {
      "type": "string"
     },
     "kind": {
      "type": "string",
      "description": "`document_inbound`, `document_outbound`, or `delivery_attempt`."
     },
     "occurred_at": {
      "type": "string",
      "format": "date-time"
     },
     "partner_id": {
      "type": "string"
     },
     "quantity": {
      "type": "integer",
      "format": "int64"
     },
     "tenant_id": {
      "type": "string"
     },
     "transaction_set": {
      "type": "string"
     }
    }
   },
   "UsageSummary": {
    "type": "object",
    "description": "Aggregated consumption for a tenant over a period.",
    "required": [
     "tenant_id",
     "total",
     "by_kind",
     "by_transaction_set",
     "by_partner"
    ],
    "properties": {
     "by_kind": {
      "type": "object",
      "description": "Totals per action kind.",
      "additionalProperties": {
       "type": "integer",
       "format": "int64"
      }
     },
     "by_partner": {
      "type": "object",
      "description": "Totals per partner.",
      "additionalProperties": {
       "type": "integer",
       "format": "int64"
      }
     },
     "by_transaction_set": {
      "type": "object",
      "description": "Totals per transaction set (documents only).",
      "additionalProperties": {
       "type": "integer",
       "format": "int64"
      }
     },
     "tenant_id": {
      "type": "string"
     },
     "total": {
      "type": "integer",
      "format": "int64"
     }
    }
   },
   "ValidationIssue": {
    "type": "object",
    "description": "One implementation-guide violation, carrying everything a 999 IK3/IK4 (or\nan operator fixing the file) needs to pinpoint it: which segment, where in\nthe transaction, which element, and the offending value.",
    "required": [
     "code",
     "message"
    ],
    "properties": {
     "code": {
      "type": "string",
      "description": "Stable machine code: `set_not_accepted`, `missing_segment`,\n`missing_reference`, `missing_element`, `value_not_allowed`,\n`too_short`, `too_long`, `too_few`, `too_many`,\n`missing_qualified_segment`, `count_mismatch`, `bad_format`, or\n`condition_failed`."
     },
     "element": {
      "type": "integer",
      "description": "1-based element position (999 IK4-01 numbering).",
      "nullable": true,
      "minimum": 0
     },
     "message": {
      "type": "string"
     },
     "segment": {
      "type": "string",
      "description": "Segment tag the issue is about (empty for set-level issues)."
     },
     "segment_position": {
      "type": "integer",
      "description": "1-based segment position within the transaction set counting ST as 1\n(999 IK3-02 numbering). Absent when the segment is missing entirely.",
      "nullable": true,
      "minimum": 0
     },
     "value": {
      "type": "string",
      "description": "The offending value, when one is present.",
      "nullable": true
     }
    }
   },
   "ValidationReport": {
    "type": "object",
    "description": "Validation report for a dry run \u2014 what inbound processing *would* accept or\nreject, with no side effects.",
    "required": [
     "partner_id",
     "interchange_control_number",
     "valid",
     "documents"
    ],
    "properties": {
     "documents": {
      "type": "array",
      "items": {
       "$ref": "#/components/schemas/DocumentValidation"
      }
     },
     "interchange_control_number": {
      "type": "string"
     },
     "partner_id": {
      "type": "string"
     },
     "structural_error": {
      "type": "string",
      "description": "Set when the envelope itself is invalid (no per-document results then).",
      "nullable": true
     },
     "valid": {
      "type": "boolean",
      "description": "True when the interchange parses and every transaction is accepted."
     }
    }
   },
   "VanConfig": {
    "type": "object",
    "required": [
     "mailbox"
    ],
    "properties": {
     "mailbox": {
      "type": "string",
      "description": "Mailbox slug under the provider."
     },
     "provider": {
      "type": "string",
      "description": "`stateset-network` for our native managed network, or an interconnect\nkey such as `sps-commerce` when a bridge is configured."
     }
    }
   }
  },
  "securitySchemes": {
   "bearer": {
    "type": "http",
    "scheme": "bearer",
    "description": "Admin token (EDI_API_TOKEN) or a partner API key"
   }
  }
 },
 "security": [
  {
   "bearer": []
  }
 ],
 "tags": [
  {
   "name": "system",
   "description": "Health and metrics"
  },
  {
   "name": "partners",
   "description": "Trading partner registry and credentials"
  },
  {
   "name": "inbound",
   "description": "Inbound EDI processing"
  },
  {
   "name": "outbound",
   "description": "Outbound EDI generation"
  },
  {
   "name": "operations",
   "description": "Outbox, audit log, debugging"
  }
 ],
 "servers": [
  {
   "url": "https://edi.stateset.com"
  }
 ]
}