{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/karbonhq/json-schema/karbonhq-billing-invoice-schema.json",
  "title": "BillingInvoice",
  "description": "A Karbon Invoice record",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/karbonhq-billing-api-openapi.yml#/components/schemas/BillingInvoice",
  "type": "object",
  "allOf": [
    {
      "$ref": "#/$defs/BillingBaseInvoice"
    },
    {
      "$ref": "#/$defs/BillingClient"
    },
    {
      "$ref": "#/$defs/BillingTaxLineItems"
    }
  ],
  "$defs": {
    "BillingBaseInvoice": {
      "description": "A Karbon invoice",
      "type": "object",
      "required": [
        "InvoiceKey",
        "InvoiceNumber",
        "TotalAmountDue",
        "InvoiceTotal",
        "InvoiceSubTotal",
        "InvoiceTaxTotal",
        "InvoiceDate",
        "PaymentDueDate",
        "UpdatedAt",
        "CurrencyCode",
        "InvoiceStatus"
      ],
      "properties": {
        "InvoiceKey": {
          "type": "string",
          "description": "The unique key assigned to an invoice by Karbon"
        },
        "InvoiceNumber": {
          "type": "string",
          "description": "The invoice number of the invoice"
        },
        "TotalAmountDue": {
          "type": "number",
          "description": "Remaining amount due on the invoice, including taxes minus any payments"
        },
        "InvoiceTotal": {
          "type": "number",
          "description": "Invoice total, including taxes"
        },
        "InvoiceSubTotal": {
          "type": "number",
          "description": "The sum of the line items of the invoice, excluding taxes"
        },
        "InvoiceTaxTotal": {
          "type": "number",
          "description": "Total of the taxes on the invoice"
        },
        "InvoiceDate": {
          "type": "string",
          "description": "The date the invoice was issued as an ISO 8601 timestamp"
        },
        "PaymentDueDate": {
          "type": "string",
          "description": "The date the invoice is due as an ISO 8601 timestamp"
        },
        "UpdatedAt": {
          "type": "string",
          "description": "A timestamp showing when the invoice was last updated as an ISO 8601 timestamp"
        },
        "CurrencyCode": {
          "type": "string",
          "description": "A three letter ISO 4217 currency code denoting the currency used in the invoice, e.g. AUD, USD, CAD, NZD, EUR, GBP"
        },
        "PaymentInstructions": {
          "type": [
            "string",
            "null"
          ],
          "description": "Payment instructions added to the invoice"
        },
        "InvoiceStatus": {
          "type": "string",
          "enum": [
            "Approved",
            "AwaitingPayment",
            "Paid",
            "Exported",
            "Voided"
          ],
          "description": "Current status of the invoice"
        }
      }
    },
    "BillingClient": {
      "required": [
        "Client"
      ],
      "description": "The details of the invoice recipient at the point in time the invoice was drafted or payment creator at the point the payment was received",
      "properties": {
        "Client": {
          "type": [
            "object",
            "null"
          ],
          "description": "The Karbon Client Billing Contact",
          "properties": {
            "ClientKey": {
              "type": "string",
              "description": "The unique key of the billed Client"
            },
            "ClientType": {
              "type": "string",
              "description": "The client type, e.g. Contact or Organization"
            },
            "Name": {
              "type": "string",
              "description": "The name of the client at the point the invoice was drafted"
            },
            "AddressLine": {
              "type": "string",
              "description": "The billing address of the cient at the point the invoice was drafted"
            },
            "City": {
              "type": "string",
              "description": "The billing address city of the cient at the point the invoice was drafted"
            },
            "StateProvinceCounty": {
              "type": "string",
              "description": "The billing address state/province/country of the cient at the point the invoice was drafted"
            },
            "ZipCode": {
              "type": "string",
              "description": "The billing address zip/postal code of the cient at the point the invoice was drafted"
            },
            "Country": {
              "type": "string",
              "description": "The billing address country of the cient at the point the invoice was drafted"
            },
            "EmailAddress": {
              "type": "string",
              "description": "The billing email address of the cient at the point the invoice was drafted"
            }
          }
        }
      }
    },
    "BillingTaxLineItems": {
      "type": "object",
      "description": "Details of the tax components of the invoice",
      "properties": {
        "TaxLineItems": {
          "description": "An array of tax types and values from invoice line items",
          "type": "array",
          "items": {
            "description": "A tax line item detailing the tax code and amount on Karbon invoice",
            "properties": {
              "TaxName": {
                "type": "string",
                "description": "The name of the tax"
              },
              "TaxValue": {
                "type": "number",
                "description": "The value of the tax in the invoice currency"
              }
            }
          }
        }
      }
    }
  }
}