{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/spaceinvoices-com/json-schema/spaceinvoices-com-invoice-schema.json",
  "title": "Invoice",
  "x-generated": "2026-11-25",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/spaceinvoices-com-openapi.json#/components/schemas/Invoice",
  "type": "object",
  "properties": {
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "updatedAt": {
      "type": "string",
      "format": "date-time"
    },
    "custom": {
      "type": "object",
      "description": "Custom field for free input data"
    },
    "l10n": {
      "type": "object",
      "description": "Object for storing localized values of strings"
    },
    "_isDeleted": {
      "type": "boolean"
    },
    "deletedAt": {
      "type": "string",
      "format": "date-time"
    },
    "number": {
      "type": "string"
    },
    "date": {
      "type": "string",
      "format": "date-time"
    },
    "reference": {
      "type": "string",
      "description": "Reference for payment identification"
    },
    "total": {
      "type": "number"
    },
    "totalConverted": {
      "type": "number"
    },
    "totalDiscount": {
      "type": "number"
    },
    "totalWithTax": {
      "type": "number"
    },
    "totalWithTaxConverted": {
      "type": "number"
    },
    "decimalPlaces": {
      "type": "number",
      "minimum": 0,
      "maximum": 9
    },
    "note": {
      "type": "string"
    },
    "taxClause": {
      "type": "string",
      "description": "Document tax clause used to replace [tax clause] smart code when visualising document. Automatically populated on document save/update if not provided."
    },
    "omitTaxes": {
      "type": "boolean",
      "description": "If taxes should be omited when issuing document. Automatically populated on document if set using omit_tax_ default."
    },
    "footer": {
      "type": "string"
    },
    "signature": {
      "type": "string"
    },
    "type": {
      "type": "string"
    },
    "sentSnailMail": {
      "type": "boolean"
    },
    "currencyId": {
      "type": "string",
      "description": "Document 3 letter currency id based on ISO 4217 standard."
    },
    "_documentTaxes": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/DocumentTax"
      }
    },
    "_documentReverseTaxes": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/DocumentTax"
      }
    },
    "hasUnit": {
      "type": "boolean",
      "description": "Indicates if document has any items with unit specified. Used for display."
    },
    "uniqueId": {
      "type": "string",
      "description": "Optional user defined random unique value for each unique document used to prevent saving same document twice in case of connection drop. If a match happens the system returns the found document instead of a new one."
    },
    "equalization": {
      "type": "number",
      "description": "Cent equalization amount"
    },
    "issuedAt": {
      "type": "string",
      "format": "date-time",
      "description": "Date document was issued, can be different than createdAt if created as draft"
    },
    "dateYear": {
      "type": "number"
    },
    "shareableId": {
      "type": "string"
    },
    "_documentIssuer": {
      "type": "object"
    },
    "_documentClient": {
      "type": "object"
    },
    "_documentItems": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/DocumentItem"
      }
    },
    "incoming": {
      "type": "boolean"
    },
    "id": {
      "type": "string"
    },
    "draft": {
      "type": "boolean"
    },
    "dateService": {
      "type": "string",
      "format": "date-time"
    },
    "dateServiceTo": {
      "type": "string",
      "format": "date-time"
    },
    "dateDue": {
      "type": "string",
      "format": "date-time"
    },
    "canceled": {
      "type": "boolean"
    },
    "totalPaid": {
      "type": "number"
    },
    "totalDue": {
      "type": "number"
    },
    "paidInFull": {
      "type": "boolean"
    },
    "chargesDisabled": {
      "type": "boolean",
      "description": "Indicates if payment processing via Pay now button is disabled for this document"
    },
    "stripeConnectPaymentIntent": {
      "type": "object"
    },
    "organizationId": {
      "type": "string"
    },
    "accountId": {
      "type": "string"
    },
    "clientId": {
      "type": "string"
    },
    "_fatturaPa": {
      "type": "object"
    }
  },
  "required": [
    "date",
    "total",
    "totalWithTax",
    "currencyId",
    "hasUnit",
    "dateYear",
    "_documentIssuer",
    "_documentClient",
    "_documentItems"
  ],
  "additionalProperties": false,
  "$defs": {
    "Component": {
      "properties": {
        "id": {
          "type": "string"
        },
        "amount": {
          "description": "How many of this component go into one parent composed item.",
          "type": "number",
          "format": "double"
        },
        "itemId": {
          "$ref": "#/$defs/ObjectID"
        },
        "custom": {
          "default": {},
          "description": "Custom field for freeform data input",
          "type": "object"
        }
      },
      "required": [
        "id",
        "amount"
      ],
      "additionalProperties": false
    },
    "Data": {
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "description": "Name identifier of data",
          "type": "string"
        },
        "value": {
          "$ref": "#/$defs/x-any"
        },
        "options": {
          "description": "Different data options.\nIe. should the value be persistem to the document `onPDF: boolean`.\nThis includes displaying on PDF.\nNote that only two values will be displayed per PDF on Client.\nAdd Document data to export using `export: boolean`",
          "type": "object"
        }
      },
      "required": [
        "id",
        "name"
      ],
      "additionalProperties": false
    },
    "DocumentItem": {
      "properties": {
        "id": {
          "type": "string"
        },
        "discount": {
          "type": "number",
          "format": "double"
        },
        "discountIsAmount": {
          "default": false,
          "type": "boolean"
        },
        "quantity": {
          "type": "number",
          "format": "double"
        },
        "total": {
          "type": "number",
          "format": "double"
        },
        "totalWithTax": {
          "type": "number",
          "format": "double"
        },
        "totalTax": {
          "type": "number",
          "format": "double"
        },
        "totalDiscount": {
          "type": "number",
          "format": "double"
        },
        "isSeparator": {
          "default": false,
          "type": "boolean"
        },
        "name": {
          "type": "string"
        },
        "description": {
          "default": "",
          "type": "string"
        },
        "price": {
          "type": "number",
          "format": "double"
        },
        "priceGross": {
          "type": "number",
          "format": "double"
        },
        "classification": {
          "type": "string"
        },
        "unit": {
          "type": "string"
        },
        "SKU": {
          "type": "string"
        },
        "EAN": {
          "type": "string"
        },
        "trackInventory": {
          "type": "boolean"
        },
        "onBehalf": {
          "description": "tax number of company selling this item/service on behalf of",
          "type": "string"
        },
        "taxExemptionCode": {
          "description": "Has to be specified in some countries if the tax is 0 or not present",
          "type": "string"
        },
        "taxExemptionReason": {
          "description": "Has to be specified in some countries if the tax is 0 or not present",
          "type": "string"
        },
        "kpd": {
          "description": "KPD classification code (Croatian CPA) - format XX.XX.XX",
          "type": "string"
        },
        "itemId": {
          "$ref": "#/$defs/ObjectID"
        },
        "_taxExemption": {
          "$ref": "#/$defs/TaxExemption"
        },
        "custom": {
          "default": {},
          "description": "Custom field for freeform data input",
          "type": "object"
        },
        "l10n": {
          "description": "Object for storing localized values of strings",
          "type": "object"
        },
        "_documentItemTaxes": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/DocumentItemTax"
          }
        },
        "_components": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Component"
          }
        },
        "_data": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Data"
          }
        }
      },
      "required": [
        "id"
      ],
      "additionalProperties": false
    },
    "DocumentItemTax": {
      "properties": {
        "id": {
          "type": "string"
        },
        "rate": {
          "type": "number",
          "format": "double"
        },
        "reverseCharged": {
          "default": false,
          "type": "boolean"
        },
        "name": {
          "type": "string"
        },
        "abbreviation": {
          "type": "string"
        },
        "recoverable": {
          "default": true,
          "type": "boolean"
        },
        "compound": {
          "default": false,
          "type": "boolean"
        },
        "taxNumber": {
          "description": "Tax number associated with this tax.",
          "type": "string"
        },
        "taxExemptionReason": {
          "description": "Tax number associated with this tax.",
          "type": "string"
        },
        "taxExemptionCode": {
          "description": "Tax exemption code associated with this tax.",
          "type": "string"
        },
        "taxId": {
          "$ref": "#/$defs/ObjectID"
        }
      },
      "required": [
        "id",
        "rate",
        "reverseCharged",
        "recoverable",
        "compound"
      ],
      "additionalProperties": false
    },
    "DocumentTax": {
      "title": "DocumentTax",
      "type": "object",
      "properties": {
        "taxId": {
          "type": "string"
        },
        "tax": {
          "type": "number"
        },
        "base": {
          "type": "number"
        },
        "baseConverted": {
          "type": "number"
        },
        "abbreviation": {
          "type": "string"
        },
        "totalTax": {
          "type": "number"
        },
        "totalTaxConverted": {
          "type": "number"
        }
      },
      "required": [
        "tax",
        "base",
        "totalTax",
        "totalTaxConverted"
      ],
      "additionalProperties": false
    },
    "ObjectID": {
      "type": "string",
      "pattern": "^[a-fA-F\\d]{24}$"
    },
    "TaxExemption": {
      "properties": {
        "code": {
          "type": "string"
        },
        "reason": {
          "type": "string"
        },
        "id": {
          "type": "string"
        }
      },
      "additionalProperties": false
    },
    "x-any": {
      "properties": {}
    }
  }
}