{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/quotebill-com/json-schema/quotebill-com-document-request-schema.json",
  "title": "DocumentRequest",
  "description": "A document to make. A field the API does not know is refused (422). Numbers are JSON numbers, not text. Prices are before tax: QuoteBill documents have no tax-inclusive prices.",
  "x-generated": "2026-11-22",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/quotebill-com-openapi.yml#/components/schemas/DocumentRequest",
  "type": "object",
  "properties": {
    "kind": {
      "type": "string",
      "enum": [
        "quotation",
        "invoice",
        "proforma",
        "receipt",
        "creditNote",
        "purchaseOrder",
        "deliveryNote",
        "workOrder",
        "commercialInvoice"
      ],
      "description": "Required. A statement of account is not made through the API."
    },
    "template": {
      "anyOf": [
        {
          "type": "string",
          "pattern": "^[a-z0-9][a-z0-9._-]{0,80}$"
        },
        {
          "type": "null"
        }
      ],
      "description": "A template slug from GET /v1/templates, of the same kind. Optional: null or an empty string counts as left out."
    },
    "language": {
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "en",
            "ko",
            "ja",
            "zh",
            "de",
            "fr",
            "es",
            "vi",
            "ar",
            "ru",
            "pt",
            "it",
            "nl",
            "pl",
            "tr",
            "sv",
            "th",
            "id",
            "ms",
            "da",
            "fi",
            "nb",
            "el",
            "cs",
            "hu",
            "ro",
            "bg",
            "hr",
            "lt",
            "lv",
            "et",
            "sl",
            "sk"
          ]
        },
        {
          "type": "null"
        }
      ],
      "description": "The language the document is written in. Default: the account's, else en. Optional: null or an empty string counts as left out."
    },
    "country": {
      "anyOf": [
        {
          "type": "string",
          "pattern": "^[A-Z]{2}$"
        },
        {
          "type": "null"
        }
      ],
      "description": "A country of GET /v1/countries. The tax follows it. Default: the template's own country (a regional template), else the account's, else US. Optional: null or an empty string counts as left out."
    },
    "region": {
      "anyOf": [
        {
          "type": "string",
          "pattern": "^[A-Z]{2}$"
        },
        {
          "type": "null"
        }
      ],
      "description": "A Canadian province or territory of GET /v1/countries (CA regions), only with country CA: its GST, HST, PST or QST, each rounded on its own. Optional: null or an empty string counts as left out."
    },
    "currency": {
      "anyOf": [
        {
          "type": "string",
          "pattern": "^[A-Z]{3}$"
        },
        {
          "type": "null"
        }
      ],
      "description": "A currency of GET /v1/countries. Default: the account's, else the country's. Amounts round to its decimals. Optional: null or an empty string counts as left out."
    },
    "issue_date": {
      "anyOf": [
        {
          "type": "string",
          "format": "date",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
        },
        {
          "type": "null"
        }
      ],
      "description": "A day from 2000 to 2100. Default: today (UTC). Optional: null or an empty string counts as left out."
    },
    "due_date": {
      "anyOf": [
        {
          "type": "string",
          "format": "date",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
        },
        {
          "type": "null"
        }
      ],
      "description": "For an invoice or commercial invoice. Default: 30 days after the issue date. Optional: null or an empty string counts as left out."
    },
    "valid_until": {
      "anyOf": [
        {
          "type": "string",
          "format": "date",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
        },
        {
          "type": "null"
        }
      ],
      "description": "For a quotation or proforma invoice. Default: 30 days after the issue date. Optional: null or an empty string counts as left out."
    },
    "document_number": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 100
        },
        {
          "type": "null"
        }
      ],
      "description": "Default: made as the account's numbering setting says. Optional: null or an empty string counts as left out."
    },
    "tax_rate": {
      "anyOf": [
        {
          "type": "number",
          "minimum": 0,
          "maximum": 100
        },
        {
          "type": "null"
        }
      ],
      "description": "A percentage for the whole document. Default: the kind's own (0 for a commercial invoice), else the template's own (0 for a template made for someone not registered for VAT or GST), else the account's saved rate when the document is for the account's own country, else the country's or region's published rate. Optional: null or an empty string counts as left out."
    },
    "customer": {
      "$ref": "#/$defs/Customer"
    },
    "items": {
      "type": "array",
      "minItems": 1,
      "maxItems": 200,
      "items": {
        "type": "object",
        "properties": {
          "description": {
            "type": "string",
            "minLength": 1,
            "maxLength": 500,
            "description": "Up to 500 characters, one line. Required."
          },
          "quantity": {
            "type": "number",
            "exclusiveMinimum": 0,
            "maximum": 1000000000,
            "description": "A JSON number above 0. Hours on an hours template."
          },
          "unit_price": {
            "type": "number",
            "minimum": 0,
            "maximum": 100000000000,
            "description": "A JSON number from 0, before tax. Required, except on a kind or template whose lines are quantities only. quantity x unit_price may not pass 100000000000."
          },
          "tax_rate": {
            "anyOf": [
              {
                "type": "number",
                "minimum": 0,
                "maximum": 100
              },
              {
                "type": "null"
              }
            ],
            "description": "A percentage. A document has one tax rate, so it must equal the document's tax_rate and every other item's. Optional: null or an empty string counts as left out."
          },
          "discount": {
            "anyOf": [
              {
                "$ref": "#/$defs/Discount"
              },
              {
                "type": "null"
              }
            ],
            "description": "Taken off the line before tax, as the editor's discount column does. Optional: null or an empty string counts as left out."
          }
        },
        "required": [
          "description",
          "quantity"
        ],
        "additionalProperties": false
      },
      "description": "1 to 200 lines."
    },
    "notes": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 2000
        },
        {
          "type": "null"
        }
      ],
      "description": "Up to 2,000 characters, printed on the document. Optional: null or an empty string counts as left out."
    }
  },
  "required": [
    "kind",
    "customer",
    "items"
  ],
  "additionalProperties": false,
  "$defs": {
    "Customer": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "minLength": 1,
          "maxLength": 200,
          "description": "Required."
        },
        "email": {
          "anyOf": [
            {
              "type": "string",
              "maxLength": 254,
              "pattern": "^[^\\s@]{1,64}@[^\\s@]{1,255}$"
            },
            {
              "type": "null"
            }
          ],
          "description": "An e-mail address. Optional: null or an empty string counts as left out."
        },
        "address": {
          "anyOf": [
            {
              "type": "string",
              "maxLength": 500
            },
            {
              "type": "null"
            }
          ],
          "description": "Up to 500 characters; may hold line breaks. Optional: null or an empty string counts as left out."
        },
        "tax_id": {
          "anyOf": [
            {
              "type": "string",
              "maxLength": 60
            },
            {
              "type": "null"
            }
          ],
          "description": "Up to 60 characters. Optional: null or an empty string counts as left out."
        }
      },
      "required": [
        "name"
      ],
      "additionalProperties": false
    },
    "Discount": {
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "percent",
            "amount"
          ]
        },
        "value": {
          "type": "number",
          "minimum": 0,
          "maximum": 100000000000,
          "description": "percent: 0 to 100. amount: in the document's currency, at most quantity x unit_price."
        }
      },
      "required": [
        "type",
        "value"
      ],
      "additionalProperties": false,
      "description": "A line's discount (V 1.38 on requests; read back since V 1.28)."
    }
  }
}