Use case 02 · Quote to invoice
Turn an accepted quote into an invoice and supplier purchase orders
When a customer accepts a quote in your product, one AccountingKit workflow accepts the quote in Xero, creates the linked draft invoice, and creates one purchase order for each supplier. Every step is persisted. If a step fails, the workflow retries and resumes from that step, so the invoice and earlier purchase orders are never created twice.
How it works
Trigger
Your customer accepts a quote
Your product decides the quote is accepted and knows which suppliers need a purchase order.
Queue
Queue one recipe
Send the quote ID, your deal reference, and the purchase orders to create. Every purchase order is validated before any write reaches Xero. The API answers 202 with an operation ID.
POST /v1/automationsRun
The steps run in order and are saved
The workflow sends and accepts the quote, creates the invoice, marks the quote invoiced, then creates each purchase order as its own step.
send_quote · accept_quote · create_invoice · mark_quote_invoiced · create_purchase_order:<index>Finish
You get one signed result
A signed event tells you the run succeeded or failed. You can also read the operation at any time to see its state and attempts.
automation.succeeded
Who builds this
- Quoting and CPQ tools whose users keep their books in Xero.
- Order management and procurement products that buy from suppliers once a deal closes.
- Project and job management tools where an accepted quote starts both billing and purchasing.
The request
The purchase_orders array is optional. Leave it out and the recipe stops after the invoice.
curl --request POST "https://api.accountingkit.dev/v1/automations" \
--header "Authorization: Bearer $ACCOUNTINGKIT_API_KEY" \
--header "Idempotency-Key: accept-quote-814" \
--header "Content-Type: application/json" \
--data '{
"connection_id": "00000000-0000-0000-0000-000000000000",
"recipe": "quote.accept_and_create_invoice",
"input": {
"quote_resource_id": "00000000-0000-0000-0000-000000000000",
"external_reference": "deal_814",
"purchase_orders": [
{
"supplier_contact_id": "supplier-contact-id",
"line_items": [{"description": "Server hardware", "quantity": 2, "unit_amount": 1850}]
}
]
}
}'Events you receive
Events are signed. Verify the AccountingKit-Signature header against the raw body before you parse it, and deduplicate on the event ID.
| Event | When it is sent |
|---|---|
automation.succeeded | Every step completed. The run is metered once. |
automation.failed | The run could not complete. The operation record shows the failing step. |
quote.status_changed | A quote moved status during reconciliation, for example sent to accepted. |
Coverage by accounting system
The quote.accept_and_create_invoice recipe runs on Xero. On the other systems you can make the same writes one call at a time, with your own idempotency keys, wherever the table shows read and write.
| Capability | Xero | QuickBooks | NetSuite | Sage Intacct | FreshBooks | Wave |
|---|---|---|---|---|---|---|
| Quotes | Read and write | Not available | Read and write | Not available | Not available | Read only |
| Invoices | Read and write | Read and write | Read and write | Read and write | Read and write | Read and write |
| Purchase orders | Read and write | Read and write | Read and write | Read only | Not available | Not available |
When something goes wrong
A supplier purchase order fails
The workflow retries with backoff and resumes at that purchase order. The invoice and the purchase orders already created are left alone.
Retries run out
After the attempt limit, 8 by default, the operation moves to dead_letter. It stays visible in the API and the console instead of failing silently.
You fixed the cause and want to rerun
Replay the operation with a reason. The replay is written to the audit log and continues from the last completed step.
Your queue request is sent twice
The Idempotency-Key returns the same operation instead of starting a second workflow.
Limits to know first
- The recipe runs on Xero only.
- The invoice is created as a draft linked to the quote. Approving and sending it stays your decision.
- Automations need a cached connection. Zero-retention connections support live reads only.
Common questions
What happens if Xero fails halfway through the workflow?
Each completed step is saved. The workflow retries the failed step with backoff and continues from there, so a failure on the second purchase order does not create a second invoice or repeat the first purchase order.
Does the quote to invoice recipe work on QuickBooks Online or NetSuite?
No. The quote.accept_and_create_invoice recipe runs on Xero. Quote writes are also available on NetSuite, and purchase order writes on QuickBooks Online and NetSuite, so you can make those calls individually with the same idempotency guarantees.
How do I see where a workflow stopped?
Read GET /v1/operations/{operation_id}. It returns the state, the number of attempts, the attempt limit, and the error. The console shows the same record.
Am I billed for failed attempts?
No. An automation run is metered once, after it succeeds. Failed attempts do not create usage.