Build-a-Box & Bundles
Update subscription bundling configuration
Adds and removes the choices of a parent product in a fixed-price Build-A-Box (buildABoxType SINGLE_PRODUCT). You send only the changes, so you don’t need to read the box first. Appstle gets the title, handle and image of each product or variant you add from Shopify.
The body is an array, so one call can change several boxes. Appstle saves each box on its own, in the order you send them, so a call that fails can leave the boxes before the failing one already changed.
Request body:
babHandle: the box’suniqueRef, shown as Ref in the Build-A-Box list.sourceProducts: required. One entry for each parent product you change.sourceProducts[].sourceProductId: the parent’s Shopify product ID. It’s theidof the parent’ssourceProductin the box’ssingleProductSettings.sourceProducts[].addSubProductIdsandsourceProducts[].addSubVariantIds: the Shopify product IDs and variant IDs to add as choices. A product ID inaddSubVariantIdsis skipped without an error.sourceProducts[].deleteSubProductIdsandsourceProducts[].deleteSubVariantIds: the IDs of the choices to remove.
Each of the four ID lists is optional. Send the IDs as numbers, not as Shopify GIDs.
Behavior:
- The call returns
200with an empty body. To check the change, read the box withGET /api/external/v2/build-a-box/{handle}, using theuniqueRefas the handle. - An unknown
babHandleorsourceProductIdis skipped without an error. A save that fails also returns200. - A product or variant ID to add that doesn’t exist in Shopify returns HTTP
400with"status": 500in the body. Check the IDs, then send the call again. - Sending the same call again is safe. A choice the parent already has isn’t added twice, and removing a choice that isn’t there does nothing.
- The call also changes a box that is off. While the box is off,
GET /api/external/v2/build-a-box/{handle}answers404, so check the change withGET /api/external/v2/build-a-box/{id}instead. - A box with
thirdPartyRuleset totruebelongs to the Appstle Bundles app. Each time the merchant saves the box in Bundles, Bundles sends the whole box again and replaces your change. - A later
PUT /api/external/v2/build-a-boxthat sends an older copy of the box undoes this change.
Authentication: Requires a valid X-API-Key header with a Read & Write key.
PUT
/
api
/
external
/
v2
/
subscription-bundling
/
update
Update subscription bundling configuration
curl --request PUT \
--url https://subscription-admin.appstle.com/api/external/v2/subscription-bundling/update \
--header 'Content-Type: application/json' \
--data '
[
{
"babHandle": "<string>",
"sourceProducts": [
{
"addSubProductIds": [
123
],
"addSubVariantIds": [
123
],
"deleteSubProductIds": [
123
],
"deleteSubVariantIds": [
123
],
"sourceProductId": 123
}
]
}
]
'import requests
url = "https://subscription-admin.appstle.com/api/external/v2/subscription-bundling/update"
payload = [
{
"babHandle": "<string>",
"sourceProducts": [
{
"addSubProductIds": [123],
"addSubVariantIds": [123],
"deleteSubProductIds": [123],
"deleteSubVariantIds": [123],
"sourceProductId": 123
}
]
}
]
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([
{
babHandle: '<string>',
sourceProducts: [
{
addSubProductIds: [123],
addSubVariantIds: [123],
deleteSubProductIds: [123],
deleteSubVariantIds: [123],
sourceProductId: 123
}
]
}
])
};
fetch('https://subscription-admin.appstle.com/api/external/v2/subscription-bundling/update', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const url = 'https://subscription-admin.appstle.com/api/external/v2/subscription-bundling/update';
const options = {
method: 'PUT',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify([
{
babHandle: '<string>',
sourceProducts: [
{
addSubProductIds: [123],
addSubVariantIds: [123],
deleteSubProductIds: [123],
deleteSubVariantIds: [123],
sourceProductId: 123
}
]
}
])
};
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://subscription-admin.appstle.com/api/external/v2/subscription-bundling/update",
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([
[
'babHandle' => '<string>',
'sourceProducts' => [
[
'addSubProductIds' => [
123
],
'addSubVariantIds' => [
123
],
'deleteSubProductIds' => [
123
],
'deleteSubVariantIds' => [
123
],
'sourceProductId' => 123
]
]
]
]),
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://subscription-admin.appstle.com/api/external/v2/subscription-bundling/update"
payload := strings.NewReader("[\n {\n \"babHandle\": \"<string>\",\n \"sourceProducts\": [\n {\n \"addSubProductIds\": [\n 123\n ],\n \"addSubVariantIds\": [\n 123\n ],\n \"deleteSubProductIds\": [\n 123\n ],\n \"deleteSubVariantIds\": [\n 123\n ],\n \"sourceProductId\": 123\n }\n ]\n }\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://subscription-admin.appstle.com/api/external/v2/subscription-bundling/update")
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 {\n \"babHandle\": \"<string>\",\n \"sourceProducts\": [\n {\n \"addSubProductIds\": [\n 123\n ],\n \"addSubVariantIds\": [\n 123\n ],\n \"deleteSubProductIds\": [\n 123\n ],\n \"deleteSubVariantIds\": [\n 123\n ],\n \"sourceProductId\": 123\n }\n ]\n }\n]"
response = http.request(request)
puts response.read_body{
"detail": "An unexpected error occurred. Please try again later.",
"message": "error.http.500",
"path": "/api/external/v2/subscription-bundling/update",
"status": 500,
"title": "Internal Server Error",
"type": "https://appstle.com/problem/problem-with-message"
}⌘I
Update subscription bundling configuration
curl --request PUT \
--url https://subscription-admin.appstle.com/api/external/v2/subscription-bundling/update \
--header 'Content-Type: application/json' \
--data '
[
{
"babHandle": "<string>",
"sourceProducts": [
{
"addSubProductIds": [
123
],
"addSubVariantIds": [
123
],
"deleteSubProductIds": [
123
],
"deleteSubVariantIds": [
123
],
"sourceProductId": 123
}
]
}
]
'import requests
url = "https://subscription-admin.appstle.com/api/external/v2/subscription-bundling/update"
payload = [
{
"babHandle": "<string>",
"sourceProducts": [
{
"addSubProductIds": [123],
"addSubVariantIds": [123],
"deleteSubProductIds": [123],
"deleteSubVariantIds": [123],
"sourceProductId": 123
}
]
}
]
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([
{
babHandle: '<string>',
sourceProducts: [
{
addSubProductIds: [123],
addSubVariantIds: [123],
deleteSubProductIds: [123],
deleteSubVariantIds: [123],
sourceProductId: 123
}
]
}
])
};
fetch('https://subscription-admin.appstle.com/api/external/v2/subscription-bundling/update', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));const url = 'https://subscription-admin.appstle.com/api/external/v2/subscription-bundling/update';
const options = {
method: 'PUT',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify([
{
babHandle: '<string>',
sourceProducts: [
{
addSubProductIds: [123],
addSubVariantIds: [123],
deleteSubProductIds: [123],
deleteSubVariantIds: [123],
sourceProductId: 123
}
]
}
])
};
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://subscription-admin.appstle.com/api/external/v2/subscription-bundling/update",
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([
[
'babHandle' => '<string>',
'sourceProducts' => [
[
'addSubProductIds' => [
123
],
'addSubVariantIds' => [
123
],
'deleteSubProductIds' => [
123
],
'deleteSubVariantIds' => [
123
],
'sourceProductId' => 123
]
]
]
]),
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://subscription-admin.appstle.com/api/external/v2/subscription-bundling/update"
payload := strings.NewReader("[\n {\n \"babHandle\": \"<string>\",\n \"sourceProducts\": [\n {\n \"addSubProductIds\": [\n 123\n ],\n \"addSubVariantIds\": [\n 123\n ],\n \"deleteSubProductIds\": [\n 123\n ],\n \"deleteSubVariantIds\": [\n 123\n ],\n \"sourceProductId\": 123\n }\n ]\n }\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://subscription-admin.appstle.com/api/external/v2/subscription-bundling/update")
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 {\n \"babHandle\": \"<string>\",\n \"sourceProducts\": [\n {\n \"addSubProductIds\": [\n 123\n ],\n \"addSubVariantIds\": [\n 123\n ],\n \"deleteSubProductIds\": [\n 123\n ],\n \"deleteSubVariantIds\": [\n 123\n ],\n \"sourceProductId\": 123\n }\n ]\n }\n]"
response = http.request(request)
puts response.read_body{
"detail": "An unexpected error occurred. Please try again later.",
"message": "error.http.500",
"path": "/api/external/v2/subscription-bundling/update",
"status": 500,
"title": "Internal Server Error",
"type": "https://appstle.com/problem/problem-with-message"
}