Purchasing and receiving
Purchase orders, goods receipts that move stock when you post them, three-way matching against the supplier invoice, and reorder suggestions.
The purchase side is the mirror of the sales side, with one difference that changes the whole integration: what arrives is not what you ordered until you say so. The purchase order records the intent, the goods receipt records the reality, and only posting a receipt moves stock.
Everything here lives under /companies/{company}/purchase-orders and
/companies/{company}/goods-receipts, gated by the purchase_orders module
(Avanzado plan upwards).
The purchase order life cycle
draft ──send──> sent ──confirm──> confirmed ──> partially_received ──> received ──> billed
│ │ │
└───────────────┴───────────────────┴──cancel──> cancelleddraftis the only editable and deletable state.sendemails the order to the supplier and moves it tosent. It is irreversible — the mail leaves. The body takesto, optionalccandbcc, andsubjectandbodyoverrides. Withsave_send_to_contact: true, the address intois saved on a supplier contact that has no email; a contact that already has one is never overwritten, and the option needs thecontacts:writescope on top of the one of the order (without it, 403insufficient_scope). Withouttoand without an email on the supplier record the answer is 422missing_required_paramwithparamto; with the recipient resolved, a mail that cannot be queued for delivery answers 500send_failed. In both cases nothing is saved and the order keeps its state.- If you placed the order by phone, use
mark as sentinstead: same state, no email. The body is optional:note(up to 200 characters, for example how it was sent) andsent_on(YYYY-MM-DD, the day you sent it, never later than today; without it the milestone carries today). confirmrecords that the supplier accepted. The optionalexpected_date(YYYY-MM-DD) is the delivery date the supplier gave and replaces the one of the order; one earlier than the order date is refused with the subcodepurchase_order_expected_date_invalid(paramexpected_date).- A
sentorder already admits receiving: posting a receipt against it confirms the order at that moment, solifecycle.confirmedis written and the eventpurchase_order.confirmedis emitted exactly as withconfirm. The receiving plan below reports it withneeds_confirmation. partially_receivedandreceivedare derived from the receipts, not set by hand.billedis terminal. It is reached fromreceivedonly when everything that was received has been invoiced by the matched supplier invoices; an order closed with pending quantity (below) reaches it at that moment if its invoices already cover what arrived.closecloses an order that has received goods. One received in full closes with an empty body, and repeating the call changes nothing. A partially received order closes only withreason(up to 500 characters): that is closing with pending quantity. Without it the call is refused with the subcodepurchase_order_short_close_reason_required(paramreason). The order staysreceived—there is no extra status—, its pending quantity drops to zero, it admits no further receipts, and it readsshort_closed: trueandshort_close(reasonandclosed_at). Closing is irreversible.cancelis terminal and takes an optionalreason(up to 500 characters), published inlifecycle.cancelled.reasonwith who cancelled and when. It has two guards checked before the state matrix. An order already billed is refused withpurchase_order_already_billed— what you correct there is the supplier invoice, not the order. An order with posted receipts is refused with the subcodepurchase_order_has_posted_receipts: goods that already came in are not undone by cancelling the paperwork that asked for them, so cancel the receipts first. The order tells you beforehand:can_cancelandcancel_blocked_reason(billed,posted_receiptsorterminal) apply the same guards, in the same order, as the operation itself.
Lines carry two pairs of quantities because the supplier may sell you in boxes
and you may stock in units: quantity / base_quantity for what was ordered,
received_quantity / received_base_quantity for what has arrived, and
pending_quantity / pending_base_quantity for what is still owed.
conversion_factor is what links the two, and it supports six decimals.
Each line also reads product_name, product_sku and variant_name from the
catalog, so a client can show it without another call, and
additional_description, the free text printed under the concept (null when
the line has none). invoiced_quantity and invoiced_base_quantity count what
the matched supplier invoices bill of the line, and rejected_quantity and
rejected_base_quantity what the posted receipts rejected.
Origin and life cycle in the resource
Every purchase order publishes two blocks, in the listing and the detail, and
the same body travels as data.object of the webhooks purchase_order.*:
origin: the channel that created the order,typemanual,reorder,importorapi, andcreated_by. The channel is set by the server: an order created through this API isapiwhatever the body says.lifecycle: who did what and when, one milestone each —created,sent,confirmed,cancelledandclosed— andnullwhile it has not happened.sentaddsvia(emailormanual),noteandon, the day declared by the buyer, which can differ fromat, the moment the call was registered.cancelledandclosedcarry thereasongiven.byisnullwhen a credential without a user wrote the milestone. The listing publisheslifecycleasnull; the detail fills it.
Reading the portfolio
The listing and the detail answer the questions of a purchasing desk without walking the lines:
fulfilment:received_percentandinvoiced_percent(one decimal, weighted by the base amount of each line; rejected goods do not count as received and only matched, not cancelled, invoices count as invoiced),pending_to_receiveandbillable_now(each withlines_countandamount),remaining_to_invoice_amount,invoice_match(none,pending,matchedordeviation),deviation_invoice,posted_receipts_countand, while the order ispartially_received,close_outcome: the status it would reach if it were closed now (billedorreceived).delivery:expected_date,is_overdue, and three mutually exclusive counters —days_overdue,days_until_dueanddays_in_grace— plusgrace_days. An order is overdue when it still waits for goods and its expected date is earlier than today minusgrace_days; inside the grace period it readsdays_in_graceand is not yet overdue.- Calculated actions:
can_edit,can_send,can_confirm,can_receive,can_cancel,can_closeandcan_delete, andnext_step(send,mark_sent,confirm,receive,link_invoiceorreview_match). invoices[]in the detail: up to 200 supplier invoices linked to the order, each with itsmatch_status,resolution,origin,deviated_lines,deviation_effect_with_tax,linked_atand, per order line,lines[]with what that invoice bills. The listing publishes it asnull.
purchase_orders.list
adds three filters that return exactly the rows each figure counts:
pending (receive or bill), delivery (late, week or none) and
invoice (none, pending, deviation or matched). The filter
warehouse_id matches the header of the order or any of its lines.
stats
adds portfolio with the same definitions: all, receive, late, bill
and draft, each with orders_count (and amount where it applies), and
grace_days. date_from and date_to bound the period of every figure.
The order also has a feed:
activities
returns, newest first and with cursor pagination, its own events plus those of
its goods receipts and of the supplier invoices linked to it, each with the
actor (a person or an API key) and the date.
Creating and editing a draft
The offer of a line is resolved among the active offers of the order's
supplier. Without offer_id, the supplier's preferred active offer is used (or
its only one); an offer of another supplier is refused as if it did not exist.
A line takes its concept from the product name and its variant (Name (Variant)); the supplier reference travels in supplier_sku and is not repeated
in the concept. additional_description (up to 5000 characters) is optional and
is printed under the concept.
The supplier_order_reference of an order is unique per company. Creating or
updating an order with one that another order already holds returns 409
resource_already_exists, subcode purchase_order_already_exists, param
supplier_order_reference, and details.purchase_order names the order that
holds it: id, number, supplier_name and order_date (YYYY-MM-DD). Because
the reference is unique per company and not per supplier, supplier_name is the
supplier of that order, which may be another one, or null when its contact
cannot be resolved. In bulk_create the row fails on its own and the other rows
go on: its item in failures[] carries error_code resource_already_exists and
the same subcode, param and details.purchase_order, also when the order that
holds the reference was created earlier in the same batch. The drafts that
accepting a reorder creates carry no supplier reference, so this 409 does not
apply to them. In a file import (purchase_orders.import and
preview_import) the document is skipped instead, with reason
already_exists — or duplicate_in_file when the file repeats it — and the
existing order is named in target_uuid (target_id in the preview).
The default VAT of a new line is the article's and, without it, the company's
default purchase VAT. If neither resolves, the line is refused with the subcode
purchase_line_tax_required; a tax_rate of 0 is kept and leaves the line
exempt. This applies to create, bulk_create
and lines.create.
While the order is draft it can be corrected:
lines.updatechangesquantity,unit_price(the cost),tax_rate,retention_rate,surcharge_rate,description,additional_descriptionandwarehouse_id; send at least one.warehouse_id: nullmakes the line inherit the warehouse of the order again, andadditional_description: nullremoves it. Article, variant and offer are the identity of the line and are not changed.retention_rateis sent as a magnitude, from 0 to 100 with at most two decimals: a negative value is 422invalid_param_valuewithparamlines.N.retention_rate(retention_rateon the single-line operations) and nothing is saved.updateacceptssupplier_id. Changing the supplier re-resolves the offer of every line among the active offers of the new supplier and keeps quantities, descriptions, percentages and warehouses. It is all or nothing: if any line has no offer from the new supplier, the call is refused with the subcodepurchase_order_supplier_offers_missing, which names those lines indetails.lines[]. Withadjust_quantity: truethe quantity of each line is kept in base units and recomputed in the purchase unit of the new offer; when it is not a whole number of that unit, the call is refused with the subcodepurchase_order_supplier_quantity_not_divisible.updatealso takeslines[], which replaces the set in one atomic step: an entry withidedits that line, an entry withoutidadds one, and a stored line the array does not mention is removed. On an entry withid,product_idis required and must repeat the product the line already has, as must the variant and the offer when sent; otherwise the call is refused with the subcodepurchase_order_line_identity_changed(paramlines.N.product_id).
A line that names an offer —or whose product has none to choose from— points at
the entry in param and in details.lines[]: supplier_offer_not_found when
the offer_id sent does not exist or is not active (param lines.N.offer_id),
and supplier_offer_ambiguous when the product has several active offers and
none is preferred. All of them are 422 business_rule_violation.
The PDF and its presentation
The PDF of a purchase order is the document you send the supplier to place the order. Its look comes from the template library, the same one that styles invoices, quotes and delivery notes, and every order has its own presentation: which template, which brand and which paper format its PDF uses. The presentation never changes the content of the order, and creating, editing or sending an order takes no template field: the template is chosen with the operations below. To see how a draft will look before you send it, use a template preview.
The four operations
{purchase_order} is the id of the order:
| Operation | Route | What it does | Scope |
|---|---|---|---|
purchase_orders.get_presentation | GET /v1/companies/{company}/purchase-orders/{purchase_order}/presentation | Reads the state: the template the order would use now and why, and the retained capture. Returns an ETag. | purchase_orders:read |
purchase_orders.assign_presentation | PATCH /v1/companies/{company}/purchase-orders/{purchase_order}/presentation | Chooses the template of a draft, or null to inherit it again. Takes expected_version, If-Match or both. | purchase_orders:write |
purchase_orders.list_presentations | GET /v1/companies/{company}/purchase-orders/{purchase_order}/presentation-history | Lists the retained captures from the newest to the oldest, paginated with page and per_page. | purchase_orders:read |
purchase_orders.revise_presentation | POST /v1/companies/{company}/purchase-orders/{purchase_order}/presentation-revisions | Appends a revision to the capture of a sent order, from a preview of that revision. | purchase_orders:write |
Reading and writing use the scopes the order already has, purchase_orders:read and
purchase_orders:write; the presentation adds none. They need the purchase_orders
module of the plan, like the rest of this page. The MCP server exposes the four as
get_purchase_order_presentation, assign_purchase_order_presentation,
list_purchase_order_presentations and revise_purchase_order_presentation, with the
same scopes. None of them generates a PDF: they move metadata and consume no PDF
budget. The state, the preconditions (ETag, If-Match, expected_version) and the
revisions work as in Document presentations.
When the presentation is captured
A draft captures nothing. Creating, editing or deleting a draft leaves no capture, and its PDF uses the presentation that resolves at that moment and carries the draft watermark.
The presentation is captured the first time the order is sent, whether you email
it with send
or record it with
mark as sent,
in the same operation that moves it from draft to sent. Sending again an order
that is already sent emails it with the presentation it retained and creates no
new capture, and neither do the supplier's confirmation, closing, cancelling or
receiving: none of them touches the capture. An order cancelled while it was still
a draft has no capture; its PDF uses the presentation that resolves at that moment
and carries the cancelled watermark.
If another request captures the presentation at the same moment, the call answers
409 pdf_presentation_conflict or
pdf_presentation_context_changed,
nothing is sent or changed, and you can retry the request.
What the capture retains
The capture retains the presentation: the template and its revision, the
commercial identity and its revision, the plan policy, the paper format, the
purpose and the language of the document. It does not retain the content.
Lines, quantities, amounts, addresses, notes, status and the expected date are
read from the order every time its PDF is produced, so the PDF of a sent order
shows, for example, the expected_date the supplier gave when confirming. A new
revision of the template that you publish later does not change a captured order:
it keeps the revision it was captured with, and a
presentation revision is how you move
it to another one.
Which template an order uses
An order with no template chosen on it resolves one down a ladder, and the first level that has an available template wins:
- The template chosen on the order with
purchase_orders.assign_presentation. It is exclusive: if that template is no longer available the operation fails, it never falls back. - The preference of the supplier for
purchase-orderandcomplete, set with the contact defaults. The contact must be an active supplier. - The company default for
purchase-orderandcomplete(type_defaults). - The company default template.
- The classic PDF settings of the company.
A purchase order is not numbered in a series, so, unlike a sales order, it has no
series level. A template serves purchase orders when it declares purchase-order,
with the complete purpose and the a4 format; the
library guide explains which
templates do.
What the document prints
The order prints its own blocks, in the language of the document, and nothing fiscal or of payment:
- The Supplier ref. column (
supplier_skuin the template configuration) prints the supplier reference of each line. It exists only on purchase orders, and a reference of up to 24 characters stays on one line. - The references strip carries Your quote (the
supplier_order_referenceof the order), Contact (the supplier's contact person) and Deliver to (the destination warehouse); a row without a value is not printed. The date is labelled Expected receipt. - Where an invoice prints its payment block, the order prints Receiving, with the text "Please quote our order number on your delivery note."
- It never prints the VeriFactu QR, legal notices, payment terms or bank details, whatever the template and the plan.
The retained PDF and the download
When the order is captured, Factuarea prepares its original PDF in the background and retains it, without making the send wait for it. From then on every download serves the retained PDF of the current content, or builds, retains and serves one inside the same request if none exists yet; when the live content changes, the new PDF is retained and the original is kept. The email of the first send attaches the retained PDF. A draft retains nothing: each download is built from the order as it is.
purchase_orders.pdf
(GET …/pdf, pdfs:read) answers 200 with the document in the response itself
(application/pdf, or an attachment with ?download=1). It never answers 202
and there is nothing to poll.
When the presentation is not active
render_activation reads legacy in the state when the revisioned presentation is
not active for your company. The reads keep working and show the inherited state
with can_select and can_revise set to false; assign_presentation and
revise_presentation answer 422
pdf_presentation_not_ready without changing
anything, no capture is taken and the PDF of the order is produced by the classic
renderer. An order that was sent before your company moved to the library keeps its
classic PDF too, while a draft created earlier is captured when it is sent, like any
other.
Receiving: a receipt is a draft until you post it
A goods receipt is created against the order —
receipts.create —
or on its own with
goods_receipts.create.
Both take received_on, an optional warehouse_id, supplier_delivery_note
(the number printed on the supplier's delivery note, up to 60 characters),
notes and lines[], and lines may be empty: the receipt is then a draft
that is saved and counted later. It has three states and only three:
| State | What it means |
|---|---|
created | Written down, no stock moved, and it does not count towards the order. |
posted | Stock moved. The order's received quantities went up. |
cancelled | The only terminal state. From created it is a discard; from posted it gives the quantity back to the order's pending. |
post is
the moment stock changes, and posting twice is refused — the state is checked
before the quantity, so you get an invalid-transition response and not a false
excess. Posting requires at least one line: a receipt without any is refused
with the subcode goods_receipt_without_lines (param lines). A receipt is
never deleted. Cancelling a posted receipt keeps both marks, so the
history says the goods came in and went back, not that they never arrived.
Revising a draft receipt
goods_receipts.update
(PATCH) updates a receipt that is still created, like every other PATCH of
the public API: every property is optional and what the body omits is kept.
null empties warehouse_id, supplier_delivery_note or notes; received_on
does not accept it. When sent, lines[] replaces the whole set and may be empty;
when omitted, the saved lines are kept and checked again against the new header.
Lines pair with the stored ones by purchase_order_line_id and order and keep
their id; the number never changes, no stock moves and the order does not
change. A posted receipt answers goods_receipt_already_posted; a
cancelled one answers 422 with the subcode goods_receipt_not_editable.
Details of the body, shared with the two create operations:
location_idon a line names the location of the receiving warehouse where the goods are left. It is informative and moves no stock; one that does not belong to the warehouse of the line is refused with the subcodegoods_receipt_location_invalid(paramlines.N.location_id).- Without
warehouse_id, the warehouses of the order lines decide when they all agree. When the lines go to different warehouses, the call is refused with the subcodegoods_receipt_warehouse_ambiguous(paramwarehouse_id): name the one the goods enter. - The optional
id(UUID v7) makes the creation idempotent: repeated with the same order it returns the receipt with 200, and already used by a receipt of another order it is a 409resource_already_existswith the subcodegoods_receipt_already_exists(paramid).
Reading a receipt
A receipt reads supplier_delivery_note, origin (manual, import or api)
and created_by. Its purchase_order summary carries status,
expected_date, supplier_order_reference, is_overdue, days_overdue,
days_until_due, days_in_grace and grace_days. In the detail, can_cancel
and cancel_blocked_reason (purchase_order_already_billed,
purchase_order_closed_short or goods_receipt_already_invoiced) say whether
the cancellation will go through; the listings publish them as null.
goods_receipts.list
and purchase_orders.receipts.list also filter by supplier_delivery_note and
purchase_order_reference (the supplier_order_reference of the order), exact
or with [contains], and search covers them.
The receiving plan and the sheet
receiving-plan
reads, before you count, what is left to receive in one warehouse: per line
ordered_quantity, received_quantity, pending_quantity,
in_progress_quantity (what other open receipts declare) and
suggested_location, plus open_receipts, the active locations, can_receive
with its blocked_reason and needs_confirmation (the order is still sent).
warehouse_id is a warehouse id or none for the lines without one; omitted,
the server picks the default among several and answers ambiguous_warehouse: true. receipt_id names the receipt you are counting, so it is not counted as
another one.
goods_receipts.sheet
(GET …/sheet) streams a PDF: the form the receiving dock uses to count what
arrives, with no amounts, the pending lines of the order in the receipt warehouse
by storage location, and boxes for what arrives and what is rejected. Only a
created receipt has a sheet; a posted or cancelled one answers 422
goods_receipt_sheet_not_available. The sheet and the PDF of the order are read
with pdfs:read, and the plan of the company must include purchase orders;
otherwise they answer 403 feature_not_available_in_plan.
The sheet takes its look from the library too: the logo, the typeface and the
colours of the warehouse sheets template of your company or, if it has none, of
the company default template, and it keeps its own layout (see
warehouse sheets). It is never
captured: each print uses the template that is current at that moment. With the
revisioned presentation active, the sheet carries below its number the Code 128
barcode of the receipt number (REC-…); scanning it in the search of the receiving
list of the application opens the receipt.
You cannot receive more than is pending: an excess is refused with
goods_receipt_exceeds_ordered_quantity,
and param points at the line, lines.N.quantity.
Receiving less is normal and is exactly how an order becomes
partially_received; call the operation again when the rest arrives.
Rejected quantity
A receipt line can declare part of what arrived as rejected: rejected_quantity
with rejection_reason —damaged, wrong_item, expired or other— and
rejection_note (up to 500 characters, required with other). The accepted
quantity can be 0 when the line declares a rejection. What is rejected does
not enter stock, does not count as received and does not reduce what is
pending: the order still owes it. The receipt lines read back
rejected_quantity and rejected_base_quantity, and the order lines add them
up. A rejection that does not hold together —more than was ordered, a reason
outside the catalog, other without a note, or a quantity that rounds to
zero— is refused with the subcode goods_receipt_rejection_invalid.
goods_receipts.list filters by has_rejections (true or
false; any other value is a 400 parameter_invalid_enum), next to status,
received_on, supplier_id, purchase_order_id, warehouse_id, number and
search.
Cancelling a posted receipt
cancel on a posted receipt gives its quantity back to the
order's pending, with three refusals:
- the order is billed:
purchase_order_already_billed; - the order was closed with pending quantity:
purchase_order_closed_short; - what is invoiced would end up above what was received:
goods_receipt_already_invoiced.
Matching the supplier invoice
match
reads, in one call, the three sides of the classic three-way check: what was
ordered, what was received and what has been invoiced, line by line in base
units (ordered_base_quantity, received_base_quantity,
invoiced_base_quantity), plus every supplier invoice already attached to the
order.
has_deviation is the flag to branch on. Each invoice carries its own
match_status from a closed catalog: not_applicable, pending, matched,
deviation and rejected.
From the purchase-invoice side there are three deliberate verbs:
match.linkattaches an invoice to an order, withpurchase_order_id(a received or partially received order with at least one posted receipt). Reversible withmatch.unlink, which takes no body, sends the match back tonot_applicableand names the released order instock.previously_linked_order; an invoice that is not linked answers the subcodepurchase_invoice_not_linked, and one that can no longer be edited,purchase_invoice_not_editable_in_current_state.match.acceptcloses the check even with a deviation — you decided the difference is fine. Irreversible.match.rejectmarks it as disputed.
match.accept and match.reject require reason (up to 500 characters). The
match of an invoice is read at any time with
match.show,
which needs only the read scope of the purchase order.
The invoice itself publishes the link as purchase_order_id,
purchase_order_number and match_status.
A deviation is not an error to swallow. It is the difference between what you agreed to pay and what you are being charged, and accepting it is a deliberate act by a person, which is why the operation is irreversible.
What an invoice is matched against
Each invoice is compared with what is invoiceable: what was received minus
what the other matched invoices of the same order already invoiced, never with
what was ordered. Invoicing more than that is a deviation (quantity_above);
invoicing less is not one. Each line of the match adds
already_invoiced_base_quantity and invoiceable_base_quantity to the three
quantities above, and description, product_name and variant_name. The reasons quantity_below and line_not_invoiced belong to the closed catalog
and can appear on matches that are already resolved; a new evaluation does not produce them.
Prices are compared per base unit and net of the line discount:
agreed_cost_per_base_unit against invoiced_cost_per_base_unit, and per
purchase unit agreed_unit_price against invoiced_unit_price, with
invoiced_price_change_percent as the signed change. A difference inside
tolerance (price_percent and quantity_percent) is not a deviation. The
effect of a deviation is published in euros as effect (base and with_tax),
per line and for the whole match, positive when the supplier charges more than
agreed. rejected_base_quantity reads, per line, what posted receipts rejected,
which does not count as received. closes_order says whether resolving the
invoice leaves the order billed, and can_resolve whether a deviation can be
accepted or rejected now.
The response of match.link, match.accept and match.reject adds:
excluded_lines: the descriptions of the invoice lines that name no article and so take no part in the comparison (excluded_line_countcounts them), andexcluded_line_items, the same lines withposition,description,baseandtax_rate.resolution: who decided and why (decision,reason,resolved_at,resolved_byandresolved_by_api_key), ornullwhile nobody has decided.
purchase_invoices.list filters by purchase_order_id and by
match_status or match_status[in] (not_applicable, pending, matched,
deviation, rejected); an invalid value is a 422 invalid_param_value.
Finding the order to link
match.candidates
lists, for an invoice that can still be edited, up to ten orders of its supplier,
those whose reference matches the invoice first, and saves nothing. Each one
reads eligible and ineligible_reason (no_posted_receipt or
status_not_matchable), posted_receipts_count, last_receipt,
pending_to_invoice_amount and:
received_unbilled[]: what was received and not invoiced, per article, withbase_quantityandbase_unit_codeand the same figure asquantityin the purchase unit (purchase_unit_code).unposted_receipt: the latest receipt that is not posted yet, whose goods do not count until it is.pending_to_receive[]: what was ordered and has not arrived, in the purchase unit.preview, when the order is eligible: the match that linking would produce (match_status,deviated_line_count,deviations[],lines[]in the purchase unit andeffect).
In the invoices[] of the order detail, each linked invoice adds the decision in
resolution (decision, reason, at and by), its origin, and
deviated_lines: per deviating line, agreed_unit_price, invoiced_unit_price
and invoiced_price_change_percent in the purchase unit.
Reorder suggestions
purchase-reorder-suggestions
lists what your stock says you should buy, already ordered by urgency
(urgency_rank): an item whose physical stock has fallen to its reorder point or
its minimum, with current_quantity, threshold, stock_state (negative,
out_of_stock, all_reserved, below_minimum or below_reorder_point) and
trigger (kind, minimum, reorder_point, reorder_quantity,
missing_quantity and replenish_quantity), plus the preferred supplier, its
offer, its unit_cost, its lead_time_days and the expected_date of an order
placed today (today plus the lead time).
The quantity is in the purchase unit of the offer. suggested_quantity is a whole
number for count units, and suggested_quantity_exact carries the value before
rounding. Each entry of offers has its own suggested_quantity,
suggested_quantity_exact and expected_date.
Three fields decide what you can do with a row:
status—to_order(it can be ordered now),already_on_order(an open order of the same supplier covers it, and accepting leaves it out) orto_resolve.actionable— whether the suggestion can become a purchase order right now.not_actionable_code— why ato_resolverow cannot be ordered:no_active_offer,ambiguous_offers,unreadable_offer,no_supplier_contactortax_rate_unresolved;not_actionable_reasoncarries the same reason as text. A suggestion without a supplier offer is still worth showing; it just cannot be turned into an order by itself.
include adds optional blocks, comma-separated; one not asked for is null, and
an unknown one is a 422 invalid_param_value:
stock: physical, reserved, committed and available, in total and per warehouse.incoming: every open order with goods still to receive, withpending_quantity,expected_date,is_overdue,days_overdueanddays_in_grace, plus the transfers in transit.demand: the sales orders that need goods nothing reserves, withtotal_short_quantityanduncovered_quantity. It needssales_orders:read.offers: every active offer of the target.coverage:covering_order, the open order that makes the rowalready_on_order, with the same overdue counters.
The envelope counts each group —actionable_count, already_on_order_count,
to_resolve_count, not_actionable_count—, flags truncated when the catalog
has more than 500 candidates, names the default_warehouse, and gives
products_with_threshold_count and products_without_threshold_count: the
articles the report watches and those that declare neither a reorder point nor a
minimum, which it can never suggest. The report is not paginated, and
supplier_id narrows it.
The thresholds live on the product: reorder_point and reorder_quantity, in
base units, are written with products.create and products.update and read
with the product, and they travel in the body of the events product.*. Only an
article that manages stock can declare them; otherwise the call is refused with
the subcode product_invalid_reorder_point.
A variant that manages its own stock declares its own reorder_point and reorder_quantity
(see Inventory and warehouses) and is a
candidate of its own: the row names it in product_variant_id, trigger.reorder_point and
trigger.reorder_quantity are the ones of the variant, stock (with include=stock) carries
its own committed and available quantities, and it can come out as all_reserved. Neither the
article nor the variant inherits the thresholds of the other, and products_with_threshold_count
includes the article that has an active variant declaring only its reorder point.
preview
computes the drafts that accepting the same body would create, without writing
anything — no order, no number, no event. It is a read even though it is a POST,
and it takes no Idempotency-Key. Each draft carries its supplier (with tax_id),
destination warehouse (id, code and name), expected_date and
lead_time_days, and lines with
conversion_factor, unit_price, tax_rate, tax_source (product or
company_purchases) and amounts; omitted lists what would be left out, each with
its code.
Both calls take the destination warehouse in the body. warehouse_id names it
for the whole request and items[].warehouse_id for one article, which wins over
it. Without either, the article goes to its preferred warehouse and, failing
that, to the default warehouse of your company. A warehouse that is archived,
does not exist or belongs to another company is refused with a 422 on
warehouse_id or items.N.warehouse_id. The drafts are grouped by supplier
and destination warehouse: articles of the same supplier bound for different
warehouses become different drafts, and the preview shows exactly those groups.
{
"data": {
"drafts": [
{
"supplier": {
"id": "01934c8d-2e5f-7a1b-8c9d-4e5f6a7b8c01",
"name": "Maderas del Noroeste, S.L.",
"tax_id": "B36123453"
},
"warehouse": {
"id": "01934c8d-2e5f-7a1b-8c9d-4e5f6a7b8d02",
"code": "MAIN",
"name": "Main warehouse"
},
"expected_date": "2026-11-09",
"lead_time_days": 10,
"lines": [
{
"position": 0,
"quantity": "4.0000",
"purchase_unit_code": "PK",
"conversion_factor": "12.000000",
"unit_price": "187.5000",
"tax_rate": "21.00",
"tax_source": "product",
"total": "907.50",
"priced": true
}
],
"total": "907.50"
}
],
"omitted": [
{
"position": 2,
"code": "no_active_offer",
"purchase_order_id": null,
"purchase_order_number": null
}
]
}
}accept
turns the rows you choose into draft purchase orders, one per supplier and
destination warehouse, with origin.type reorder. It does not send anything: the order is born as draft,
and sending it is still your call. Each article and variant goes once in items;
repeating one is refused with a 422 whose param is items.N.product_id.
The drafts are born complete: the destination warehouse, an expected date equal to today
plus the longest lead time of their offers, and the VAT of each line. Accepting
again does not duplicate them: an article already covered by an open order of
its supplier is left out of the new drafts. The response is partial
—purchase_orders lists the orders created and failures the items left out,
each with its index and a code that is always present: already_on_order
(with the purchase_order_id and purchase_order_number of the order that covers
it), no_active_offer, ambiguous_offers, unreadable_offer,
no_supplier_contact, tax_rate_unresolved, offer_not_valid (the offer is not
one of the article or is no longer active) or quantity_not_valid. The omitted
list of the preview uses the same codes. A new set is created again once that
order is received, billed or cancelled.
Two acceptances of the same company at the same time do not both run: the second
answers 409 resource_locked with the subcode reorder_accept_in_progress
(param items) and creates nothing, so you can send it again a few seconds
later. Idempotency-Key is optional and honoured.
Overdue deliveries
When an order that is still waiting for goods passes its expected delivery date
by more than three days, Factuarea emits the event purchase_order.overdue, once
per order and expected date (see Events). It is an
event for webhooks, automations and
the n8n trigger, and it has no notice of its own: it creates no
notification in the application and sends no message to the integration channels.
The order keeps its status.
The same rule is published as data wherever an order is read: delivery in the
order, purchase_order in the receipt, and every incoming[] entry of the stock
availability and of the reorder suggestions carry is_overdue and days_overdue
(the days since the expected date, once the grace period has passed) and
days_in_grace while the order is late but still within grace_days.
The notice inside the application for the same fact is the pending receipt summary, which uses the same criterion. Both are about the same orders.
The document scanner relates to the order from the other side. When it reads an
expense whose document names an order, it suggests that order
(suggested_purchase_order_id) but never links it: a person chooses it in the
review or in the conversion, and linking makes the matching described above
apply to the expense. See Document scanner.
Errors worth branching on
| Code | When |
|---|---|
purchase_order_not_found | The id is not yours, or does not exist. |
purchase_order_already_billed | The order reached its terminal state and cannot move. |
goods_receipt_not_found | Same, for a receipt. |
goods_receipt_already_posted | You tried to revise or post a posted receipt. |
goods_receipt_exceeds_ordered_quantity | The receipt would receive more than was ordered. |
pdf_presentation_conflict | 409 of POST …/send, POST …/mark-as-sent or GET …/pdf: another request captured the presentation of the order at the same time. Nothing was sent or changed; repeat the request. |
pdf_presentation_context_changed | 409 of the same three operations when the presentation context changed in the meantime. Nothing was sent or changed; repeat the request. |
pdf_presentation_invalid | 422 of GET …/pdf: the PDF cannot be produced with the template that applies to the order. param names what does not fit, such as configuration.columns, and subcode is columns_exceed_page_width or required_document_content_hidden. |
The rejections of purchase orders and receipts below are 422
business_rule_violation with these subcodes:
| Subcode | When |
|---|---|
purchase_order_short_close_reason_required | Closing a partially received order without reason. |
purchase_order_closed_short | Cancelling a posted receipt of an order closed with pending quantity. |
goods_receipt_already_invoiced | Cancelling the receipt would leave what was received below what was invoiced. |
goods_receipt_rejection_invalid | The rejection of a receipt line is incoherent. |
purchase_order_supplier_offers_missing | A line has no offer from the new supplier. |
purchase_line_tax_required | The line has no VAT of its own, of the article or of the company. |
purchase_order_expected_date_invalid | Confirming with an expected_date earlier than the order date. |
purchase_order_line_identity_changed | The product, variant or offer of a stored line differ from the ones it has. |
purchase_order_supplier_quantity_not_divisible | adjust_quantity leaves a line with a fraction of the purchase unit. |
supplier_offer_not_found | The offer_id of a line does not exist or is not active. |
supplier_offer_ambiguous | The product has several active offers and none is preferred. |
goods_receipt_not_editable | Revising a cancelled receipt. |
goods_receipt_warehouse_ambiguous | The lines go to different warehouses and no warehouse_id was sent. |
goods_receipt_location_invalid | The location does not belong to the warehouse of the line. |
goods_receipt_without_lines | Posting a receipt that declares no quantity. |
goods_receipt_sheet_not_available | Asking for the sheet of a receipt that is not created. |
purchase_invoice_not_linked | Unlinking an invoice that is not linked to an order. |
purchase_invoice_match_not_resolvable | Accepting or rejecting a match that can no longer be resolved, for example when the same request is repeated. |
purchase_order_line_amount_exceeds_column | A quantity whose equivalent in the base unit exceeds the ceiling of the column, 9,999,999,999.9999 (param lines). It applies when an order or a line is created or updated and when a receipt is created or posted. |
product_invalid_reorder_point | reorder_point or reorder_quantity on an article that does not manage stock. |
Two conflicts are 409: resource_already_exists with the subcode
purchase_order_already_exists (param supplier_order_reference) or
goods_receipt_already_exists (param id), and resource_locked with the
subcode reorder_accept_in_progress.
The full lists are the purchase order error index and the purchase invoice error index.
Where to go next
- Sales orders — the same shape on the customer side.
- Document presentations — the template of an order, what it retains and how to revise it.
- Inventory and warehouses — where the posted receipt lands.
- The ERP section of the CLI — the same cycle from a terminal.
- Purchase order tools in MCP — the same cycle for an agent.