{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/medianfi-com/json-schema/medianfi-com-business-event-wire-schema.json",
  "title": "BusinessEventWire",
  "description": "A business event with its generated preview lines and any posted journal entries. jeGenerationSkipped/jeGenerationError explain a null journalEntryId — skipped means a known, named blocker (or metadata-only event); error means an unexpected posting failure.\n",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/medianfi-com-business-events-api-openapi.yml#/components/schemas/BusinessEventWire",
  "type": "object",
  "properties": {
    "idempotentReplay": {
      "type": "boolean",
      "description": "True when a completed create operation was returned without creating or posting again. Posting failures/skips retain their own fields."
    },
    "id": {
      "type": "string",
      "format": "uuid"
    },
    "customerId": {
      "type": "string",
      "format": "uuid",
      "description": "The company id (wire name kept for accountant-app compatibility)."
    },
    "eventType": {
      "type": "string"
    },
    "status": {
      "type": "string"
    },
    "parameters": {
      "type": "object",
      "additionalProperties": true
    },
    "journalEntryId": {
      "type": [
        "string",
        "null"
      ],
      "format": "uuid"
    },
    "generatedEntries": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "account": {
            "type": "string"
          },
          "accountNumber": {
            "type": [
              "string",
              "null"
            ]
          },
          "debit": {
            "type": "number"
          },
          "credit": {
            "type": "number"
          },
          "memo": {
            "type": "string"
          }
        }
      }
    },
    "generatedJEs": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": true
      }
    },
    "journalEntryState": {
      "type": "string",
      "enum": [
        "posted",
        "not_posted",
        "void",
        "deleted",
        "missing",
        "mixed"
      ],
      "description": "Consolidated state of every journal entry owned by this event."
    },
    "journalEntryStateCounts": {
      "type": "object",
      "required": [
        "posted",
        "void",
        "deleted",
        "missing"
      ],
      "properties": {
        "posted": {
          "type": "integer",
          "minimum": 0
        },
        "void": {
          "type": "integer",
          "minimum": 0
        },
        "deleted": {
          "type": "integer",
          "minimum": 0
        },
        "missing": {
          "type": "integer",
          "minimum": 0
        }
      }
    },
    "jeGenerationSkipped": {
      "type": "string",
      "description": "Why journal-entry generation was skipped (named blocker, unresolved accounts, or metadata-only event)."
    },
    "jeGenerationError": {
      "type": "string",
      "description": "Unexpected posting failure recorded by the residual safety net (also captured to Sentry)."
    },
    "journalSkippedOnPurpose": {
      "type": "boolean",
      "enum": [
        true
      ],
      "description": "#3864: present only when the Stripe deferral schedule skipped this journal on purpose and owns its posting; retry-post answers 409 and no retry is offered."
    },
    "payablesApItemId": {
      "type": "string",
      "format": "uuid",
      "description": "#2529: the Payables (AP) item a posted vendor bill created or linked; its initial journal entry is this event's journal entry."
    },
    "unresolvedAccounts": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "createdBy": {
      "type": [
        "string",
        "null"
      ]
    }
  }
}