---
title: "Order flow: quote to invoice"
description: "Chain quote, purchase order, sales order and invoice through POST /v1/documents/send with orderReference, confirm orders with the lifecycle, list invoices per purchase order and react to document.received and lifecycle.updated webhooks."
canonical: "https://docs.get-flowie.com/guides/order-flow"
source: "https://docs.get-flowie.com/guides/order-flow.html"
---

# Order flow: quote to invoice

Guides

# Order flow: quote → purchase order → sales order → invoice

Quotes, purchase orders, sales orders and invoices all go through the same `POST /v1/documents/send` and the same lifecycle, chained by one field: `orderReference`.

For
    Mid-market · Large group — Buyers and Sellers trading with orders

Time
    ≈ 30 min in sandbox

You need
    Two sandbox keys, one per side ([get one](<../sandbox/keys.html>))

Updated
    30 Nov 2026

Do you need this guide?

  * **Small business** — if you invoice without purchase orders, you don't. Start with [Send an invoice](<send-invoice.html>). If a customer gives you a PO number, put it in `orderReference` on the invoice and stop there.
  * **Mid-market** — send orders from your ERP the same way you send invoices ([Connect your ERP](<erp-integration.html>)), and use this guide to chain them.
  * **Large group** — the same flow per entity; each entity sends with its own key or through a platform key ([Multi-entity groups](<multi-entity.html>)).



## The order document types

Only `type` and the reference change between them. Every type accepts the same payload shapes (JSON, XML, file).

`type`| Who sends it| What it says  
---|---|---  
`quote`| Seller → buyer| An offer: lines, prices, validity.  
`purchase-order`| Buyer → seller| The buyer commits to buy.  
`sales-order`| Seller → buyer| The seller's order confirmation.  
`goods-receipt`| Buyer| What was actually received.  
`invoice` · `credit-note` · `debit-note`| Seller → buyer| The bill, and its corrections.  
  
## How the documents are chained

Each document points at the one before it with `document.orderReference`. It is the only order-reference field the API has (BT-13, rendered as `cac:OrderReference`):

  * on the **purchase order** , `orderReference` carries the **quote** number it accepts;
  * on the **sales order** , **goods receipt** and **invoice** , it carries the **purchase order** number.


[code] 
    quote           QUO-2026-0042   seller → buyer
      │
    purchase-order  PO-2026-9988    buyer → seller   orderReference: "QUO-2026-0042"
      │  seller sets the PO to approved (= order confirmed)
    sales-order     SO-2026-0107    seller → buyer   orderReference: "PO-2026-9988"
      │
    invoice         INV-2026-0311   seller → buyer   orderReference: "PO-2026-9988"
      │  buyer: received → approved → paid
[/code]

Because every document after the PO carries the PO number, you can list everything billed against an order in one call ([step 4](<#reconcile>)).

## 1 · Send the quote (seller)

The seller sends the quote like an invoice, with `"type": "quote"`. In this guide the seller is the sandbox test company `vat:BE0000000001` and the buyer is `vat:FR12345678901`.
[code] 
    curl -X POST https://back.flowie.ink/exchange/v1/documents/send \
      -H "Authorization: Bearer $FLOWIE_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "type": "quote",
        "format": "json",
        "from": "vat:BE0000000001",
        "to": "vat:FR12345678901",
        "document": {
          "number": "QUO-2026-0042",
          "issueDate": "2026-11-30",
          "currency": "EUR",
          "lines": [
            { "description": "Consulting", "quantity": 10, "unitPrice": 150.00, "vatRate": 20 }
          ]
        }
      }'
[/code]

Expected response — `201 Created`:
[code] 
    {
      "id": "doc_sbx_…",
      "status": "sent",
      "type": "quote",
      "number": "QUO-2026-0042",
      "deliveryStatus": "delivered",
      "sentAt": "2026-11-30T09:12:44Z"
    }
[/code]

`status: "sent"` means Flowie accepted the document. `deliveryStatus` is its state on the network: `pending` in production until the recipient's side confirms, then `delivered` or `failed`; the sandbox answers `delivered` straight away.

## 2 · Send the purchase order (buyer)

The buyer, with its own key, accepts the quote by sending a purchase order whose `orderReference` is the quote number.
[code] 
    curl -X POST https://back.flowie.ink/exchange/v1/documents/send \
      -H "Authorization: Bearer $FLOWIE_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "type": "purchase-order",
        "format": "json",
        "from": "vat:FR12345678901",
        "to": "vat:BE0000000001",
        "document": {
          "number": "PO-2026-9988",
          "issueDate": "2026-11-30",
          "currency": "EUR",
          "orderReference": "QUO-2026-0042",
          "lines": [
            { "description": "Consulting", "quantity": 10, "unitPrice": 150.00, "vatRate": 20 }
          ]
        }
      }'
[/code]

The seller receives a `document.received` webhook whose `data.type` is `PURCHASE_ORDER` (see [webhooks](<#webhooks>)).

## 3 · Confirm (or refuse) the order (seller)

Orders use the same lifecycle statuses as invoices. There is no separate "confirmed" or "fulfilled" status: the seller **confirms** a purchase order by moving it to `approved`, and **refuses** it with `rejected` plus a `reasonCode`. Fulfilment shows up as the next documents in the chain — the sales order, the goods receipt and the invoice that carry the PO number.
[code] 
    curl -X POST https://back.flowie.ink/exchange/v1/documents/{documentId}/lifecycle \
      -H "Authorization: Bearer $FLOWIE_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "status": "approved",
        "note": "Order confirmed, delivery week 50"
      }'
[/code]

Expected response — `200`:
[code] 
    {
      "documentId": "doc_…",
      "previousStatus": "received",
      "currentStatus": "approved",
      "updatedAt": "2026-11-30T09:20:03Z",
      "compliance": {},
      "allowedTransitions": ["partially_paid", "paid", "disputed"]
    }
[/code]

To refuse instead: `{"status": "rejected", "reasonCode": "PRI", "reason": "Unit price differs from quote QUO-2026-0042"}`. `rejected` is final. The full state machine and reason codes are in the [lifecycle reference](<../reference/index.html#update-lifecycle>).

Then the seller sends its `sales-order` (and, after delivery, the `invoice`) exactly like step 1, with `"orderReference": "PO-2026-9988"`:
[code] 
    curl -X POST https://back.flowie.ink/exchange/v1/documents/send \
      -H "Authorization: Bearer $FLOWIE_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "type": "invoice",
        "format": "json",
        "from": "vat:BE0000000001",
        "to": "vat:FR12345678901",
        "document": {
          "number": "INV-2026-0311",
          "issueDate": "2026-11-30",
          "dueDate": "2026-12-30",
          "currency": "EUR",
          "orderReference": "PO-2026-9988",
          "lines": [
            { "description": "Consulting", "quantity": 10, "unitPrice": 150.00, "vatRate": 20 }
          ]
        }
      }'
[/code]

## 4 · Match invoices to the order

Either side lists every invoice billed against a purchase order by its number — the value the invoices carry in `orderReference`. It answers "what has been invoiced on this order so far?" and is the starting point of your own PO ↔ invoice match. An order with nothing billed returns an empty list, not a `404`.
[code] 
    curl https://back.flowie.ink/exchange/v1/purchase-orders/PO-2026-9988/invoices \
      -H "Authorization: Bearer $FLOWIE_API_KEY"
[/code]

Expected response — `200` (paginate with `cursor` while `hasMore` is true):
[code] 
    {
      "data": [
        {
          "id": "doc_…",
          "type": "INVOICE",
          "number": "INV-2026-0311",
          "issueDate": "2026-11-30",
          "currency": "EUR",
          "amount": 1800.0,
          "status": "received",
          "direction": "incoming"
        }
      ],
      "hasMore": false,
      "cursor": null
    }
[/code]

For line-level checks (quantities and prices against the PO), read each document with [`GET /v1/documents/{documentId}/structured`](<../reference/index.html#document-structured>) and compare in your system. If an invoice doesn't match, the buyer can put it on hold with `disputed` (reason `QTY` or `PRI`) or refuse it with `rejected`.

## Webhooks for orders

Orders fire the same events as invoices. Two matter most:

  * `document.received` — a quote, PO, sales order or invoice arrived. `data.type` says which: `QUOTE`, `PURCHASE_ORDER`, `SALES_ORDER`, `GOODS_RECEIPT`, `INVOICE`…
  * `lifecycle.updated` — a status changed, for example the seller confirmed your PO. `data.currentStatus` is the new status (`approved` = confirmed, `rejected` = refused), with `data.previousStatus`, `data.reasonCode` and `data.reason`. The event carries `data.documentId` but not the document type: look it up in your own records, or with [`GET /v1/documents/{documentId}`](<../reference/index.html#get-document>).



Subscriptions are per event, not per document type, so filter on `data.type` in your handler:
[code] 
    curl -X POST https://back.flowie.ink/exchange/v1/webhooks \
      -H "Authorization: Bearer $FLOWIE_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "url": "https://yourapp.example.com/hooks/orders",
        "events": ["document.received", "lifecycle.updated"]
      }'
[/code]
[code] 
    ORDER_TYPES = {"QUOTE", "PURCHASE_ORDER", "SALES_ORDER", "GOODS_RECEIPT"}
    
    def handle(event: dict) -> None:
        # Verify X-Flowie-Signature first: see the webhooks reference.
        data = event["data"]
        if event["type"] == "document.received" and data["type"] in ORDER_TYPES:
            print("order document in:", data["type"], data["number"])
        elif event["type"] == "lifecycle.updated":
            if data["currentStatus"] == "approved":
                print("confirmed / approved:", data["documentId"])
            elif data["currentStatus"] == "rejected":
                print("refused:", data["documentId"], data.get("reasonCode"), data.get("reason"))
[/code]

Payloads, signature check and retry schedule: [Webhooks reference](<../reference/webhooks.html>).

## Errors you may hit

Status / code| What it means| Fix  
---|---|---  
`400` `INVALID_REQUEST`| A field failed validation, or `to` is missing.| Read `details[]` and fix the body.  
`400` `invalid_transition`| The lifecycle move isn't allowed from the current status (for example, approving a PO that is already `rejected`).| Read `allowedTransitions` from [`GET /v1/documents/{documentId}/lifecycle`](<../reference/index.html#get-lifecycle>).  
`400` `REASON_CODE_REQUIRED`| `rejected` or `disputed` sent without a `reasonCode`.| Add a [reason code](<../reference/index.html#reason-codes>) and a free-text `reason`.  
`403` `COMPANY_FORBIDDEN`| `from` is a company your key can't act for — typically the buyer's PO sent with the seller's key.| Send each side with its own key.  
`404` `DOCUMENT_NOT_FOUND`| Unknown document id, or not one your organization is a party to.| Use the `id` from the send response or the webhook.  
`422` `RECIPIENT_CANNOT_RECEIVE`| The counterparty doesn't accept this document type.| Agree another channel for orders with that counterparty.  
  
## Test in sandbox

Create one sandbox key per side ([API keys](<../sandbox/keys.html>)) and register the two test companies with [`POST /v1/companies`](<../reference/index.html#create-company>): `BE0000000001` as the seller, `FR12345678901` as the buyer. Then run steps 1 to 4, switching keys between seller and buyer calls. Lifecycle changes on your sandbox documents behave as in production; to move a document forward on a timeline, use [time travel](<../sandbox/index.html#test-clock>).

## Next steps

  * [Connect your ERP](<erp-integration.html>) — send orders and invoices from D365, SAP, NetSuite…
  * [Receive invoices](<receive-invoices.html>) — the buyer side, end to end.
  * [Purchase orders reference](<../reference/index.html#purchase-orders>) — listing invoices per order.
  * [Webhooks reference](<../reference/webhooks.html>) — events, signatures, retries.
