Confirm Cost Entry AI Allocation Proposals
POST/api/cost-entries/:costEntry/ai-allocation/:batch/confirm
Writes the chosen proposals as cost allocations, linked to their source lines, in one transaction. Every proposal is re-checked first: it must be ready, its product must still exist and pass the stock-and-sales check, and the selected amounts must fit what is left unallocated on each line. If any check fails nothing is written.
purchase-orders:writeGrant this scope to your token under Settings → Developer → Personal Access Tokens.
Body:
proposal_ids(array of integers, required, 1–5000, distinct) — proposals of this batch to confirm.input_hash(string, required, exactly 64 characters) — the batch'sinput_hashyou reviewed. A different value means the source lines, the entry's amount, or its currency or exchange rate changed, and the confirm is refused with 409.
Response: data is the result — batch_id, count (allocations written), total, proposal_ids, allocation_ids, unallocated_after (what is left to allocate on the entry after confirming, in the entry's own currency like every amount here), decided_by_name, decided_at and input_hash (the batch's new fingerprint, needed for a further confirm). batch is the refreshed batch; message is a short summary. Keep proposal_ids to undo this confirmation later.
Errors: 409 with code: stale when the source lines, their allocations, or the entry's amount, currency or rate changed since proposing; 422 when a proposal is not part of the batch, is not ready, its product was deleted or is no longer eligible, a line has less left than proposed, or the batch is still running or failed; 422 validation errors; 404 when the batch does not belong to the cost entry.
Required permission: cost_entries.ai_allocate (Allocate with AI).
Authentication: Requires Bearer token (scope purchase-orders:write).
targets (optional): object of proposal id => the product id you reviewed, an extra check on top of revisions. If a proposal points at a different product now (someone changed it since you loaded the batch), nothing is confirmed and the response is 409 (code: proposal_changed); reload the batch and review again.
revisions (required): object of proposal id => the revision you reviewed, with an entry for every id in proposal_ids. A request without it, or missing any proposal, is refused with 422 and nothing is written. Editing a proposal does not change input_hash, so the revision is what proves each proposal is still the one you reviewed. Every proposal carries a revision that goes up on each change (re-pointed, left unallocated, confirmed, rejected or made stale). If any proposal's revision differs now (someone changed it in another tab after you loaded the batch), nothing is confirmed and the response is 409 with code: proposal_changed and proposal_ids (the changed ones); reload the batch, check those proposals and confirm again. The same 409 is returned when a proposal's product differs from targets.
Amounts are in the cost entry's own currency; the result carries currency_code.
Request
Responses
- 200
- 401
- 403
- 404
- 409
- 422
- 429
OK
Response Headers
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 — no record with the given identifier (or the route does not exist). Verify the ID before retrying.
Conflict
Response Headers
Unprocessable Content
Response Headers
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.