Add a fixed pricing bundle line item, with its child products, to a subscription contract
Adds another fixed-price box (a Fixed Pricing Bundle) to the signed-in customer’s own subscription, filled with the products the customer picked. The subscription must already be a fixed-price box subscription, and variantId must be a variant of a parent product that the subscription’s box is set up for.
The request body says what goes in one box: each key is a child product’s numeric variant ID, as a JSON string, and each value is how many of it go in the box. Entries with a count of 0 or less are ignored. quantity is the number of boxes, and every box gets the same contents.
On success the call returns 200 with the updated contract. The boxes are one new line for variantId, with quantity as its quantity. The line carries the box properties products, _appstle-bb-id, __appstle-bb-name, _appstle-bb-product-sku and __appstle-bb-variants, plus _appstle_bundles_type set to SINGLE_PRODUCT_BUILD_A_BOX. Each call adds a new line, even when the subscription already has a box with the same contents, so repeating a call that succeeded adds the boxes again.
The store must let customers add products to their bundles: Customer Portal → Customize portal → Features → Build-a-Box and bundles → Customers can add products to their bundles must be on (new stores start with it off), and Customer Portal → Customize portal → Features → Products → Customers can add products to a subscription must not be turned off. Otherwise the call returns 400 with the title UserGeneratedError:Permission denied, Subscription cannot be modified.
The call is also refused with a 400 when the contract isn’t the customer’s, when the subscription is a gift, while a billing for the subscription is in progress, when quantity is below the store’s minimum quantity for adding products, when the store’s product-change window doesn’t allow changes today, when the subscription is frozen until its minimum number of cycles (unless the store allows adds while frozen) or a line’s _min-cycles attribute hasn’t been met, when the store doesn’t let customers change products on a prepaid subscription that ships as separate orders, when the store doesn’t let customers add the parent product to a subscription, or when the subscription already has 50 lines (the default limit).
Appstle also checks the box against its settings. A failed check returns a 400 with one of these errorKey values:
notSingleProductBundle: the subscription isn’t a fixed-price box subscription.bundleNotFound: the subscription’s box can’t be found, for example because the store deleted it.bundleNotAvailable: the box is turned off, or it’s no longer a fixed-price box.notABundleSourceProduct:variantIdisn’t a variant of a parent product that the box is set up for.invalidBundleChild: a body key isn’t a variant of one of the box’s choices for that parent product.bundleBelowMinimum: the counts in the body add up to less than the box’s minimum, or to 0.bundleAboveMaximum: the counts in the body add up to more than the box’s maximum.
A body key that isn’t a number, such as a variant GID, returns a 400 with the title Bad Request.
curl --request PUT \
--url https://www.myshop.com/apps/subscriptions/cp/api/v2/subscription-contracts-add-bundle-line-item \
--header 'Content-Type: application/json' \
--data '
{
"44190100000002": 2,
"44190100000003": 1
}
'import requests
url = "https://www.myshop.com/apps/subscriptions/cp/api/v2/subscription-contracts-add-bundle-line-item"
payload = {
"44190100000002": 2,
"44190100000003": 1
}
headers = {"Content-Type": "application/json"}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({'44190100000002': 2, '44190100000003': 1})
};
fetch('https://www.myshop.com/apps/subscriptions/cp/api/v2/subscription-contracts-add-bundle-line-item', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const url = 'https://www.myshop.com/apps/subscriptions/cp/api/v2/subscription-contracts-add-bundle-line-item';
const options = {
method: 'PUT',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({'44190100000002': 2, '44190100000003': 1})
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://www.myshop.com/apps/subscriptions/cp/api/v2/subscription-contracts-add-bundle-line-item",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'44190100000002' => 2,
'44190100000003' => 1
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://www.myshop.com/apps/subscriptions/cp/api/v2/subscription-contracts-add-bundle-line-item"
payload := strings.NewReader("{\n \"44190100000002\": 2,\n \"44190100000003\": 1\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}require 'uri'
require 'net/http'
url = URI("https://www.myshop.com/apps/subscriptions/cp/api/v2/subscription-contracts-add-bundle-line-item")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"44190100000002\": 2,\n \"44190100000003\": 1\n}"
response = http.request(request)
puts response.read_body{
"billingAttempts": {
"get__typename": "<string>",
"nodes": [
{
"completedAt": {},
"createdAt": {},
"get__typename": "<string>",
"id": "<string>",
"idempotencyKey": "<string>",
"ready": true
}
]
},
"billingPolicy": {
"anchors": [
{
"cutoffDay": 123,
"day": 123,
"get__typename": "<string>",
"month": 123,
"type": "WEEKDAY"
}
],
"get__typename": "<string>",
"interval": "DAY",
"intervalCount": 123,
"maxCycles": 123,
"minCycles": 123
},
"createdAt": {},
"customAttributes": [
{
"get__typename": "<string>",
"key": "<string>",
"value": "<string>"
}
],
"customer": {
"displayName": "<string>",
"email": "<string>",
"firstName": "<string>",
"get__typename": "<string>",
"id": "<string>",
"lastName": "<string>",
"phone": "<string>"
},
"customerPaymentMethod": {
"get__typename": "<string>",
"id": "<string>",
"instrument": {
"get__typename": "<string>"
},
"revokedAt": {},
"revokedReason": "AUTHORIZE_NET_GATEWAY_NOT_ENABLED"
},
"deliveryMethod": {
"get__typename": "<string>"
},
"deliveryPolicy": {
"anchors": [
{
"cutoffDay": 123,
"day": 123,
"get__typename": "<string>",
"month": 123,
"type": "WEEKDAY"
}
],
"get__typename": "<string>",
"interval": "DAY",
"intervalCount": 123
},
"deliveryPrice": {
"amount": {},
"currencyCode": "USD",
"get__typename": "<string>"
},
"discounts": {
"get__typename": "<string>",
"nodes": [
{
"get__typename": "<string>",
"id": "<string>",
"recurringCycleLimit": 123,
"rejectionReason": "NOT_FOUND",
"targetType": "LINE_ITEM",
"title": "<string>",
"type": "MANUAL",
"usageCount": 123,
"value": {
"get__typename": "<string>"
}
}
],
"pageInfo": {
"endCursor": "<string>",
"get__typename": "<string>",
"hasNextPage": true,
"hasPreviousPage": true,
"startCursor": "<string>"
}
},
"get__typename": "<string>",
"id": "<string>",
"lastPaymentStatus": "SUCCEEDED",
"lines": {
"get__typename": "<string>",
"nodes": [
{
"currentPrice": {
"amount": {},
"currencyCode": "USD",
"get__typename": "<string>"
},
"customAttributes": [
{
"get__typename": "<string>",
"key": "<string>",
"value": "<string>"
}
],
"discountAllocations": [
{
"amount": {
"amount": {},
"currencyCode": "USD",
"get__typename": "<string>"
},
"discount": {
"get__typename": "<string>"
},
"get__typename": "<string>"
}
],
"get__typename": "<string>",
"id": "<string>",
"lineDiscountedPrice": {
"amount": {},
"currencyCode": "USD",
"get__typename": "<string>"
},
"pricingPolicy": {
"basePrice": {
"amount": {},
"currencyCode": "USD",
"get__typename": "<string>"
},
"cycleDiscounts": [
{
"adjustmentType": "PERCENTAGE",
"adjustmentValue": {
"get__typename": "<string>"
},
"afterCycle": 123,
"computedPrice": {
"amount": {},
"currencyCode": "USD",
"get__typename": "<string>"
},
"get__typename": "<string>"
}
],
"get__typename": "<string>"
},
"productId": "<string>",
"quantity": 123,
"sellingPlanId": "<string>",
"sellingPlanName": "<string>",
"sku": "<string>",
"taxable": true,
"title": "<string>",
"variantId": "<string>",
"variantImage": {
"get__typename": "<string>",
"url": {}
},
"variantTitle": "<string>"
}
],
"pageInfo": {
"endCursor": "<string>",
"get__typename": "<string>",
"hasNextPage": true,
"hasPreviousPage": true,
"startCursor": "<string>"
}
},
"nextBillingDate": {},
"note": "<string>",
"originOrder": {
"fulfillmentOrders": {
"get__typename": "<string>",
"nodes": [
{
"fulfillAt": {},
"get__typename": "<string>",
"id": "<string>",
"status": "OPEN"
}
],
"pageInfo": {
"endCursor": "<string>",
"get__typename": "<string>",
"hasNextPage": true,
"hasPreviousPage": true,
"startCursor": "<string>"
}
},
"get__typename": "<string>",
"id": "<string>",
"name": "<string>"
},
"revisionId": {},
"status": "ACTIVE",
"updatedAt": {}
}Query Parameters
Body
What goes in one box: each key is a child product's numeric variant ID, as a JSON string (not a GID), and each value is how many of it go in the box.
Response
OK
curl --request PUT \
--url https://www.myshop.com/apps/subscriptions/cp/api/v2/subscription-contracts-add-bundle-line-item \
--header 'Content-Type: application/json' \
--data '
{
"44190100000002": 2,
"44190100000003": 1
}
'import requests
url = "https://www.myshop.com/apps/subscriptions/cp/api/v2/subscription-contracts-add-bundle-line-item"
payload = {
"44190100000002": 2,
"44190100000003": 1
}
headers = {"Content-Type": "application/json"}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({'44190100000002': 2, '44190100000003': 1})
};
fetch('https://www.myshop.com/apps/subscriptions/cp/api/v2/subscription-contracts-add-bundle-line-item', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const url = 'https://www.myshop.com/apps/subscriptions/cp/api/v2/subscription-contracts-add-bundle-line-item';
const options = {
method: 'PUT',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({'44190100000002': 2, '44190100000003': 1})
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://www.myshop.com/apps/subscriptions/cp/api/v2/subscription-contracts-add-bundle-line-item",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'44190100000002' => 2,
'44190100000003' => 1
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://www.myshop.com/apps/subscriptions/cp/api/v2/subscription-contracts-add-bundle-line-item"
payload := strings.NewReader("{\n \"44190100000002\": 2,\n \"44190100000003\": 1\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}require 'uri'
require 'net/http'
url = URI("https://www.myshop.com/apps/subscriptions/cp/api/v2/subscription-contracts-add-bundle-line-item")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"44190100000002\": 2,\n \"44190100000003\": 1\n}"
response = http.request(request)
puts response.read_body{
"billingAttempts": {
"get__typename": "<string>",
"nodes": [
{
"completedAt": {},
"createdAt": {},
"get__typename": "<string>",
"id": "<string>",
"idempotencyKey": "<string>",
"ready": true
}
]
},
"billingPolicy": {
"anchors": [
{
"cutoffDay": 123,
"day": 123,
"get__typename": "<string>",
"month": 123,
"type": "WEEKDAY"
}
],
"get__typename": "<string>",
"interval": "DAY",
"intervalCount": 123,
"maxCycles": 123,
"minCycles": 123
},
"createdAt": {},
"customAttributes": [
{
"get__typename": "<string>",
"key": "<string>",
"value": "<string>"
}
],
"customer": {
"displayName": "<string>",
"email": "<string>",
"firstName": "<string>",
"get__typename": "<string>",
"id": "<string>",
"lastName": "<string>",
"phone": "<string>"
},
"customerPaymentMethod": {
"get__typename": "<string>",
"id": "<string>",
"instrument": {
"get__typename": "<string>"
},
"revokedAt": {},
"revokedReason": "AUTHORIZE_NET_GATEWAY_NOT_ENABLED"
},
"deliveryMethod": {
"get__typename": "<string>"
},
"deliveryPolicy": {
"anchors": [
{
"cutoffDay": 123,
"day": 123,
"get__typename": "<string>",
"month": 123,
"type": "WEEKDAY"
}
],
"get__typename": "<string>",
"interval": "DAY",
"intervalCount": 123
},
"deliveryPrice": {
"amount": {},
"currencyCode": "USD",
"get__typename": "<string>"
},
"discounts": {
"get__typename": "<string>",
"nodes": [
{
"get__typename": "<string>",
"id": "<string>",
"recurringCycleLimit": 123,
"rejectionReason": "NOT_FOUND",
"targetType": "LINE_ITEM",
"title": "<string>",
"type": "MANUAL",
"usageCount": 123,
"value": {
"get__typename": "<string>"
}
}
],
"pageInfo": {
"endCursor": "<string>",
"get__typename": "<string>",
"hasNextPage": true,
"hasPreviousPage": true,
"startCursor": "<string>"
}
},
"get__typename": "<string>",
"id": "<string>",
"lastPaymentStatus": "SUCCEEDED",
"lines": {
"get__typename": "<string>",
"nodes": [
{
"currentPrice": {
"amount": {},
"currencyCode": "USD",
"get__typename": "<string>"
},
"customAttributes": [
{
"get__typename": "<string>",
"key": "<string>",
"value": "<string>"
}
],
"discountAllocations": [
{
"amount": {
"amount": {},
"currencyCode": "USD",
"get__typename": "<string>"
},
"discount": {
"get__typename": "<string>"
},
"get__typename": "<string>"
}
],
"get__typename": "<string>",
"id": "<string>",
"lineDiscountedPrice": {
"amount": {},
"currencyCode": "USD",
"get__typename": "<string>"
},
"pricingPolicy": {
"basePrice": {
"amount": {},
"currencyCode": "USD",
"get__typename": "<string>"
},
"cycleDiscounts": [
{
"adjustmentType": "PERCENTAGE",
"adjustmentValue": {
"get__typename": "<string>"
},
"afterCycle": 123,
"computedPrice": {
"amount": {},
"currencyCode": "USD",
"get__typename": "<string>"
},
"get__typename": "<string>"
}
],
"get__typename": "<string>"
},
"productId": "<string>",
"quantity": 123,
"sellingPlanId": "<string>",
"sellingPlanName": "<string>",
"sku": "<string>",
"taxable": true,
"title": "<string>",
"variantId": "<string>",
"variantImage": {
"get__typename": "<string>",
"url": {}
},
"variantTitle": "<string>"
}
],
"pageInfo": {
"endCursor": "<string>",
"get__typename": "<string>",
"hasNextPage": true,
"hasPreviousPage": true,
"startCursor": "<string>"
}
},
"nextBillingDate": {},
"note": "<string>",
"originOrder": {
"fulfillmentOrders": {
"get__typename": "<string>",
"nodes": [
{
"fulfillAt": {},
"get__typename": "<string>",
"id": "<string>",
"status": "OPEN"
}
],
"pageInfo": {
"endCursor": "<string>",
"get__typename": "<string>",
"hasNextPage": true,
"hasPreviousPage": true,
"startCursor": "<string>"
}
},
"get__typename": "<string>",
"id": "<string>",
"name": "<string>"
},
"revisionId": {},
"status": "ACTIVE",
"updatedAt": {}
}