Developers
Guides

Create an invoice

From the customer to the validated invoice: lines, taxes, currency, idempotency and totals.

This guide creates a sales invoice end to end: find the customer and the articles, create the document with no risk of duplicate, validate it, record its payment. You need a key with partners:read, articles:read, sales:write and payments:write (or Read & write).

The API computes nothing on its own: every write goes through the service the application uses. Numbering, totals, taxes, customer pricing, capped discounts and status transitions are exactly those of the screen.

1. Find the customer

Look the record up by email (or tax ID, taxId). role=CLIENT also returns mixed customer-supplier records:

GET/partners

curl 'https://quosuite.com/api/public/v1/quosuite/partners?role=CLIENT&email=contact%40exemple.tn' \
  -H "Authorization: Bearer $QUOSUITE_API_KEY"

Missing? Create it — type and name are enough, the code is assigned by the series:

POST/partners

# One key per operation, reused as is on every retry.
curl -X POST 'https://quosuite.com/api/public/v1/quosuite/partners' \
  -H "Authorization: Bearer $QUOSUITE_API_KEY" \
  -H 'Idempotency-Key: 3f1c2a9e-5b7d-4e8a-9c1f-2d6b8e4a7c30' \
  -H 'Content-Type: application/json' \
  -d '{
  "type": "CLIENT",
  "name": "Société Exemple SARL",
  "email": "contact@exemple.tn",
  "country": "TN",
  "paymentTermsDays": 30
}'

2. Find the articles

A line that references an article may omit label, price and VAT: they are taken from the article record, and the customer’s pricing applies. Find the identifier by reference (or barcode, barcode):

GET/articles

curl 'https://quosuite.com/api/public/v1/quosuite/articles?reference=PC-14-PRO' \
  -H "Authorization: Bearer $QUOSUITE_API_KEY"

3. Create the invoice

Always send an Idempotency-Key: if the response gets lost (timeout, network cut), you retry with the same key and the API replays the first response instead of creating a second invoice.

POST/sales/invoices

# One key per operation, reused as is on every retry.
curl -X POST 'https://quosuite.com/api/public/v1/quosuite/sales/invoices' \
  -H "Authorization: Bearer $QUOSUITE_API_KEY" \
  -H 'Idempotency-Key: 3f1c2a9e-5b7d-4e8a-9c1f-2d6b8e4a7c30' \
  -H 'Content-Type: application/json' \
  -d '{
  "partnerId": "11111111-1111-4111-8111-111111111111",
  "date": "2026-09-15",
  "dueDate": "2026-10-15",
  "reference": "CMD-778",
  "lines": [
    {
      "articleId": "aaaaaaaa-0000-4000-8000-000000000010",
      "quantity": 2
    },
    {
      "label": "Installation",
      "quantity": 1,
      "unitPrice": 50,
      "vatRate": 19,
      "discount": {
        "value": 10,
        "unit": "PCT"
      }
    }
  ]
}'

The 201 response returns the full document, computed by the ERP:

JSON
{
  "success": true,
  "data": {
    "id": "5b0e7c1a-2f3d-4e8b-9a6c-1d2e3f4a5b6c",
    "kind": "invoice",
    "number": "FAC-2026-0001",
    "status": "DRAFT",
    "currency": "TND",
    "exchangeRate": 1,
    "totals": { "totalExclTax": 245, "totalVat": 46.55, "totalInclTax": 292.55, "paidAmount": 0, "balanceDue": 292.55 },
    "lines": [ "…" ],
    "taxes": [],
    "reference": "CMD-778"
  },
  "timestamp": "2026-09-15T09:15:00.000Z"
}

Good to know:

  • Number: when omitted, the next one of the invoice series. If imposed (number), it must be free.
  • Footer taxes (stamp duty, FODEC…): those configured for invoices apply automatically; taxIds replaces them, [] sets none. They are detailed in taxes, and totalInclTax = excl. tax + VAT + footer taxes outside VAT.
  • Currency: the workspace base currency by default; another currency (currency, exchangeRate) requires the Multi-currency option (402 otherwise).
  • Initial status: DRAFT by default. "status": "VALIDATED" issues the invoice right away and saves you the next step.
  • Grouped invoicing: deliveryNoteIds takes over issued delivery notes of the same customer, which move to INVOICED.
  • Quota: the creation counts towards the plan’s monthly document quota (402 PLAN_QUOTA_EXCEEDED when reached).

4. Validate the invoice

A draft can be changed freely (PATCH, where a provided lines replaces all the lines). Once ready, issue it:

POST/sales/invoices/{id}/status

curl -X POST 'https://quosuite.com/api/public/v1/quosuite/sales/invoices/5b0e7c1a-2f3d-4e8b-9a6c-1d2e3f4a5b6c/status' \
  -H "Authorization: Bearer $QUOSUITE_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "status": "VALIDATED"
}'

Transitions are those of the ERP: a forbidden transition answers 422 BUSINESS_RULE_VIOLATION. PARTIALLY_PAID and PAID are never set by hand — they result from payments.

5. Record the payment

A receipt is allocated to one or more documents (allocations). The invoice status follows: PARTIALLY_PAID, then PAID when balanceDue reaches 0. Here too, the Idempotency-Key is essential: a replayed payment would count twice.

POST/payments

# One key per operation, reused as is on every retry.
curl -X POST 'https://quosuite.com/api/public/v1/quosuite/payments' \
  -H "Authorization: Bearer $QUOSUITE_API_KEY" \
  -H 'Idempotency-Key: 3f1c2a9e-5b7d-4e8a-9c1f-2d6b8e4a7c30' \
  -H 'Content-Type: application/json' \
  -d '{
  "direction": "INBOUND",
  "method": "TRANSFER",
  "partnerId": "11111111-1111-4111-8111-111111111111",
  "amount": 292.55,
  "reference": "VIR-88231",
  "allocations": [
    {
      "documentId": "5b0e7c1a-2f3d-4e8b-9a6c-1d2e3f4a5b6c",
      "amount": 292.55
    }
  ]
}'

A cheque or a bill of exchange (method CHECK / DRAFT) also carries instrument (number, due date) and enters the instruments portfolio (GET /instruments), as PENDING. The payment covers the invoice at once (balanceDue drops to zero), but the invoice only becomes PAID — and invoice.paid is only sent — once the instrument is paid (CASHED); if it comes back unpaid and is cancelled (CANCELLED), the payment is reversed and the invoice becomes due again.

6. Next

  • Download the PDF of the invoice, in the customer’s language.
  • Get notified of payments made elsewhere (POS, screen, store): subscribe to invoice.paid and payment.created — see Receive webhooks.