Update an invoice line
AI agents: read /llms.txt; add .md to any page URL. This page as Markdown: /reference/invoice-line-items/v2-invoice-item-update.md. Index of every page and the rules for every call: /llms.txt. Guides and concepts in one file: /llms-full.txt. OpenAPI: /openapi.json.
PUT/
Changes one invoice line and recalculates the invoice. Send only what you change; returns the line in an action envelope (action_performed UPDATED, or NONE with has_changes false when nothing changed).
What you can change:
| Kind | Changeable |
|---|---|
order_item |
quantity, tax.type, position. Not which sales order line it bills. |
shipment_fee |
name, description, shipping_taxable, the pricing fee, position. |
invoice_discount |
name, description, type, rate, applies_to_shipping, position. |
user_tax |
id (switch preset), description, shipping_taxable, apply_before_discount, refresh_tax_rate. Always send properties.id. When you switch preset or send refresh_tax_rate, shipping_taxable and apply_before_discount are taken from the preset and the values you send are ignored. |
override_tax |
mode, total, description, shipping_taxable, apply_before_discount. |
auto_tax |
Send the full properties again; the rate is fetched again from the provider. |
Updating an order_item line also copies the sales order line's current unit price again. Numbers are { value, dp } pairs: value is the number without its decimal point and dp the count of decimal places, so 12.50 is { "value": 1250, "dp": 2 } (or { "value": 125, "dp": 1 }). value is a JSON integer or a digit string, never a float. Quantities take up to 8 decimal places, a discount rate 4 and a manual tax total 6; more decimals are a 422 validation_failed. A shipping fee price is rounded half-up to 6 decimal places (a float value there is 422 amount_out_of_range). Send very large numbers as strings. Answers send prices at the stored scale (6 decimal places), quantities without trailing zeros, and _meta.subtotal (price × quantity) at the combined scale, compacted when it would exceed a safe integer: always read dp.
Business rules
- A line's kind can't change: 422 "Cannot update the product type...".
- On an Auto Invoice invoice (
auto_invoice_managed: true), YoPrint automatically updates invoice lines to match the sales order's product lines and shipping fees. You cannot add, edit, or delete its order lines, or edit or delete the shipping fees and discounts created by YoPrint. You can still add your own custom discounts and shipping fees; YoPrint always places them after the managed lines regardless of thepositionyou send. - Updating a tax line makes it yours: YoPrint stops managing it, even when nothing else changes.
- Lines synced from an external system accept only
position.
Side effects
- Recalculates the invoice: line totals, subtotal, shipping, discounts, tax and total.
- Updates the sales order's invoiced totals and each line's invoiced status (not invoiced, partly, fully, or over-invoiced), and automatically redistributes (reallocates) recorded payments across the order's invoices to match updated totals (funds frozen by an open dispute or review stay where they are).
- When the team syncs to QuickBooks Online automatically and the order is published, the order is synced again about 3 minutes later (not after a change of
positiononly). - Open Admin Portal pages refresh, and so do Customer Portal pages the order's customer has open. No webhook or email is sent.
- Updating an
auto_taxline calls the tax provider while you wait.
Path parameters
Your team slug, shown as Team ID next to your API key in Profile.
- Example
your-team
- Example
The invoice line's
id(a hash id), as its answers show it. Its unique key (ordinvitm_...) also works, but API answers don't include it.- Example
nhsGsn84PyJBvK
- Example
Request body
application/json, required.
lock_versionintegerThe line's
lock_versionwhen you read it. If someone saved the line since, the update is refused with 422optimistic_lock_conflict. Omit (or send 0) to skip the check.positionintegerWhere the line sits on the invoice; lower comes first. Not checked against other lines.
pricingobjectChild fields (2)
- Always
"fee"
- Always
Child fields (1)
The fee. Rounded half-up to 6 decimal places.
{ "value": 1250, "dp": 2 }is 12.50:valueholds the digits,dpthe decimal places. See Money and quantities.
productobjectChild fields (2)
- One of:
"order_item","shipment_fee","invoice_discount","user_tax","override_tax","auto_tax"
- One of:
propertiesobjectThe fields of that kind you change, as on create. Fields you leave out keep their values.
quantityobjectHow many to bill. Not negative; you may bill more than was ordered.
Child fields (2)
- Always
"unit"
- Always
The quantity, up to 8 decimal places.
{ "value": 1250, "dp": 2 }is 12.50:valueholds the digits,dpthe decimal places. See Money and quantities.
taxobjectSales order lines (
order_item) only: whether the line is taxed (defaulttaxable). Ignored on other kinds: shipping is taxed by the tax line'sshipping_taxable.Child fields (1)
- One of:
"taxable","non_taxable"
- One of:
More examples (2)
Bill 12 instead
curl -X PUT 'https://secure.yoprint.com/v2/api/store/your-team/v2/invoice/item/nhsGsn84PyJBvK' \ -H 'Authorization: Bearer YOUR_API_KEY' \ -H 'Accept: application/json' \ -H 'X-Yoprint-Decimal-Format: exact-v1' \ -H 'Content-Type: application/json' \ -d '{ "lock_version": 1730000000000000, "quantity": { "total": { "dp": 0, "value": 12 }, "type": "unit" } }'Reload a tax preset's current rate
curl -X PUT 'https://secure.yoprint.com/v2/api/store/your-team/v2/invoice/item/nhsGsn84PyJBvK' \ -H 'Authorization: Bearer YOUR_API_KEY' \ -H 'Accept: application/json' \ -H 'X-Yoprint-Decimal-Format: exact-v1' \ -H 'Content-Type: application/json' \ -d '{ "product": { "properties": { "id": "KC48n7qAAfGYMM", "refresh_tax_rate": true }, "type": "user_tax" } }'Response
200Successful response.
What happened, and the line.
Child fields (5)
object_typestring- Always
"invoice_item"
- Always
action_performedstringNONEwhen nothing changed.- One of:
"CREATED","UPDATED","DELETED","NONE"
- One of:
has_changesbooleanitemobjectAn invoice line.
Child fields (15)
_metaobjectRead-only:
id,type,invoice_id,lock_version,from_legacy,position_hash.auto_invoice_managedbooleanYoPrint manages this line (Auto Invoice).
external_idsarray of objectsLinks to external systems; empty for lines made in YoPrint.
external_typestring | nullfrom_legacybooleanidstringThe invoice line.
invoice_idstringThe invoice.
is_externalbooleanlock_versionintegerSend it back on Update an invoice line to detect a concurrent change.
positionintegerpricingobjectAbsent on tax and discount lines.
system(sales order lines):_meta.unit_priceis the price copied from the sales order line and_meta.subtotalis that price × this line's quantity.fee(shipping fees):product.totalis the fee. Prices come at the stored scale (6 decimal places);_meta.subtotalat the combined scale of price × quantity (compacted when large). Always readdp.Child fields (1)
typestring- One of:
"system","fee"
- One of:
productobjectChild fields (3)
_metaobjectRead-only details, always an object (with
editable_fields_on_update); fororder_item,parentdescribes the sales order line.propertiesobjectThe kind's fields; for
order_item,idis the sales order line. A discount's percentage or amount comes back astotal(you send it asrate).typestring- One of:
"order_item","shipment_fee","invoice_discount","user_tax","override_tax","auto_tax","invoice_surcharge"
- One of:
quantityobjectAbsent on tax and discount lines.
Child fields (2)
typestring- Always
"unit"
- Always
totaldecimal pairThe quantity. A decimal pair: the amount is
value÷ 10^dp({ "value": 1250, "dp": 2 }is 12.50). Readdpevery time: it can differ between fields and records.- See Money and quantities.
taxobjectAbsent on tax and discount lines. YoPrint adds it by default only to sales order lines (
taxable); other lines have it only when it was sent.Child fields (1)
typestring- One of:
"taxable","non_taxable"
- One of:
typestringSame as
product.type.
lock_versionobjectLock versions after the change.
Errors
401The API key is missing or wrong (
unauthenticated).403You are not allowed to do this.
api_access_not_in_plan: your team's plan doesn't include API access (Pro and above, with an active subscription or trial), so every request answers this until the team upgrades. When your role lacks the permission the operation needs, the body is only{"message": "Insufficient Permission"}. Other refusals use the error envelope, withunauthorizedoruser_is_not_authorized.- When
- Your role can't edit this order.
- Fix
- Ask the team owner to adjust your role or assign you to the order.
404Not found.
page_not_found: the team slug is unknown, you are not a member of the team, or an id in the path is not one of this team's.code: null, with a message that starts "No query results for": there is no record with that id.- When
- The line isn't your team's.
- Fix
- Check the line id.
422The request was refused and changed nothing.
validation_failedlists what to fix inerror.fields; other codes name a business rule, explained inerror.message. A few checks answer with only{"message": "..."}. An operation that calls another service (a payment provider, a carrier, an accounting app) can answerconnect_timeout("Please retry again") when that service does not answer in time: the change may or may not have happened there, so read the record back before you retry.- When
- Someone saved the line since you read it (
optimistic_lock_conflict, "Invoice item was modified in another window. Reload and retry."). - Fix
- Read the line again and resend with its new
lock_version. - When
- Validation or a business rule fails (see Add a line to an invoice).
- Fix
- Read
error.messageanderror.fields.
Related
- GETGet an invoice line
/v2/ api/ store/ {team_slug}/ v2/ invoice/ item/ {unique_key} - POSTAdd, change and remove invoice lines at once
/v2/ api/ store/ {team_slug}/ v2/ invoice/ {unique_key}/ item/ bulk
