Change a purchase order charge
Updates the supplied charge fields, recalculates the line shares, adjusts received units’ costs and returns the updated costs. A charge tied to one receipt must be changed through that receipt; this endpoint returns 409 PURCHASE_ORDER_REFUSED.
Required access
- API key
- Enter and correct costspermission
- Request limit
- Counts as 5 requests. Each key has a capacity of 15, restored at 0.6 a second.
Idempotent-Replayed: true. Responses are saved for 24 hours.Headers
Bearer and your key, opk_….
Up to 100 characters (letters, digits, - _ : .). Kept for 24 hours.
application/json. A body is at most 256 KB.
Parameters
The purchase order’s id.
The charge’s id, from GET /purchase-orders/{id}/charges.
Body
JSONHow it is split over the lines: by their value, their quantity or their weight, by hand (manual, with manual_amounts), or expense: in no item cost (its own line in QuickBooks). Any casing is accepted.
One of by_value, by_quantity, by_weight, manual, expense.
As billed, in currency: 0 or more, at most 2 decimals.
A link to the invoice.
The billed currency, three letters. Left out: the store’s. Another needs fx_rate.
Up to 500 characters.
The store’s currency per unit of currency, for a charge billed in another.
True until the vendor’s invoice confirms the amount.
For manual: each line’s amount, { line_id, amount }. They must add up to the charge.
Two decimals.
The vendor’s invoice or waybill number. Up to 500 characters.
The lines (or options on lines) the charge is limited to. Left out or empty: every line.
A line’s id from the purchase order’s lines.
Only part of the line: the option’s label (“Lining”).
What the option costs per unit: what a split by value uses for it.
The option’s value on this line (“Blackout lining”).
What the charge is for. Any casing is accepted.
One of inbound_shipping, duty_import, brokerage, insurance, handling, tariff, other.
Returns
OK: charge_id, charges_in_item_cost, charges_total, content_version, cost_status, cost_sync_error, cost_sync_status, currency, expensed_charges, finalized_at and more
Accepted: the write is done, but its record couldn’t be read back. Don’t send it again: read it with `read`.: charge_id, content_version, done, id, message, number, payment_id, read, refund, reopened and more
Errors
Errors use { "error": { "code", "message" } }. Use code to handle the error. View all error codes.
The request isn’t valid (see error.code), or the API version isn’t supported.
No valid access token or API key.
The store’s subscription isn’t active.
Not allowed: the API is off for this store, or the caller lacks the scope or permission.
Not found, or not visible to this caller.
Wrong method for this path; Allow lists every method the path takes.
The request body didn’t arrive in time.
The same Idempotency-Key is still being processed (REQUEST_IN_PROGRESS), its outcome is unknown (OUTCOME_UNKNOWN: check the record), or the record changed since it was read.
The request body is too large.
The request is valid JSON but can’t be done (a rule of the store refuses it), or the Idempotency-Key was used with a different body.
The app is older than the oldest version still served (error.code CLIENT_TOO_OLD); see error.min_version and error.upgrade_url.
Over a rate limit; wait Retry-After seconds.
Something went wrong on our side. A write may have partly happened: check the record before retrying it.
Busy, switched off, or billing couldn’t be checked; wait Retry-After seconds.