{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/spaceinvoices-com/json-schema/spaceinvoices-com-new-document-schema.json",
  "title": "_new_Document",
  "x-generated": "2026-11-25",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/spaceinvoices-com-openapi.json#/components/schemas/_new_Document",
  "properties": {
    "_issuance": {
      "description": "Internal atomic claim and fencing metadata for draft issuance",
      "type": "object"
    },
    "_fatturaPa": {
      "type": "object"
    },
    "_eFiskalizacija": {
      "description": "eFiskalizacija service data (Tax Admin port 8509) for B2B e-invoice reporting",
      "type": "object"
    },
    "number": {
      "description": "Auto-incremented on Document create if not provided.",
      "type": "string"
    },
    "previousDocumentId": {
      "type": "string"
    },
    "draft": {
      "default": false,
      "type": "boolean"
    },
    "date": {
      "description": "Default is today.",
      "type": "string",
      "format": "date-time"
    },
    "dateService": {
      "type": "string",
      "format": "date-time"
    },
    "dateServiceTo": {
      "description": "In case service for period, this is the end date of the period.",
      "type": "string",
      "format": "date-time"
    },
    "dateDue": {
      "description": "Date invoice is due.",
      "type": "string",
      "format": "date-time"
    },
    "dateValidTill": {
      "description": "Date estimate is valid till.",
      "type": "string",
      "format": "date-time"
    },
    "datePaid": {
      "description": "Date advance invoice was paid.",
      "type": "string",
      "format": "date-time"
    },
    "dateReceived": {
      "description": "Date document was received, used for incoming documents.",
      "type": "string",
      "format": "date-time"
    },
    "reference": {
      "description": "Reference for Payment or other identification",
      "type": "string"
    },
    "total": {
      "description": "Document total without taxes.",
      "type": "number",
      "format": "double"
    },
    "totalConverted": {
      "description": "Document total without taxes converted to organization's currency.",
      "type": "number",
      "format": "double"
    },
    "totalDiscount": {
      "description": "Total discount amount.",
      "type": "number",
      "format": "double"
    },
    "totalWithTax": {
      "description": "Document total with taxes.",
      "type": "number",
      "format": "double"
    },
    "totalWithTaxConverted": {
      "description": "Document total with taxes converted to organization's currency.",
      "type": "number",
      "format": "double"
    },
    "decimalPlaces": {
      "default": 4,
      "type": "number",
      "format": "double"
    },
    "note": {
      "description": "Document note to client. Auto-set based on Organization's Defaults if not provided.",
      "type": "string"
    },
    "taxClause": {
      "description": "Document tax clause used to replace [tax clause] smart code when visualising document.\nAuto-set based on Organization's settings on Document create if not provided.",
      "type": "string"
    },
    "omitTaxes": {
      "description": "If taxes should be omited when issuing document.\nAutomatically populated on document if set using omit_tax_ default.",
      "type": "boolean"
    },
    "keepPricesAsGross": {
      "description": "Forces not removing tax from gross price when saving document with omitTaxes set",
      "type": "boolean"
    },
    "ignoreOmitTaxes": {
      "description": "Forces omit taxes setting to be ignored when saving document",
      "type": "boolean"
    },
    "footer": {
      "description": "Auto-set based on Organization's Defaults if not provided.",
      "type": "string"
    },
    "signature": {
      "description": "Auto-set based on Organization's Defaults if not provided.",
      "type": "string"
    },
    "type": {
      "default": "invoice",
      "description": "Defaults is 'invoice'.",
      "type": "string"
    },
    "displayName": {
      "description": "Customize the dispay name of an estimate.",
      "type": "string"
    },
    "canceled": {
      "default": false,
      "type": "boolean"
    },
    "sentSnailMail": {
      "default": false,
      "type": "boolean"
    },
    "totalPaid": {
      "default": 0,
      "description": "Total amount paid on Document.",
      "type": "number",
      "format": "double"
    },
    "totalDue": {
      "default": 0,
      "description": "Total amount still due on Document.",
      "type": "number",
      "format": "double"
    },
    "paidInFull": {
      "default": false,
      "description": "Indicates if document was paid in full.",
      "type": "boolean"
    },
    "currencyId": {
      "description": "Defaults to Organization's currencyId if not provided.\n3 character ISO currency code.",
      "type": "string"
    },
    "_documentTaxes": {
      "description": "Auto-populated array of unique taxes on document.",
      "type": "array",
      "items": {
        "type": "object"
      }
    },
    "_documentReverseTaxes": {
      "description": "Auto-populated array of unique reverse taxes on document",
      "type": "array",
      "items": {
        "type": "object"
      }
    },
    "hasUnit": {
      "description": "Indicates if document has any items with unit specified. Used for display.",
      "type": "boolean"
    },
    "validateEslog": {
      "description": "Indicates if document should be validated based on eslog e-invoice format.",
      "type": "boolean"
    },
    "isValidEslog": {
      "description": "Property indicating that a document is a valid by eslog e-invoice validation",
      "type": "boolean"
    },
    "uniqueId": {
      "description": "Optional user defined random unique value for each individual document.\nUsed to prevent saving same document twice in case of connection drop.\nIf a match happens the system returns the found document instead of a new one.",
      "type": "string"
    },
    "customTotals": {
      "description": "If true document tax and amount totals won't be calculated, provided values will be used instead. Incoming documents only.",
      "type": "boolean"
    },
    "incoming": {
      "default": false,
      "description": "Indicates document is incoming ie. expense if invoice etc.",
      "type": "boolean"
    },
    "numberInternal": {
      "description": "Internal tracking number for incoming documents.",
      "type": "string"
    },
    "equalization": {
      "description": "Cent equalization amount.",
      "type": "number",
      "format": "double"
    },
    "sandbox": {
      "type": "boolean"
    },
    "issuedAt": {
      "description": "Date document was issued, can be different than createdAt if created as draft",
      "type": "string",
      "format": "date-time"
    },
    "shareableId": {
      "description": "id used for sharing document using a public link",
      "type": "string"
    },
    "stripeConnectPaymentIntent": {
      "type": "object"
    },
    "chargesDisabled": {
      "description": "Indicates if payment processing is disabled for this document",
      "type": "boolean"
    },
    "dateYear": {
      "type": "number",
      "format": "double"
    },
    "documentIds": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/ObjectID"
      }
    },
    "createdAt": {
      "type": "string",
      "format": "date-time"
    },
    "updatedAt": {
      "type": "string",
      "format": "date-time"
    },
    "custom": {
      "default": {},
      "description": "Custom field for freeform data input",
      "type": "object"
    },
    "l10n": {
      "description": "Object for storing localized values of strings",
      "type": "object"
    },
    "deletedAt": {
      "type": "string",
      "format": "date-time"
    },
    "_isDeleted": {
      "default": false,
      "type": "boolean"
    },
    "deletedId": {
      "type": "string"
    },
    "_documentItems": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/DocumentItem"
      }
    },
    "_documentIssuer": {
      "$ref": "#/$defs/DocumentIssuer"
    },
    "clientId": {
      "$ref": "#/$defs/ObjectID"
    },
    "_documentClient": {
      "$ref": "#/$defs/DocumentClient"
    },
    "organizationId": {
      "$ref": "#/$defs/ObjectID"
    },
    "accountId": {
      "$ref": "#/$defs/ObjectID"
    },
    "_comments": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Comment"
      }
    },
    "_furs": {
      "$ref": "#/$defs/Furs"
    },
    "_at": {
      "$ref": "#/$defs/At"
    },
    "_fina": {
      "$ref": "#/$defs/Fina"
    },
    "_documentConversionRate": {
      "$ref": "#/$defs/DocumentConversionRate"
    },
    "unitId": {
      "$ref": "#/$defs/ObjectID"
    },
    "_documentUnit": {
      "$ref": "#/$defs/DocumentUnit"
    },
    "priceListId": {
      "$ref": "#/$defs/ObjectID"
    },
    "warehouseId": {
      "$ref": "#/$defs/ObjectID"
    },
    "destinationWarehouseId": {
      "$ref": "#/$defs/ObjectID"
    },
    "_data": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/Data"
      }
    },
    "_bPay": {
      "$ref": "#/$defs/BPay"
    }
  },
  "additionalProperties": false,
  "$defs": {
    "At": {
      "properties": {
        "hashSource": {
          "type": "string"
        },
        "hash": {
          "type": "string"
        },
        "qrString": {
          "type": "string"
        },
        "qrCode": {
          "type": "string"
        },
        "certificateVersion": {
          "type": "string"
        },
        "certificateId": {
          "type": "string"
        },
        "hashExtract": {
          "type": "string"
        },
        "printCount": {
          "default": 0,
          "description": "Number of prints of document. If > 1 should print 'copy n' on it.",
          "type": "number",
          "format": "double"
        },
        "cancellationReason": {
          "type": "string"
        },
        "canceledByAccountId": {
          "type": "string"
        },
        "hasOriginalDocument": {
          "type": "boolean"
        },
        "isManual": {
          "default": false,
          "type": "boolean"
        },
        "manualNumber": {
          "type": "string"
        },
        "manualNumberSeries": {
          "type": "string"
        },
        "manualNumberSequentialNumber": {
          "type": "string"
        },
        "id": {
          "type": "string"
        },
        "accountId": {
          "$ref": "#/$defs/ObjectID"
        },
        "previousDocumentId": {
          "$ref": "#/$defs/ObjectID"
        },
        "atcudSeriesId": {
          "$ref": "#/$defs/ObjectID"
        }
      },
      "additionalProperties": false
    },
    "BPay": {
      "properties": {
        "billerCode": {
          "type": "string"
        },
        "reference": {
          "type": "string"
        },
        "hidden": {
          "type": "boolean"
        },
        "id": {
          "type": "string"
        }
      },
      "additionalProperties": false
    },
    "Comment": {
      "properties": {
        "id": {
          "type": "string"
        },
        "text": {
          "type": "string"
        },
        "accountId": {
          "$ref": "#/$defs/ObjectID"
        },
        "createdAt": {
          "type": "string",
          "format": "date-time"
        },
        "updatedAt": {
          "type": "string",
          "format": "date-time"
        }
      },
      "required": [
        "id",
        "text"
      ],
      "additionalProperties": false
    },
    "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
    },
    "DocumentClient": {
      "properties": {
        "id": {
          "type": "string"
        },
        "isEndCustomer": {
          "default": false,
          "type": "boolean"
        },
        "throwEslogErrors": {
          "type": "boolean"
        },
        "saveClient": {
          "type": "boolean"
        },
        "ipAddress": {
          "type": "string"
        },
        "fatturaPaChannelId": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "address": {
          "type": "string"
        },
        "address2": {
          "type": "string"
        },
        "city": {
          "type": "string"
        },
        "zip": {
          "type": "string"
        },
        "state": {
          "type": "string"
        },
        "country": {
          "type": "string"
        },
        "countryAlpha2Code": {
          "type": "string"
        },
        "taxNumber": {
          "type": "string"
        },
        "taxSubject": {
          "type": "boolean"
        },
        "companyNumber": {
          "type": "string"
        },
        "IBAN": {
          "type": "string"
        },
        "bank": {
          "type": "string"
        },
        "SWIFT": {
          "type": "string"
        },
        "website": {
          "type": "string"
        },
        "email": {
          "type": "string"
        },
        "phone": {
          "type": "string"
        },
        "businessType": {
          "type": "string"
        },
        "fiscalRegionCode": {
          "type": "string"
        },
        "startingCapital": {
          "type": "number",
          "format": "double"
        },
        "createdAt": {
          "type": "string",
          "format": "date-time"
        },
        "updatedAt": {
          "type": "string",
          "format": "date-time"
        },
        "custom": {
          "default": {},
          "description": "Custom field for freeform data input",
          "type": "object"
        },
        "_data": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Data"
          }
        }
      },
      "required": [
        "id",
        "name"
      ],
      "additionalProperties": false
    },
    "DocumentConversionRate": {
      "properties": {
        "id": {
          "type": "string"
        },
        "dualCurrency": {
          "description": "Is conversion meant for dual currency display.\ni.e. for Croatian organizations from 5.9.2022 to 1.1.2023\nShows conversion only for total and not taxes",
          "type": "boolean"
        },
        "from": {
          "type": "string"
        },
        "to": {
          "type": "string"
        },
        "rate": {
          "type": "number",
          "format": "double"
        },
        "date": {
          "type": "string",
          "format": "date-time"
        },
        "source": {
          "type": "string"
        }
      },
      "required": [
        "id",
        "from",
        "to",
        "rate",
        "date",
        "source"
      ],
      "additionalProperties": false
    },
    "DocumentIssuer": {
      "properties": {
        "id": {
          "type": "string"
        },
        "throwEslogErrors": {
          "type": "boolean"
        },
        "name": {
          "type": "string"
        },
        "address": {
          "type": "string"
        },
        "address2": {
          "type": "string"
        },
        "city": {
          "type": "string"
        },
        "zip": {
          "type": "string"
        },
        "state": {
          "type": "string"
        },
        "country": {
          "type": "string"
        },
        "countryAlpha2Code": {
          "type": "string"
        },
        "taxNumber": {
          "type": "string"
        },
        "taxSubject": {
          "type": "boolean"
        },
        "companyNumber": {
          "type": "string"
        },
        "IBAN": {
          "type": "string"
        },
        "bank": {
          "type": "string"
        },
        "SWIFT": {
          "type": "string"
        },
        "website": {
          "type": "string"
        },
        "email": {
          "type": "string"
        },
        "phone": {
          "type": "string"
        },
        "businessType": {
          "type": "string"
        },
        "fiscalRegionCode": {
          "type": "string"
        },
        "startingCapital": {
          "type": "number",
          "format": "double"
        },
        "createdAt": {
          "type": "string",
          "format": "date-time"
        },
        "updatedAt": {
          "type": "string",
          "format": "date-time"
        },
        "custom": {
          "default": {},
          "description": "Custom field for freeform data input",
          "type": "object"
        },
        "_data": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Data"
          }
        }
      },
      "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
    },
    "DocumentUnit": {
      "properties": {
        "id": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "address": {
          "type": "string"
        },
        "address2": {
          "type": "string"
        },
        "city": {
          "type": "string"
        },
        "zip": {
          "type": "string"
        },
        "state": {
          "type": "string"
        },
        "country": {
          "type": "string"
        },
        "countryAlpha2Code": {
          "type": "string"
        },
        "taxNumber": {
          "type": "string"
        },
        "taxSubject": {
          "type": "boolean"
        },
        "companyNumber": {
          "type": "string"
        },
        "IBAN": {
          "type": "string"
        },
        "bank": {
          "type": "string"
        },
        "SWIFT": {
          "type": "string"
        },
        "website": {
          "type": "string"
        },
        "email": {
          "type": "string"
        },
        "phone": {
          "type": "string"
        },
        "businessType": {
          "type": "string"
        },
        "fiscalRegionCode": {
          "type": "string"
        },
        "startingCapital": {
          "type": "number",
          "format": "double"
        },
        "createdAt": {
          "type": "string",
          "format": "date-time"
        },
        "updatedAt": {
          "type": "string",
          "format": "date-time"
        },
        "custom": {
          "default": {},
          "description": "Custom field for freeform data input",
          "type": "object"
        },
        "_data": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Data"
          }
        }
      },
      "required": [
        "id",
        "name"
      ],
      "additionalProperties": false
    },
    "Fina": {
      "properties": {
        "JIR": {
          "type": "string"
        },
        "ZKI": {
          "type": "string"
        },
        "businessPremiseId": {
          "type": "string"
        },
        "electronicDeviceId": {
          "type": "string"
        },
        "invoiceNumber": {
          "type": "number",
          "format": "double"
        },
        "strategy": {
          "description": "Fiscalization strategy used, C or B",
          "type": "string"
        },
        "operatorTaxNumber": {
          "type": "string"
        },
        "operatorLabel": {
          "description": "Label of operator ie. issuer of document.\nCopied from account creator.",
          "type": "string"
        },
        "paymentType": {
          "type": "string"
        },
        "environment": {
          "default": "production",
          "type": "string"
        },
        "payload": {
          "type": "object"
        },
        "id": {
          "type": "string"
        },
        "accountId": {
          "$ref": "#/$defs/ObjectID"
        }
      },
      "required": [
        "businessPremiseId",
        "electronicDeviceId",
        "invoiceNumber",
        "strategy",
        "operatorLabel",
        "environment"
      ],
      "additionalProperties": false
    },
    "Furs": {
      "properties": {
        "eor": {
          "type": "string"
        },
        "zoi": {
          "type": "string"
        },
        "qr": {
          "type": "string"
        },
        "businessPremiseId": {
          "type": "string"
        },
        "electronicDeviceId": {
          "type": "string"
        },
        "invoiceNumber": {
          "type": "number",
          "format": "double"
        },
        "strategy": {
          "description": "Fiscalization strategy used, C or B",
          "type": "string"
        },
        "operatorTaxNumber": {
          "description": "Mandatory, can be omitted if person doesn't have a Slo tax number\nusing omitOperatorTaxNumber",
          "type": "string"
        },
        "omitOperatorTaxNumber": {
          "default": false,
          "description": "Specify if operatorTaxNumber should be omitted in case operator\ndoesn't have Slo tax number.",
          "type": "boolean"
        },
        "operatorLabel": {
          "description": "Label of operator ie. issuer of document.\nCopied from account creator.",
          "type": "string"
        },
        "foreignOperator": {
          "default": false,
          "type": "boolean"
        },
        "iteration": {
          "default": 0,
          "description": "Iteration of document editing.",
          "type": "number",
          "format": "double"
        },
        "printCount": {
          "default": 0,
          "description": "Number of prints of document. If > 1 should print 'copy n' on it.",
          "type": "number",
          "format": "double"
        },
        "environment": {
          "default": "production",
          "type": "string"
        },
        "payload": {
          "type": "object"
        },
        "id": {
          "type": "string"
        },
        "accountId": {
          "$ref": "#/$defs/ObjectID"
        }
      },
      "required": [
        "businessPremiseId",
        "electronicDeviceId",
        "invoiceNumber",
        "strategy",
        "omitOperatorTaxNumber",
        "operatorLabel",
        "foreignOperator",
        "iteration",
        "printCount",
        "environment"
      ],
      "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": {}
    }
  }
}