Line items
Change what a subscription contains: add, update and remove a contract's line items.
Change what a subscription contains. These endpoints alter what the customer receives and pays, so read the notes at the end of the group before wiring them up.
Add a line item to a contract
POST /shop-api/contracts/add-line-itemPermission: Line items → Add line items (contracts:add_line_item).
Adds a product variant to a contract. The new line rides the contract's existing billing schedule and appears in lines the next time you list contracts.
Request body
| Field | Type | Required | Description |
|---|---|---|---|
contractId | string|number | Yes | Shopify GID or numeric ID of the contract. |
variantId | string|number | Yes | Shopify GID (gid://shopify/ProductVariant/123) or numeric ID of the variant to add. |
quantity | number | Yes | Whole number from 1 to 1000000. |
price | number | No | Per-unit price in the contract's currency: 0 or more, at most 2 decimals, up to 1000000. Omit it to price the line at the variant's price for the contract's delivery country. |
currencyCode | string | No | Three-letter currency code. A check, not a conversion: the request is refused if it differs from the contract's currencyCode. |
How the line is priced
- With `price` — the line is contracted at that price on every future order. The contract's selling plan cannot re-price it later.
- Without `price` — the line is priced at the variant's price for the market the contract ships to, in the contract's currency. If the variant has no price in that currency, the request is refused with
422and nothing is added.
Example
curl -X POST "https://subscriptions.kachingappz.app/shop-api/contracts/add-line-item" \
-H "Authorization: Bearer <your-api-token>" \
-H "Content-Type: application/json" \
-d '{
"contractId": "123456789",
"variantId": "44123456789",
"quantity": 2,
"price": 25.99,
"currencyCode": "USD"
}'Response (200)
{
"success": true,
"line": {
"id": "gid://shopify/SubscriptionLine/0f1dcb8f-e608-4c3f-b153-dc77897d39e9",
"variantId": "gid://shopify/ProductVariant/44123456789",
"quantity": 2,
"price": 25.99,
"currencyCode": "USD",
"priceSource": "REQUEST"
}
}priceSource is REQUEST when the price is the one you sent, and CONTEXTUAL when it was taken from the contract's market.
Update a line item
POST /shop-api/contracts/update-line-itemPermission: Line items → Update line items (contracts:update_line_item).
Changes the variant, quantity and/or price of an existing line. Send at least one of variantId, quantity and price.
Request body
| Field | Type | Required | Description |
|---|---|---|---|
contractId | string|number | Yes | Shopify GID or numeric ID of the contract. |
lineId | string | Yes | The line's id from list contracts — the full gid://shopify/SubscriptionLine/… GID or the part after the last /. |
variantId | string|number | No | Move the line to this variant. |
quantity | number | No | New quantity, a whole number from 1 to 1000000. |
price | number | No | New per-unit price in the contract's currency, with the same rules as for adding a line. |
currencyCode | string | No | Checked against the contract's currency, as for adding a line. |
What each field changes
- `quantity` — only the quantity. The line's price and discount schedule are left as they are.
- `variantId` — the line moves to the new variant at the price it already has. A variant swap never changes what the customer pays; send
priceas well if it should. - `price` — the line is contracted at the new price on every future order, replacing any discount schedule it had.
Example — swap the variant and change the quantity
curl -X POST "https://subscriptions.kachingappz.app/shop-api/contracts/update-line-item" \
-H "Authorization: Bearer <your-api-token>" \
-H "Content-Type: application/json" \
-d '{
"contractId": "123456789",
"lineId": "gid://shopify/SubscriptionLine/0f1dcb8f-e608-4c3f-b153-dc77897d39e9",
"variantId": "44987654321",
"quantity": 3
}'Response (200)
{
"success": true,
"line": {
"id": "gid://shopify/SubscriptionLine/0f1dcb8f-e608-4c3f-b153-dc77897d39e9",
"variantId": "gid://shopify/ProductVariant/44987654321",
"quantity": 3,
"price": 25.99,
"currencyCode": "USD",
"priceSource": "REQUEST"
},
"removedDiscounts": []
}Each entry in removedDiscounts is { "discountId": "gid://shopify/SubscriptionManualDiscount/…", "reason": "quantity-invalidated" }.
Remove a line item
POST /shop-api/contracts/remove-line-itemPermission: Line items → Remove line items (contracts:remove_line_item).
Removes a line from a contract. The contract's last line cannot be removed — to stop a subscription, cancel it instead.
Request body
| Field | Type | Required | Description |
|---|---|---|---|
contractId | string|number | Yes | Shopify GID or numeric ID of the contract. |
lineId | string | Yes | The line's id from list contracts. |
Example
curl -X POST "https://subscriptions.kachingappz.app/shop-api/contracts/remove-line-item" \
-H "Authorization: Bearer <your-api-token>" \
-H "Content-Type: application/json" \
-d '{
"contractId": "123456789",
"lineId": "gid://shopify/SubscriptionLine/0f1dcb8f-e608-4c3f-b153-dc77897d39e9"
}'Response (200)
{
"success": true,
"lineId": "gid://shopify/SubscriptionLine/0f1dcb8f-e608-4c3f-b153-dc77897d39e9"
}Notes on line item changes
- Only `ACTIVE`, `PAUSED` and `FAILED` contracts can be changed. Others are refused with
422, and so is a contract with more than 50 line items. - Changes apply to every future order, not just the next one.
- Every call applies — repeat calls are not deduplicated. Two identical
add-line-itemrequests add two lines. A request that timed out may still have been applied, so read list contracts before retrying. - Each call is its own change. To replace one product with another, either swap the variant with
update-line-item, or add the new line and then remove the old one — and if you do the latter, check the contract afterwards, since a failure in between leaves both lines or neither. - Lines given as a streak reward cannot be changed or removed (
403). - If the contract is being changed by something else at that moment, the request is refused with
409. Nothing was applied, so retry after a short wait. - The merchant's contract-update guard applies. If the shop has it turned on, a change that takes the contract's total above both $100 USD and twice the value of its first order is refused with
422. - Every change appears on the contract's timeline in the Kaching admin as a "via API" entry.