Auto-Link Inbound Shipments
POST/api/purchase-invoices/:purchaseInvoice/inbound-shipments/auto-link
Run the shipment matcher for this purchase invoice now. No request body is required.
purchase-orders:writeGrant this scope to your token under Settings → Developer → Personal Access Tokens.
Every inbound shipment on the invoice's purchase order that is not yet linked to it is weighed against the invoice's lines. A shipment whose lines all match this invoice's lines unambiguously (exact) is linked immediately — exactly as Link Inbound Shipment to Invoice would, but recorded with linked_via = auto. The rest are only reported: partial means some overlap but an ambiguity a person must resolve (a purchase order line billed by two lines on this invoice, a shipment line already paired to a line on another invoice, a shipment line missing from this invoice, or a shipment unlinked from this invoice earlier); none means the shipment has no line in common with the invoice. Both remain linkable by hand.
This runs even when the account-level purchase_invoice_auto_link_shipments setting is off — that setting only controls whether matching happens on its own as invoices and shipments are saved; auto_link_enabled in the response reports it. The same guarantees as a manual link apply: a manually set due date is never overwritten, and a paid invoice's due date never moves.
Response data:
linked— the shipments this run linkedsuggested— thepartialshipments left for a person to decidecandidates— every shipment considered, withmatch(exact,partial,none) and amatch_reasonin plain wordsauto_link_enabled— the account-level automatic matching settingdue_date(YYYY-MM-DD or null),due_date_source(derived,manual,none) anddue_date_basis— the invoice's due date after the run and where it came from (same shape as on Get Purchase Invoice)
message reads "Inbound shipment updated successfully" when at least one shipment was linked, otherwise "No shipment matched this bill unambiguously."
Authentication: Requires Bearer token.
Request
Responses
- 200
- 401
- 403
- 404
- 422
- 429
OK
Unauthenticated — the bearer token is missing, revoked, expired, or malformed. Never retry automatically; fix the credential. See the Errors guide.
Forbidden — the token lacks a required scope, the endpoint is not available to API tokens, or the user behind the token lacks the permission. A human must adjust the token scopes or user permissions; do not retry.
Not Found
Validation failed — the body is a field → messages map (Laravel shape) or the platform envelope with a stable machine-readable code. Fix the payload and resubmit.
Rate limited — platform limit is 1,000 requests/min; individual tokens may carry lower limits. Honor the Retry-After header before retrying. See the Rate Limits guide.