{
  "openapi": "3.1.0",
  "info": {
    "title": "Quickly Invoice API",
    "version": "1.0.0",
    "summary": "Make and read the documents of an Israeli business: receipts, tax invoices and the rest.",
    "description": "Docs, guides and examples: https://api.quicklyinvoice.com/docs. Support: hello@quicklyinvoice.com.",
    "contact": {
      "email": "hello@quicklyinvoice.com",
      "url": "https://api.quicklyinvoice.com/docs"
    }
  },
  "servers": [
    {
      "url": "https://api.quicklyinvoice.com/v1"
    }
  ],
  "security": [
    {
      "apiKey": []
    }
  ],
  "tags": [
    {
      "name": "Business",
      "description": "The business the key belongs to."
    },
    {
      "name": "Documents",
      "description": "Receipts, invoices, quotes and the other document types."
    },
    {
      "name": "Customers",
      "description": "The business's customers."
    }
  ],
  "paths": {
    "/business": {
      "get": {
        "operationId": "getBusiness",
        "tags": [
          "Business"
        ],
        "summary": "The business, its VAT status and what it may make",
        "description": "Call it first: it says which document types the business makes and when an invoice needs an approval number. Needs no scope.",
        "responses": {
          "200": {
            "description": "The business.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Business"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "402": {
            "$ref": "#/components/responses/E402"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/documents": {
      "post": {
        "operationId": "createDocument",
        "tags": [
          "Documents"
        ],
        "summary": "Make a document",
        "description": "Made exactly as the Quickly Invoice app makes it: the business's numbering, its plan limit, and an approval number from the Tax Authority for a tax_invoice or invoice_receipt from the threshold up (see GET /business). Scope: documents:write.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Any unique string (8 to 255 characters), e.g. your order id. Sending the same request again with the same key answers the first answer (for 24 hours) and never makes a second document.",
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 255
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateDocument"
              },
              "example": {
                "type": "receipt",
                "customer": {
                  "externalId": "shop-1842",
                  "name": "Dana Levi",
                  "phone": "0501234567",
                  "email": "dana@example.com"
                },
                "items": [
                  {
                    "description": "Haircut",
                    "quantity": 1,
                    "price": 100
                  }
                ],
                "payments": [
                  {
                    "method": "credit_card",
                    "amount": 100,
                    "cardLast4": "4242"
                  }
                ],
                "send": {
                  "email": "dana@example.com"
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The new document.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Document"
                },
                "example": {
                  "id": "6ae7ad705b41bf815c641079",
                  "type": "receipt",
                  "typeCode": "400",
                  "number": 1043,
                  "date": "2026-11-01",
                  "status": "issued",
                  "customer": {
                    "id": "6ae7aa88a8bda9fb93c58e1c",
                    "name": "Dana Levi",
                    "taxId": null,
                    "companyName": null
                  },
                  "items": [
                    {
                      "description": "Haircut",
                      "quantity": 1,
                      "unitPrice": 100,
                      "vatIncluded": true
                    }
                  ],
                  "discount": 0,
                  "total": 100,
                  "vat": 15.25,
                  "totalBeforeVat": 84.75,
                  "currency": "ILS",
                  "payments": [
                    {
                      "method": "credit_card",
                      "amount": 100,
                      "date": "2026-11-01"
                    }
                  ],
                  "approvalNumber": null,
                  "approvalNumberStatus": "not_needed",
                  "note": null,
                  "pdfUrl": "https://api.zenat.app/customer/document/pdf/6ae7ad705b41bf815c641079",
                  "shareUrl": null,
                  "createdAt": "2026-11-01T12:00:00.000Z"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "402": {
            "$ref": "#/components/responses/E402"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "500": {
            "$ref": "#/components/responses/E500"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          },
          "504": {
            "$ref": "#/components/responses/E504"
          }
        }
      },
      "get": {
        "operationId": "listDocuments",
        "tags": [
          "Documents"
        ],
        "summary": "List documents, newest first",
        "description": "Scope: documents:read.",
        "parameters": [
          {
            "name": "type",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/DocumentType"
            }
          },
          {
            "name": "from",
            "in": "query",
            "description": "First day, Israel time.",
            "schema": {
              "type": "string",
              "format": "date",
              "example": "2026-11-01"
            }
          },
          {
            "name": "to",
            "in": "query",
            "description": "Last day, Israel time.",
            "schema": {
              "type": "string",
              "format": "date",
              "example": "2026-11-01"
            }
          },
          {
            "name": "customer",
            "in": "query",
            "description": "A customer's id.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          {
            "name": "perPage",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of documents.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DocumentList"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "402": {
            "$ref": "#/components/responses/E402"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/documents/{id}": {
      "get": {
        "operationId": "getDocument",
        "tags": [
          "Documents"
        ],
        "summary": "Read a document",
        "description": "Scope: documents:read.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The document's id.",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{24}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The document.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Document"
                },
                "example": {
                  "id": "6ae7ad705b41bf815c641079",
                  "type": "receipt",
                  "typeCode": "400",
                  "number": 1043,
                  "date": "2026-11-01",
                  "status": "issued",
                  "customer": {
                    "id": "6ae7aa88a8bda9fb93c58e1c",
                    "name": "Dana Levi",
                    "taxId": null,
                    "companyName": null
                  },
                  "items": [
                    {
                      "description": "Haircut",
                      "quantity": 1,
                      "unitPrice": 100,
                      "vatIncluded": true
                    }
                  ],
                  "discount": 0,
                  "total": 100,
                  "vat": 15.25,
                  "totalBeforeVat": 84.75,
                  "currency": "ILS",
                  "payments": [
                    {
                      "method": "credit_card",
                      "amount": 100,
                      "date": "2026-11-01"
                    }
                  ],
                  "approvalNumber": null,
                  "approvalNumberStatus": "not_needed",
                  "note": null,
                  "pdfUrl": "https://api.zenat.app/customer/document/pdf/6ae7ad705b41bf815c641079",
                  "shareUrl": null,
                  "createdAt": "2026-11-01T12:00:00.000Z"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "402": {
            "$ref": "#/components/responses/E402"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/documents/{id}/pdf": {
      "get": {
        "operationId": "getDocumentPdf",
        "tags": [
          "Documents"
        ],
        "summary": "Redirect to the document's PDF",
        "description": "Answers 302 to the PDF, which opens without a key (the link the app shares). Scope: documents:read.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The document's id.",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{24}$"
            }
          }
        ],
        "responses": {
          "302": {
            "description": "Location is the PDF."
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "402": {
            "$ref": "#/components/responses/E402"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/documents/{id}/send": {
      "post": {
        "operationId": "sendDocument",
        "tags": [
          "Documents"
        ],
        "summary": "Email the document's PDF",
        "description": "Scope: documents:write.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The document's id.",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{24}$"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Any unique string (8 to 255 characters), e.g. your order id. Sending the same request again with the same key answers the first answer (for 24 hours) and never makes a second document.",
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 255
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SendTo"
              },
              "example": {
                "email": "dana@example.com",
                "name": "Dana"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Sent.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "sent": {
                      "type": "object",
                      "properties": {
                        "email": {
                          "type": "string"
                        },
                        "sent": {
                          "type": "boolean"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "402": {
            "$ref": "#/components/responses/E402"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/documents/{id}/cancel": {
      "post": {
        "operationId": "cancelDocument",
        "tags": [
          "Documents"
        ],
        "summary": "Cancel a document",
        "description": "Makes the credit document for it, as the app does, and answers both. Quotes, orders, transaction invoices and credit invoices cannot be cancelled. Scope: documents:write.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The document's id.",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{24}$"
            }
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Any unique string (8 to 255 characters), e.g. your order id. Sending the same request again with the same key answers the first answer (for 24 hours) and never makes a second document.",
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 255
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The cancelled document and its credit.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "document": {
                      "$ref": "#/components/schemas/Document"
                    },
                    "credit": {
                      "oneOf": [
                        {
                          "$ref": "#/components/schemas/Document"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "402": {
            "$ref": "#/components/responses/E402"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "422": {
            "$ref": "#/components/responses/E422"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "500": {
            "$ref": "#/components/responses/E500"
          },
          "504": {
            "$ref": "#/components/responses/E504"
          }
        }
      }
    },
    "/customers": {
      "get": {
        "operationId": "listCustomers",
        "tags": [
          "Customers"
        ],
        "summary": "List customers",
        "description": "Scope: customers:read.",
        "parameters": [
          {
            "name": "search",
            "in": "query",
            "description": "Part of a name, phone or email.",
            "schema": {
              "type": "string",
              "maxLength": 100
            }
          },
          {
            "name": "externalId",
            "in": "query",
            "description": "Your system's id.",
            "schema": {
              "type": "string",
              "maxLength": 100
            }
          },
          {
            "name": "page",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          {
            "name": "perPage",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 25
            }
          }
        ],
        "responses": {
          "200": {
            "description": "A page of customers.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomerList"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "402": {
            "$ref": "#/components/responses/E402"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      },
      "post": {
        "operationId": "createCustomer",
        "tags": [
          "Customers"
        ],
        "summary": "Add a customer",
        "description": "A customer with the same externalId or phone is not added twice: the answer is the existing one (200, `existing: true`). Scope: customers:write.",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Any unique string (8 to 255 characters), e.g. your order id. Sending the same request again with the same key answers the first answer (for 24 hours) and never makes a second document.",
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 255
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCustomer"
              },
              "example": {
                "name": "Dana Levi",
                "phone": "0501234567",
                "externalId": "shop-1842"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Already a customer.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Customer"
                }
              }
            }
          },
          "201": {
            "description": "Added.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Customer"
                },
                "example": {
                  "id": "6ae7aa88a8bda9fb93c58e1c",
                  "name": "Dana Levi",
                  "phone": "+972501234567",
                  "email": "dana@example.com",
                  "taxId": null,
                  "companyName": null,
                  "address": null,
                  "externalId": "shop-1842",
                  "createdAt": "2026-11-01T12:00:00.000Z"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "402": {
            "$ref": "#/components/responses/E402"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "409": {
            "$ref": "#/components/responses/E409"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    },
    "/customers/{id}": {
      "get": {
        "operationId": "getCustomer",
        "tags": [
          "Customers"
        ],
        "summary": "Read a customer",
        "description": "Scope: customers:read.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "The customer's id.",
            "schema": {
              "type": "string",
              "pattern": "^[0-9a-f]{24}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The customer.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Customer"
                },
                "example": {
                  "id": "6ae7aa88a8bda9fb93c58e1c",
                  "name": "Dana Levi",
                  "phone": "+972501234567",
                  "email": "dana@example.com",
                  "taxId": null,
                  "companyName": null,
                  "address": null,
                  "externalId": "shop-1842",
                  "createdAt": "2026-11-01T12:00:00.000Z"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "402": {
            "$ref": "#/components/responses/E402"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "apiKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "Authorization: Bearer qik_live_... (or qik_test_... for test mode). A key is made on Settings → API in the Quickly Invoice app. Call from your server only: a request from a browser is refused."
      }
    },
    "responses": {
      "E400": {
        "description": "invalid_request, idempotency_key_invalid",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E401": {
        "description": "unauthorized",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E402": {
        "description": "plan_required, plan_limit",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E403": {
        "description": "forbidden_scope, customers_scope_needed",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E404": {
        "description": "not_found",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E409": {
        "description": "already_cancelled, already_cancelling, idempotency_key_reused, idempotency_key_in_use",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E422": {
        "description": "document_type_not_allowed, payments_mismatch, payments_not_allowed, tax_authority_not_connected, cannot_cancel, send_failed, rejected",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E429": {
        "description": "rate_limited, daily_limit",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E500": {
        "description": "internal_error, outcome_unknown",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E503": {
        "description": "unavailable",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E504": {
        "description": "outcome_unknown (a write that ran out of time)",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    },
    "schemas": {
      "DocumentType": {
        "type": "string",
        "enum": [
          "receipt",
          "tax_invoice",
          "invoice_receipt",
          "credit_invoice",
          "transaction_invoice",
          "order",
          "quote",
          "delivery_note"
        ]
      },
      "PaymentMethod": {
        "type": "string",
        "enum": [
          "cash",
          "cheque",
          "credit_card",
          "bank_transfer",
          "payment_app",
          "withholding_tax"
        ]
      },
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string",
                "enum": [
                  "invalid_request",
                  "idempotency_key_invalid",
                  "unauthorized",
                  "plan_required",
                  "plan_limit",
                  "forbidden_scope",
                  "customers_scope_needed",
                  "not_found",
                  "already_cancelled",
                  "already_cancelling",
                  "idempotency_key_reused",
                  "idempotency_key_in_use",
                  "document_type_not_allowed",
                  "payments_mismatch",
                  "payments_not_allowed",
                  "tax_authority_not_connected",
                  "cannot_cancel",
                  "send_failed",
                  "rejected",
                  "rate_limited",
                  "daily_limit",
                  "internal_error",
                  "outcome_unknown",
                  "unavailable",
                  "moving_to_v1"
                ]
              },
              "message": {
                "type": "string",
                "description": "In English, or Hebrew with Accept-Language: he."
              },
              "details": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "field": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "Business": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": [
              "string",
              "null"
            ]
          },
          "businessNumber": {
            "type": [
              "string",
              "null"
            ],
            "description": "ח.פ / ע.מ."
          },
          "vatStatus": {
            "type": "string",
            "enum": [
              "licensed",
              "company",
              "exempt"
            ]
          },
          "vatRate": {
            "type": "number",
            "example": 18
          },
          "documentTypes": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DocumentType"
            }
          },
          "approvalNumber": {
            "type": "object",
            "properties": {
              "documentTypes": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/DocumentType"
                }
              },
              "fromAmountBeforeVat": {
                "type": "number",
                "description": "An invoice from this amount before VAT needs an approval number."
              },
              "taxAuthorityConnected": {
                "type": "boolean"
              }
            }
          },
          "key": {
            "type": "object",
            "properties": {
              "mode": {
                "type": "string",
                "enum": [
                  "live",
                  "test"
                ]
              },
              "scopes": {
                "type": "array",
                "items": {
                  "type": "string",
                  "enum": [
                    "documents:read",
                    "documents:write",
                    "customers:read",
                    "customers:write"
                  ]
                }
              }
            }
          }
        }
      },
      "CustomerRef": {
        "type": "object",
        "description": "Who the document is for. `id` names a customer of the business; `externalId` (your id) or `phone` finds one, or adds one with these details when the key has customers:write; with neither, the details are only printed on the document.",
        "properties": {
          "id": {
            "type": "string"
          },
          "externalId": {
            "type": "string",
            "maxLength": 100
          },
          "name": {
            "type": "string",
            "maxLength": 100
          },
          "phone": {
            "type": "string",
            "example": "0501234567"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "taxId": {
            "type": "string",
            "pattern": "^\\d{1,9}$",
            "description": "ח.פ or ת.ז, printed on the document. Required on an invoice that needs an approval number."
          },
          "companyName": {
            "type": "string",
            "maxLength": 100
          }
        }
      },
      "Item": {
        "type": "object",
        "required": [
          "description",
          "price"
        ],
        "properties": {
          "description": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "quantity": {
            "type": "number",
            "minimum": 0.001,
            "default": 1
          },
          "price": {
            "type": "number",
            "minimum": 0,
            "description": "Unit price in shekels, VAT included unless vatIncluded is false."
          },
          "vatIncluded": {
            "type": "boolean",
            "default": true
          }
        }
      },
      "Payment": {
        "type": "object",
        "required": [
          "method",
          "amount"
        ],
        "properties": {
          "method": {
            "$ref": "#/components/schemas/PaymentMethod"
          },
          "amount": {
            "type": "number",
            "minimum": 0.01
          },
          "date": {
            "type": "string",
            "format": "date",
            "example": "2026-11-01",
            "description": "Today when left out."
          },
          "bank": {
            "type": "string"
          },
          "branch": {
            "type": "string"
          },
          "accountNumber": {
            "type": "string"
          },
          "chequeNumber": {
            "type": "string"
          },
          "reference": {
            "type": "string",
            "description": "A transfer or app payment reference (אסמכתא)."
          },
          "installments": {
            "type": "integer",
            "minimum": 1,
            "maximum": 36
          },
          "cardLast4": {
            "type": "string",
            "pattern": "^\\d{4}$"
          },
          "confirmationCode": {
            "type": "string"
          },
          "appName": {
            "type": "string",
            "example": "bit"
          }
        }
      },
      "SendTo": {
        "type": "object",
        "required": [
          "email"
        ],
        "properties": {
          "email": {
            "type": "string",
            "format": "email"
          },
          "name": {
            "type": "string",
            "maxLength": 100
          }
        }
      },
      "CreateDocument": {
        "type": "object",
        "required": [
          "type",
          "items"
        ],
        "properties": {
          "type": {
            "$ref": "#/components/schemas/DocumentType"
          },
          "date": {
            "type": "string",
            "format": "date",
            "example": "2026-11-01",
            "description": "Today or earlier, Israel time. Today when left out."
          },
          "customer": {
            "$ref": "#/components/schemas/CustomerRef"
          },
          "items": {
            "type": "array",
            "minItems": 1,
            "maxItems": 200,
            "items": {
              "$ref": "#/components/schemas/Item"
            }
          },
          "discount": {
            "type": "number",
            "minimum": 0,
            "description": "Shekels off the total, VAT included."
          },
          "round": {
            "type": "boolean",
            "description": "Round the total down to a whole shekel."
          },
          "payments": {
            "type": "array",
            "maxItems": 20,
            "items": {
              "$ref": "#/components/schemas/Payment"
            },
            "description": "Required on receipt and invoice_receipt, and must add up to the total. Refused on the other types."
          },
          "note": {
            "type": "string",
            "maxLength": 1000
          },
          "send": {
            "$ref": "#/components/schemas/SendTo"
          }
        }
      },
      "Document": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "type": {
            "$ref": "#/components/schemas/DocumentType"
          },
          "typeCode": {
            "type": "string",
            "description": "The Tax Authority's code (400, 305...)."
          },
          "number": {
            "type": "integer"
          },
          "date": {
            "type": "string",
            "format": "date",
            "example": "2026-11-01"
          },
          "status": {
            "type": "string",
            "enum": [
              "issued",
              "cancelled"
            ]
          },
          "customer": {
            "type": "object",
            "properties": {
              "id": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "name": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "taxId": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "companyName": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          },
          "items": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "description": {
                  "type": "string"
                },
                "quantity": {
                  "type": "number"
                },
                "unitPrice": {
                  "type": "number"
                },
                "vatIncluded": {
                  "type": "boolean"
                }
              }
            }
          },
          "discount": {
            "type": "number"
          },
          "total": {
            "type": "number",
            "description": "VAT included."
          },
          "vat": {
            "type": "number"
          },
          "totalBeforeVat": {
            "type": "number"
          },
          "currency": {
            "type": "string",
            "example": "ILS"
          },
          "payments": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "method": {
                  "$ref": "#/components/schemas/PaymentMethod"
                },
                "amount": {
                  "type": "number"
                },
                "date": {
                  "type": "string",
                  "format": "date",
                  "example": "2026-11-01"
                }
              }
            }
          },
          "approvalNumber": {
            "type": [
              "string",
              "null"
            ],
            "description": "The Tax Authority's allocation number (מספר הקצאה)."
          },
          "approvalNumberStatus": {
            "type": "string",
            "enum": [
              "not_needed",
              "successfully_got",
              "failed_to_get",
              "waiting_for_customer_decision"
            ]
          },
          "note": {
            "type": [
              "string",
              "null"
            ]
          },
          "pdfUrl": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri",
            "description": "null in test mode."
          },
          "shareUrl": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "test": {
            "type": "boolean",
            "description": "Only with a test key: always true."
          }
        }
      },
      "DocumentList": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Document"
            }
          },
          "page": {
            "type": "integer"
          },
          "perPage": {
            "type": "integer"
          },
          "hasMore": {
            "type": "boolean"
          },
          "test": {
            "type": "boolean",
            "description": "Only with a test key: always true."
          }
        }
      },
      "CreateCustomer": {
        "type": "object",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "phone": {
            "type": "string"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "taxId": {
            "type": "string",
            "pattern": "^\\d{1,9}$"
          },
          "companyName": {
            "type": "string",
            "maxLength": 100
          },
          "address": {
            "type": "string",
            "maxLength": 200
          },
          "externalId": {
            "type": "string",
            "maxLength": 100
          }
        }
      },
      "Customer": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "phone": {
            "type": [
              "string",
              "null"
            ]
          },
          "email": {
            "type": [
              "string",
              "null"
            ]
          },
          "taxId": {
            "type": [
              "string",
              "null"
            ]
          },
          "companyName": {
            "type": [
              "string",
              "null"
            ]
          },
          "address": {
            "type": [
              "string",
              "null"
            ]
          },
          "externalId": {
            "type": [
              "string",
              "null"
            ]
          },
          "existing": {
            "type": "boolean",
            "description": "On POST /customers: true when it was already a customer."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "test": {
            "type": "boolean",
            "description": "Only with a test key: always true."
          }
        }
      },
      "CustomerList": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Customer"
            }
          },
          "page": {
            "type": "integer"
          },
          "perPage": {
            "type": "integer"
          },
          "hasMore": {
            "type": "boolean"
          }
        }
      }
    }
  }
}