---
title: "Track the invoice lifecycle"
description: "Track an e-invoice from received to paid with the Flowie Exchange API: the nine lifecycle statuses and their allowed transitions, POST /v1/documents/{documentId}/lifecycle, the lifecycle.updated webhook, and France"
canonical: "https://docs.get-flowie.com/guides/lifecycle"
source: "https://docs.get-flowie.com/guides/lifecycle.html"
---

# Track the invoice lifecycle

Guides

# Track the invoice lifecycle, end to end

Every document carries a lifecycle status — received, approved, refused, paid… — that you read and move with one endpoint, and that Flowie reports to the tax authority where the law requires it.

For
    Small business · Mid-market · Large group · Platform — Buyers and Sellers

Time
    ≈ 20 min in sandbox

You need
    A sandbox key ([get one](<../sandbox/keys.html>)) and a document id

Updated
    30 Nov 2026

## Buyer or seller? Who moves what

Each party has its own status on the same document: the buyer decides on the invoice, the seller records that it was paid.

You are| You send| Typical trigger  
---|---|---  
**Buyer** (you receive supplier invoices)| `under_review`, `approved`, `disputed`, `rejected`, `paid`| Your AP team or approval workflow takes the invoice in, approves, contests, refuses, then pays it.  
**Seller** (you issue invoices)| `partially_paid`, `paid`| The money reaches your bank account (fully or partly).  
**Both**|  Each set above, on the documents where you hold that role| —  
  
A small business can do all of this from its accounting tool or by hand; a group usually wires it to the ERP's approval and payment runs; a platform sends it on behalf of each managed company.

## 1 · The statuses and the allowed moves

The happy path is `received → under_review → approved → paid`. Any other move is checked against the table below; an illegal one is refused with `400`.

Status| Meaning| Can move to  
---|---|---  
`draft`| Not yet issued.| `under_review`, `approved`, `rejected`, `received`, `failed`  
`received`| Delivered to the buyer.| `under_review`, `approved`, `rejected`, `failed`  
`under_review`| The buyer is processing it.| `approved`, `rejected`, `failed`  
`approved`| The buyer accepts it.| `partially_paid`, `paid`, `disputed`  
`partially_paid`| Part of the amount is paid.| `paid`, `disputed`  
`disputed`| Contested, but still alive.| `approved`, `rejected`  
`rejected`| Refused by the buyer (business decision).| — terminal  
`failed`| Rejected for a technical or format reason.| — terminal  
`paid`| Paid in full.| — terminal  
  
Prefer reversible statuses

`rejected` is final: the seller must issue a corrective document. If the problem may still be solved, send `disputed` first — it can go back to `approved`. 

Your organization's lifecycle can be configured with its own stages, so the moves really available for a document are the ones listed in its `allowedTransitions`: read them before you offer an action in your UI.

## 2 · Read where a document stands
[code] 
    curl https://back.flowie.ink/exchange/v1/documents/{documentId}/lifecycle \
      -H "Authorization: Bearer $FLOWIE_API_KEY"
[/code]

Expected response:
[code] 
    {
      "documentId": "doc_01HY7AB9C2DE3FG",
      "currentStatus": "under_review",
      "currentStatusAt": "2026-11-30T09:12:03Z",
      "compliance": {},
      "history": [
        {"status": "received", "at": "2026-11-30T09:02:41Z", "setBy": "system", "note": null, "reported": false, "reportedTo": null, "reportedAt": null},
        {"status": "under_review", "at": "2026-11-30T09:12:03Z", "setBy": "usr_5f2a", "note": "Awaiting PO match", "reported": false, "reportedTo": null, "reportedAt": null}
      ],
      "allowedTransitions": ["approved", "rejected", "failed"]
    }
[/code]

`history` is the audit trail (who set which status, when); `reported` and `reportedTo` show whether a change was sent to a tax authority.

## 3 · Move the document to a new status

One call, with the target `status` and an optional `note`. Here a buyer approves an invoice:
[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": "Matched to purchase order PO-7731"}'
[/code]

Expected response:
[code] 
    {
      "documentId": "doc_01HY7AB9C2DE3FG",
      "previousStatus": "under_review",
      "currentStatus": "approved",
      "updatedAt": "2026-11-30T10:32:18Z",
      "compliance": {},
      "allowedTransitions": ["partially_paid", "paid", "disputed"]
    }
[/code]

Other bodies you will send to the same endpoint:

**Buyer — refuse** (a `reasonCode` is required for `rejected` and `disputed`; use a [status reason code](<../reference/index.html#reason-codes>) and say in `reason` exactly what to fix):
[code] 
    {"status": "rejected", "reasonCode": "PRI", "reason": "Unit price on line 3 does not match the quote"}
[/code]

**Buyer — contest without refusing:**
[code] 
    {"status": "disputed", "reasonCode": "QTY", "reason": "12 units delivered, 15 invoiced"}
[/code]

**Seller — payment received** (a buyer sends the same body when its payment goes out):
[code] 
    {
      "status": "paid",
      "paymentDate": "2026-11-30",
      "paymentAmount": 1815.00,
      "paymentCurrency": "EUR",
      "paymentReference": "PAY-2026-0042"
    }
[/code]

**Seller — partial payment:**
[code] 
    {
      "status": "partially_paid",
      "paymentDate": "2026-11-30",
      "paymentAmount": 1000.00,
      "paymentCurrency": "EUR",
      "remainingAmount": 815.00
    }
[/code]

Many documents at once? `POST /v1/documents/lifecycle/batch` takes the same bodies — see the [batch reference](<../reference/index.html#batch-lifecycle>).

## 4 · Keep your system in sync

Each transition you make through the API emits `lifecycle.updated` to your webhooks:
[code] 
    {
      "id": "evt_01HY3AB9C2DE3FG",
      "type": "lifecycle.updated",
      "livemode": true,
      "createdAt": "2026-11-30T10:32:18Z",
      "data": {
        "documentId": "doc_01HY7AB9C2DE3FG",
        "previousStatus": "under_review",
        "currentStatus": "approved",
        "at": "2026-11-30T10:32:18Z",
        "setBy": {"type": "api_key", "userId": null, "email": null},
        "reason": null,
        "reasonCode": null,
        "compliance": null
      }
    }
[/code]

A status change you did not make through the API — by the counterparty, in the Flowie app or by an automated flow — reaches you as `document.updated`, with `status` in its `changes`. Subscribe to both. A minimal handler that verifies the signature and stores the new status:
[code] 
    import hashlib, hmac, json, os, time
    from fastapi import FastAPI, HTTPException, Request, Response
    
    app = FastAPI()
    SECRET = os.environ["FLOWIE_WEBHOOK_SECRET"].encode()
    
    
    def verify(raw: bytes, header: str) -> None:
        parts = dict(p.split("=", 1) for p in header.split(",") if "=" in p)
        t, v1 = parts.get("t", "0"), parts.get("v1", "")
        try:  # a malformed header is a 400, never a 500
            stale = abs(time.time() - int(t)) > 300
            expected = hmac.new(SECRET, t.encode() + b"." + raw, hashlib.sha256).hexdigest()
            valid = hmac.compare_digest(expected.encode(), v1.encode())
        except (ValueError, UnicodeEncodeError):
            raise HTTPException(400, "bad signature")
        if stale:
            raise HTTPException(400, "stale signature")
        if not valid:
            raise HTTPException(400, "bad signature")
    
    
    @app.post("/hooks/flowie")
    async def hook(request: Request):
        raw = await request.body()
        verify(raw, request.headers.get("X-Flowie-Signature", ""))
        event = json.loads(raw)
        if event["type"] == "lifecycle.updated":
            d = event["data"]
            save_status(d["documentId"], d["currentStatus"], d["at"])  # your own persistence
        return Response(status_code=204)
[/code]

Payloads, retries and the signature recipe: [webhooks reference](<../reference/webhooks.html#events>).

## 5 · France and Italy: reported for you

When the seller is French or Italian, Flowie reports each lifecycle change to the tax authority (PPF in France, SDI in Italy). You make the same call; the response's `compliance` shows the report was dispatched:
[code] 
    {
      "documentId": "doc_01HY7AB9C2DE3FG",
      "previousStatus": "under_review",
      "currentStatus": "rejected",
      "updatedAt": "2026-11-30T10:40:02Z",
      "compliance": {
        "FR": {
          "platform": "PPF",
          "status": "dispatched",
          "willEmit": ["compliance.reported", "compliance.reported.failed"]
        }
      },
      "allowedTransitions": []
    }
[/code]

The outcome arrives as a `compliance.reported` webhook, or `compliance.reported.failed` if the authority refused it:
[code] 
    {
      "id": "evt_01HY3AC4D5EF6GH",
      "type": "compliance.reported",
      "livemode": true,
      "createdAt": "2026-11-30T10:40:05Z",
      "data": {
        "documentId": "doc_01HY7AB9C2DE3FG",
        "platform": "PPF",
        "status": "reported",
        "reportId": "rpt_…",
        "platformResponse": {"code": "…", "message": "…"},
        "transmissionId": "…",
        "lifecycleStatus": "rejected",
        "transient": false,
        "remediationDocUrl": null
      }
    }
[/code]

In France each status maps to an official code:

You send| France| Who  
---|---|---  
`under_review`| 204 Prise en charge| Buyer  
`approved` (with `remainingAmount`: 206)| 205 Approuvée| Buyer  
`disputed` (with `reasonCode` `suspended`: 208 Suspendue)| 207 En litige| Buyer  
`rejected`| **210 Refusée** — the buyer refuses the invoice; mandatory| Buyer  
`paid`| 211 Paiement transmis| Buyer  
`paid` / `partially_paid`| **212 Encaissée** ; mandatory| Seller  
`failed`| **213 Rejetée** — technical rejection by the platform| Flowie, not you  
  
Refusal or rejection? [210 vs 213, with examples](<../compliance/fr/refusal-rejection.html>) · all statuses: [French lifecycle](<../compliance/fr/lifecycle.html>).

## Try it in the sandbox

Send a document to `0208:TEST_OK` (see [go-live, step 1](<go-live.html#sandbox>)) and keep the `doc_sbx_…` id. A sandbox document starts in `received`: send `approved`, then `paid`, then try `approved` again to see the `400` on an illegal move. Sandbox documents check the same transitions; webhooks and tax-authority reporting are not simulated on them.

## Errors you may hit

Status / code| What it means| Fix  
---|---|---  
`400` `Transition from 'paid' to 'approved' is not allowed`| The target is not a legal next status.| Read `allowedTransitions` with `GET …/lifecycle`.  
`400` `REASON_CODE_REQUIRED`| `rejected` or `disputed` without `reasonCode`. Nothing was written.| Add a [reason code](<../reference/index.html#reason-codes>) and a `reason`.  
`400` `Status '…' has no equivalent in the lifecycle configured for this document`| Your organization's lifecycle has no stage for that status.| Use one of the statuses the message lists.  
`404`| Unknown document id, or not visible to your organization.| Check the id and the key's organization.  
`compliance.reported.failed`| The tax authority refused the report.| Read `platformResponse.code`; `transient: true` means a temporary failure on its side — see [compliance errors](<../reference/errors.html#compliance-errors>).  
  
## Next steps

  * [Receive invoices](<receive-invoices.html>) — where buyer statuses start.
  * [Go live](<go-live.html>) — from sandbox to production.
  * [France: who owes which status](<../compliance/fr/integration.html#lifecycle>).
  * [Lifecycle endpoint reference](<../reference/index.html#update-lifecycle>).
