Build-a-Box & Bundles
Create a new Build-A-Box subscription bundle
Creates a Build-A-Box. Send the fields of the box, as in the 201 example, and leave out id and uniqueRef. The example is a fixed-price box (buildABoxType SINGLE_PRODUCT).
Behavior:
- The call returns
201with the whole box. Store itsidand itsuniqueRef: you read, change and delete the box by itsid, and read it by handle or change its choices by itsuniqueRef. - Appstle generates the
uniqueRefwhen you leave it out. The box page link ends with it. - A body with the
idor theuniqueRefof one of your boxes replaces that box, the same way asPUT, and still returns201. Anidthat isn’t one of your boxes returns400witherrorKeyidnotfound. - Each
POSTwithout auniqueRefcreates a new box, so aPOSTthat timed out isn’t safe to repeat. Look for the box in the Appstle app’s Build-A-Box list first. shopis optional. When you send it, it must be your store’s.myshopify.comdomain: the domain of another store returns403.subscriptionIdis the Shopify ID of the plan group the box uses, theidthatGET /api/external/v2/subscription-groupsreturns for it. Appstle doesn’t check it. A value that isn’t one of your plan groups saves, but the box then answers404when you read it by handle.- The Appstle app requires
bundleRedirectfor a fixed-price box, so a box created without it blocks the merchant’s next edit. Values:CART,CART_DRAWER,CHECKOUT,CUSTOM,NONE. singleProductSettings,tieredDiscountandsellingPlanIdsare JSON strings, not objects.discount, or thediscountof a tier intieredDiscount, outside 0 to 100 returns400witherrorKeyinvaliddiscount. AtieredDiscountthat isn’t a JSON array, or a tier without a whole-numberquantityof 1 or more, returns400witherrorKeyinvalidtierdiscount.- A box created with
subscriptionBundlingEnabledset tofalseis off, andGET /api/external/v2/build-a-box/{handle}answers404for it. Read it withGET /api/external/v2/build-a-box/{id}. To turn it on, send the box back withPUT /api/external/v2/build-a-boxandsubscriptionBundlingEnabledset totrue, or select Enabled under Build-A-Box Status in the Appstle app. - Leave out
thirdPartyRule:truemarks a box that belongs to the Appstle Bundles app.
Authentication: Requires a valid X-API-Key header with a Read & Write key.
POST
/
api
/
external
/
v2
/
build-a-box
Create a new Build-A-Box subscription bundle
curl --request POST \
--url https://subscription-admin.appstle.com/api/external/v2/build-a-box \
--header 'Content-Type: application/json' \
--data '
{
"shop": "<string>"
}
'import requests
url = "https://subscription-admin.appstle.com/api/external/v2/build-a-box"
payload = { "shop": "<string>" }
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({shop: '<string>'})
};
fetch('https://subscription-admin.appstle.com/api/external/v2/build-a-box', 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/build-a-box';
const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({shop: '<string>'})
};
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/build-a-box",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'shop' => '<string>'
]),
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/build-a-box"
payload := strings.NewReader("{\n \"shop\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", 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/build-a-box")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"shop\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"buildABoxType": "SINGLE_PRODUCT",
"bundleRedirect": "CART",
"id": 21109,
"name": "Roasters choice box",
"shop": "your-store.myshopify.com",
"singleProductSettings": "[{\"sourceProduct\":{\"id\":15386745176368,\"title\":\"Ethiopia Coffee\",\"handle\":\"ethiopia-coffee\"},\"minQuantity\":\"1\",\"maxQuantity\":\"4\",\"products\":[{\"id\":15386745078064,\"type\":\"PRODUCT\",\"title\":\"Colombia Coffee\",\"productHandle\":\"colombia-coffee\"}]}]",
"subscriptionBundlingEnabled": false,
"subscriptionId": 80297427248,
"uniqueRef": "koasdkcx"
}{
"entityName": "subscriptionBundling",
"errorKey": "invaliddiscount",
"message": "UserGeneratedError:Discount must be between 0 and 100%.",
"params": "subscriptionBundling",
"status": 400,
"title": "UserGeneratedError:Discount must be between 0 and 100%.",
"type": "https://appstle.com/problem/problem-with-message"
}Body
application/json
Response
The box was created. The body is the whole box.
⌘I
Create a new Build-A-Box subscription bundle
curl --request POST \
--url https://subscription-admin.appstle.com/api/external/v2/build-a-box \
--header 'Content-Type: application/json' \
--data '
{
"shop": "<string>"
}
'import requests
url = "https://subscription-admin.appstle.com/api/external/v2/build-a-box"
payload = { "shop": "<string>" }
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({shop: '<string>'})
};
fetch('https://subscription-admin.appstle.com/api/external/v2/build-a-box', 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/build-a-box';
const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({shop: '<string>'})
};
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/build-a-box",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'shop' => '<string>'
]),
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/build-a-box"
payload := strings.NewReader("{\n \"shop\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", 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/build-a-box")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"shop\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"buildABoxType": "SINGLE_PRODUCT",
"bundleRedirect": "CART",
"id": 21109,
"name": "Roasters choice box",
"shop": "your-store.myshopify.com",
"singleProductSettings": "[{\"sourceProduct\":{\"id\":15386745176368,\"title\":\"Ethiopia Coffee\",\"handle\":\"ethiopia-coffee\"},\"minQuantity\":\"1\",\"maxQuantity\":\"4\",\"products\":[{\"id\":15386745078064,\"type\":\"PRODUCT\",\"title\":\"Colombia Coffee\",\"productHandle\":\"colombia-coffee\"}]}]",
"subscriptionBundlingEnabled": false,
"subscriptionId": 80297427248,
"uniqueRef": "koasdkcx"
}{
"entityName": "subscriptionBundling",
"errorKey": "invaliddiscount",
"message": "UserGeneratedError:Discount must be between 0 and 100%.",
"params": "subscriptionBundling",
"status": 400,
"title": "UserGeneratedError:Discount must be between 0 and 100%.",
"type": "https://appstle.com/problem/problem-with-message"
}