Add, change and remove shipment lines at once
AI agents: read /llms.txt; add .md to any page URL. This page as Markdown: /reference/shipment-line-items/v2-shipment-item-bulk.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.
POST/
Applies several line changes to one shipment in one transaction: all of them are saved, or none.
The body is a JSON array of actions, each with your own label bid, an action, a payload for create and update (the same body as the single calls) and cart_item_id for update and delete. YoPrint runs the deletes first, then the creates, then the updates, and recalculates once. Returns every line of the shipment afterwards, with a top-level has_changes. 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: 12.5 is refused. Quantities take up to 8 decimal places; shipping costs and a pricing mode's rate take 6. More significant decimals than that are a 422, not rounded. 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
- One action per line: a second is 422
cart_item_validation_errorwitherror.context.reasonduplicate_item_actionand the row'serror.bid. - An
updateordeleteof a line that isn't on the shipment is the same code with reasonitem_not_available(anderror.bid). Deleting an already deleted line is skipped. - The validation and Shopify lock rules of the single calls apply to each action (the Shopify lock to every action, synced line or not). Two don't: a shipping cost line for a package that already has one is created again (the single call answers
NONE), and the draft-order "Publish this order before ..." rule for externally synced shipments isn't checked.
Side effects
- Recalculates the shipment's cost and billable fee totals and the order's shipping totals.
- Updates each order line's shipped status (not allocated, partly, fully or over-allocated).
- On an Auto Invoice order, shipping cost lines are mirrored as shipping fees on the managed invoice.
- Open Admin Portal pages refresh, and so do Customer Portal pages the order's customer has open. No webhook or email is sent.
Path parameters
Your team slug, shown as Team ID next to your API key in Profile.
- Example
your-team
- Example
The shipment's
id(a hash id), as its answers show it. Its unique key (shp_...) also works, but API answers don't include it.- Example
MQyJUnd3oty75h
- Example
Request body
application/json, required.
The body is an array of objects.
- One of:
"create","update","delete"
- One of:
Your label for this action, echoed in errors.
cart_item_idstringThe shipment line. Required for
updateanddelete.payloadobjectRequired for
createandupdate.
Response
200Successful response.
Every line of the shipment after the save, one envelope each (deleted lines are absent).
has_changesis at the top level, next todata.Fields of each item (5)
object_typestring- Always
"shipment_item"
- Always
action_performedstringNONEwhen nothing changed.- One of:
"CREATED","UPDATED","DELETED","NONE"
- One of:
has_changesbooleanitemobjectA shipment line.
Child fields (16)
_metaobjectRead-only details of the line.
auto_invoice_managedbooleanbillable_fee_totaldecimal pairShipping cost lines only: what is billed (after override, markup or margin);
pricing.product_cost.totalis the cost. A decimal pair: the amount isvalue÷ 10^dp({ "value": 1250, "dp": 2 }is 12.50). Readdpevery time: it can differ between fields and records.- See Money and quantities.
external_idsarray of objectsLinks to external systems; usually empty.
external_typestring | nullfrom_legacybooleanidstringThe shipment line.
is_externalbooleanlock_versionintegerReturned but not checked on shipment lines.
positionintegerpricingobjectFor
system,_meta.unit_priceis the order line's unit price and_meta.subtotalis that price × this shipment line's quantity (_meta.totalis always 0); forshipment_cost,product_costhasoverride(always true for lines saved through the API),total(the cost),pricing_modeandpricing_mode_total(decimal pairs at 6 decimal places).Child fields (1)
typestring- One of:
"system","shipment_cost"
- One of:
productobjectChild fields (3)
_metaobjectRead-only details; for
order_item,parentdescribes the order line.propertiesobjectFor
order_item,idis the order line; forshipment_cost,name,description,shipment_package_id,shipment_estimate_id.typestring- One of:
"order_item","shipment_cost"
- One of:
quantityobjectChild 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.
shipment_idstringThe shipment.
typestringSame as
product.type.weightobjectThe order line's weight (
_meta.total,_meta.unit).
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 shipment isn't your team's.
- Fix
- Check the id.
422The request was refused and changed nothing.
validation_failedlists what to fix inerror.fields;bulk_validation_payload_failednames the failing item'sbidand itsfields.- When
- A payload fails validation (
bulk_validation_payload_failed, withbidandfields), or a rule refuses an action; nothing is saved. - Fix
- Fix the named action and resend the whole array.
Notes
- Lines you updated say
UPDATED; lines you created and lines you didn't touch both sayCREATED, and deleted lines are absent. Use the top-levelhas_changes(next todata) to know whether anything changed.
Related
- POSTAdd a line to a shipment
/v2/ api/ store/ {team_slug}/ v2/ shipment/ {unique_key}/ item - PUTUpdate a shipment line
/v2/ api/ store/ {team_slug}/ v2/ shipment/ item/ {unique_key} - DELETERemove a line from a shipment
/v2/ api/ store/ {team_slug}/ v2/ shipment/ item/ {unique_key}
