Skip to content

Quotes & Invoices reference

Reference for the Quotes & Invoices endpoints. All paths start with https://<your-instance>/api/v1. Every request carries Authorization: Bearer hek_…. Formats, paging, deletion lists and error codes are on Conventions.

Reading needs read permission on the Quotes & Invoices module, every writing request needs write permission (otherwise 403 with no_write_permission).

What the API may do here

  • Read: every quote, order confirmation and invoice in every status, with lines, totals, numbers, payment reference and PDF.
  • Drafts: create, change and cancel drafts.
  • Catalogue: create, change, deactivate and delete articles.

Issuing stays in Hive Engine. Finalising (assigning the number and booking), reopening, storno, marking as paid, sending by email and quote response links are done by a person in the app. Nothing is booked through the API.

Formats in this module

  • Amounts are decimal strings. Totals have two places ("21.62"). Unit prices have at least two and at most four places ("4.50", "4.1234"). Quantities come without trailing zeros ("2", "0.5") and have at most 8 digits before the point.
  • VAT rates are fractions, not percentages: "0", "0.026", "0.038", "0.081". Other rates are refused with 422 (validation_error, the problem says invalid_vat_rate).
  • Numbers sent as JSON numbers (4.5 instead of "4.50") are refused with 422.

Documents

A sale is one document that moves from quote (Offerte) to order confirmation (Auftragsbestätigung) to invoice (Rechnung), exactly as in the app.

FieldValues
document_typeofferte, auftragsbestaetigung, invoice
statusdraft, finalised, paid, cancelled. More values may be added.
Line kindproduct, deduction, chapter, text, subtotal. More values may be added.

The numbers are in three fields: offer_number, order_confirmation_number and invoice_number. They are null while the document has no number. invoice_number is set only once the invoice is issued.

List documents

GET /api/v1/sales/documents

Parameters: status, document_type, crm_contact_id, invoice_date_from, invoice_date_to (YYYY-MM-DD), limit, cursor, updated_since. A change to a single line counts as a change to the whole document.

Terminal window
curl "https://<your-instance>/api/v1/sales/documents?status=finalised&updated_since=2026-11-01T00:00:00Z" \
-H "Authorization: Bearer hek_…"

Get a document

GET /api/v1/sales/documents/{document_id}

Response 200 OK:

{
"id": "8d1f3a52-6c47-4b0e-9a21-5e7c0b4d2f10",
"document_type": "invoice",
"status": "finalised",
"offer_number": "OF_2026110012",
"order_confirmation_number": "AB_2026110012",
"invoice_number": "RE_2026110012",
"crm_contact_id": "a7c2e9f1-3b5d-4f80-9e12-4d6b8a0c1e22",
"standing_order": false,
"billing": {
"name": "Anna Muster",
"company": "Bistro Sonnenblick",
"address_line1": "Seestrasse 12",
"address_line2": null,
"zip": "8002",
"city": "Zürich",
"country": "CH",
"email": "[email protected]"
},
"invoice_date": "2026-11-06",
"due_date": "2026-12-06",
"payment_terms_label": "Netto 30 Tage",
"currency": "CHF",
"notes": "Thank you for your order.",
"internal_notes": null,
"payment_reference": "RF18539007547034",
"totals": {
"subtotal": "20.00",
"total_vat": "1.62",
"total": "21.62",
"vat": [{"rate_label": "MwSt 8.1%", "net": "20.00", "vat": "1.62"}]
},
"lines": [
{
"position": 0,
"kind": "product",
"catalogue_item_id": "f3b9d2c4-8e61-4a07-b5d3-2c1e0f9a8b77",
"sku": "BRT-1",
"name": "Farmhouse bread",
"description": null,
"quantity": "2",
"unit": "Stk",
"unit_price": "10.00",
"vat_rate": "0.081",
"discount_kind": null,
"is_optional": false,
"response_status": null
}
],
"created_by": "API: ERP link",
"created_at": "2026-11-06T08:12:40+00:00",
"updated_at": "2026-11-06T09:30:05+00:00",
"finalised_at": "2026-11-06T09:30:05+00:00",
"sent_at": null,
"paid_at": null
}

If your business is not VAT-registered, the totals show no VAT: total_vat is "0.00", total equals subtotal, vat is empty. That is also what the PDF shows.

Create a draft

POST /api/v1/sales/documents (supports Idempotency-Key)

Fields: document_type (default invoice), billing (with name, required; country default CH), invoice_date (required), due_date, payment_terms_label (default Netto 30 Tage), currency (default CHF), crm_contact_id, standing_order, notes, internal_notes, lines.

A product line needs quantity and unit_price, a deduction needs unit_price and discount_kind (percent or amount). is_optional (optional line) exists only on a quote (offerte).

Terminal window
curl -X POST "https://<your-instance>/api/v1/sales/documents" \
-H "Authorization: Bearer hek_…" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: erp-order-4711" \
-d '{
"document_type": "offerte",
"crm_contact_id": "a7c2e9f1-3b5d-4f80-9e12-4d6b8a0c1e22",
"billing": {"name": "Anna Muster", "company": "Bistro Sonnenblick", "zip": "8002", "city": "Zürich"},
"invoice_date": "2026-11-06",
"lines": [
{"kind": "chapter", "name": "Bread"},
{"kind": "product", "catalogue_item_id": "f3b9d2c4-8e61-4a07-b5d3-2c1e0f9a8b77", "sku": "BRT-1",
"name": "Farmhouse bread", "quantity": "20", "unit": "Stk", "unit_price": "6.50", "vat_rate": "0.026"},
{"kind": "deduction", "name": "Volume discount", "unit_price": "5", "discount_kind": "percent"}
]
}'

Response 201 Created with the whole document in status draft. The author is your key’s name (API: …).

Change a draft

PATCH /api/v1/sales/documents/{document_id}

Send only the fields that change. In billing, the changed parts are enough. If you send lines, the list replaces all lines, [] removes them all. Without lines, the lines stay as they are. "lines": null is refused with 422.

Every draft can be changed, including a reopened invoice. It keeps its number, as in the app. A finalised, paid or cancelled document answers 409 with document_not_draft.

Cancel a draft

POST /api/v1/sales/documents/{document_id}/cancel

Sets a draft to cancelled. Finalised documents are cancelled in the app, because that reverses a booking (409 with document_not_draft).

Download a PDF

GET /api/v1/sales/documents/{document_id}/pdf?type=offerte

type is offerte, auftragsbestaetigung or invoice. Without type you get the document’s own type. The invoice PDF exists only once the document is finalised, otherwise 409 with invoice_pdf_not_available. The response is application/pdf.

Catalogue

Articles from the Quotes & Invoices catalogue. The SKU is unique per business. Whether your system or Hive Engine is the master of the articles is your choice. The last saved change wins, as between two people in the app.

Keeping the catalogue in sync: find an article with ?sku=, fetch changes with updated_since and deletions from the deletion list.

EndpointPurpose
GET /api/v1/sales/catalogue-itemsList. Parameters: sku, is_active, limit, cursor, updated_since
GET /api/v1/sales/catalogue-items/deleted?since=…Deleted articles
GET /api/v1/sales/catalogue-items/{catalogue_item_id}One article
POST /api/v1/sales/catalogue-itemsCreate (supports Idempotency-Key)
PATCH /api/v1/sales/catalogue-items/{catalogue_item_id}Change, including deactivating with "is_active": false
DELETE /api/v1/sales/catalogue-items/{catalogue_item_id}Delete. Existing documents keep SKU, name and price.

Fields: sku (required), name (required), description, unit (default Stk), unit_price (required), vat_rate (default "0"), is_active, discount_rules.

Terminal window
curl -X POST "https://<your-instance>/api/v1/sales/catalogue-items" \
-H "Authorization: Bearer hek_…" \
-H "Content-Type: application/json" \
-d '{"sku": "BRT-1", "name": "Farmhouse bread", "unit": "Stk", "unit_price": "6.50", "vat_rate": "0.026",
"discount_rules": [{"min_quantity": "10", "discount_pct": "5", "description": "from 10 pieces"}]}'

Response 201 Created:

{
"id": "f3b9d2c4-8e61-4a07-b5d3-2c1e0f9a8b77",
"sku": "BRT-1",
"name": "Farmhouse bread",
"description": null,
"unit": "Stk",
"unit_price": "6.50",
"vat_rate": "0.026",
"is_active": true,
"discount_rules": [{"min_quantity": "10", "discount_pct": "5", "description": "from 10 pieces"}],
"created_at": "2026-11-06T08:00:00+00:00",
"updated_at": "2026-11-06T08:00:00+00:00"
}

Settings

GET /api/v1/sales/settings returns what your system needs to send valid drafts: the number prefixes (prefixes with offerte, auftragsbestaetigung, invoice), vat_registered, the allowed vat_rates, default_payment_terms_label and default_currency. Settings cannot be changed through the API.

Error codes in this module

StatusCodeMeaning
409document_not_draftThe document is no longer a draft.
409sku_takenAnother article already has this SKU.
409invoice_pdf_not_availableInvoice PDF requested before finalising.
422validation_errorInvalid request, including a VAT rate that is not allowed (invalid_vat_rate).
422deduction_without_productA deduction has no product amount to deduct from in its section (since the last chapter or subtotal).
422optional_line_not_allowedOptional line on a document that is not a quote.
422standing_order_contact_requiredStanding order without a CRM contact.
404not_foundDocument, article or CRM contact does not exist (also: belongs to another business).

What’s next