Build-a-Box & Bundles
Generate discount code for bundle
Returns the tier discount code for a customer’s Build-a-Box cart, so your own Build-a-Box page can apply it at checkout. Send the cart that Shopify’s /cart.js returns, and use the box’s uniqueRef (shown as Ref in the Build-A-Box list) as the token.
Request body: The cart uses Shopify’s snake_case field names. Appstle reads these fields:
cart.total_price: required. The cart total in the smallest currency unit, such as cents.cart.items: required. One entry per cart line.cart.items[].quantity: required.cart.items[].product_idandcart.items[].variant_id: the line’s product and variant. The discount covers the products of the box that are in the cart.cart.items[].properties: optional. A line with the property_appstle-bb-idis a box line. When any line has it, only those lines count toward the tier and the discount. When none has it, every line counts.
Names that Appstle doesn’t read, such as totalPrice or productId, are ignored without an error.
How the discount is chosen:
- A
QUANTITYtier applies when the counted quantity is at least the tier’s quantity. AnAMOUNTtier applies whencart.total_pricedivided by 100 is at least the tier’s amount. When several tiers apply, the largest discount wins. - When no tier applies, the response is
{"discountNeeded": false}and no code is created. The response is the same for a token that matches no box and for a disabled box. - Otherwise Appstle creates a Shopify discount code named
BUILD_A_BOX_DISCOUNT_<ten letters>_<token>. It takes the matched percentage off the box’s products in the cart (only the box lines when the cart has lines with_appstle-bb-id, so the same product added outside the box keeps its price), applies to subscription purchases and renewal orders, needs the tier’s minimum quantity or subtotal, and combines with product, order and shipping discounts. It allows a one-time purchase only when the box does.
Important Notes:
- Every call that returns a code creates a new discount in Shopify. Call once, when the customer goes to checkout.
- The response is
200with an empty body when the discount can’t be created in Shopify. A cart whose lines carry noproduct_idandvariant_idgets this response. - A cart without
cart,cart.items, an item’squantityorcart.total_pricereturns HTTP400with"status": 500in the body. The same request fails every time, so don’t retry it.
Authentication: Requires a valid X-API-Key header with a Read & Write key.
PUT
/
api
/
external
/
v2
/
subscription-bundlings
/
discount
/
{token}
Generate discount code for bundle
curl --request PUT \
--url https://subscription-admin.appstle.com/api/external/v2/subscription-bundlings/discount/{token} \
--header 'Content-Type: application/json' \
--data '
{
"cart": {
"attributes": {},
"cart_level_discount_applications": [
{}
],
"currency": "<string>",
"item_count": 123,
"items": [
{
"discounted_price": 123,
"discounts": [
{}
],
"featured_image": {
"alt": "<string>",
"aspect_ratio": 123,
"height": 123,
"url": "<string>",
"width": 123
},
"final_line_price": 123,
"final_price": 123,
"gift_card": true,
"grams": 123,
"handle": "<string>",
"id": 123,
"image": "<string>",
"key": "<string>",
"line_level_discount_allocations": [
{}
],
"line_level_total_discount": 123,
"line_price": 123,
"options_with_values": [
{
"name": "<string>",
"value": "<string>"
}
],
"original_line_price": 123,
"original_price": 123,
"price": 123,
"product_description": "<string>",
"product_has_only_default_variant": true,
"product_id": 123,
"product_title": "<string>",
"product_type": "<string>",
"properties": {},
"quantity": 123,
"requires_shipping": true,
"sku": "<string>",
"taxable": true,
"title": "<string>",
"total_discount": 123,
"url": "<string>",
"variant_id": 123,
"variant_options": [
"<string>"
],
"variant_title": {},
"vendor": "<string>"
}
],
"items_subtotal_price": 123,
"note": {},
"original_total_price": 123,
"requires_shipping": true,
"token": "<string>",
"total_discount": 123,
"total_price": 123,
"total_weight": 123
}
}
'import requests
url = "https://subscription-admin.appstle.com/api/external/v2/subscription-bundlings/discount/{token}"
payload = { "cart": {
"attributes": {},
"cart_level_discount_applications": [{}],
"currency": "<string>",
"item_count": 123,
"items": [
{
"discounted_price": 123,
"discounts": [{}],
"featured_image": {
"alt": "<string>",
"aspect_ratio": 123,
"height": 123,
"url": "<string>",
"width": 123
},
"final_line_price": 123,
"final_price": 123,
"gift_card": True,
"grams": 123,
"handle": "<string>",
"id": 123,
"image": "<string>",
"key": "<string>",
"line_level_discount_allocations": [{}],
"line_level_total_discount": 123,
"line_price": 123,
"options_with_values": [
{
"name": "<string>",
"value": "<string>"
}
],
"original_line_price": 123,
"original_price": 123,
"price": 123,
"product_description": "<string>",
"product_has_only_default_variant": True,
"product_id": 123,
"product_title": "<string>",
"product_type": "<string>",
"properties": {},
"quantity": 123,
"requires_shipping": True,
"sku": "<string>",
"taxable": True,
"title": "<string>",
"total_discount": 123,
"url": "<string>",
"variant_id": 123,
"variant_options": ["<string>"],
"variant_title": {},
"vendor": "<string>"
}
],
"items_subtotal_price": 123,
"note": {},
"original_total_price": 123,
"requires_shipping": True,
"token": "<string>",
"total_discount": 123,
"total_price": 123,
"total_weight": 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({
cart: {
attributes: {},
cart_level_discount_applications: [{}],
currency: '<string>',
item_count: 123,
items: [
{
discounted_price: 123,
discounts: [{}],
featured_image: {alt: '<string>', aspect_ratio: 123, height: 123, url: '<string>', width: 123},
final_line_price: 123,
final_price: 123,
gift_card: true,
grams: 123,
handle: '<string>',
id: 123,
image: '<string>',
key: '<string>',
line_level_discount_allocations: [{}],
line_level_total_discount: 123,
line_price: 123,
options_with_values: [{name: '<string>', value: '<string>'}],
original_line_price: 123,
original_price: 123,
price: 123,
product_description: '<string>',
product_has_only_default_variant: true,
product_id: 123,
product_title: '<string>',
product_type: '<string>',
properties: {},
quantity: 123,
requires_shipping: true,
sku: '<string>',
taxable: true,
title: '<string>',
total_discount: 123,
url: '<string>',
variant_id: 123,
variant_options: ['<string>'],
variant_title: {},
vendor: '<string>'
}
],
items_subtotal_price: 123,
note: {},
original_total_price: 123,
requires_shipping: true,
token: '<string>',
total_discount: 123,
total_price: 123,
total_weight: 123
}
})
};
fetch('https://subscription-admin.appstle.com/api/external/v2/subscription-bundlings/discount/{token}', 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-bundlings/discount/{token}';
const options = {
method: 'PUT',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
cart: {
attributes: {},
cart_level_discount_applications: [{}],
currency: '<string>',
item_count: 123,
items: [
{
discounted_price: 123,
discounts: [{}],
featured_image: {alt: '<string>', aspect_ratio: 123, height: 123, url: '<string>', width: 123},
final_line_price: 123,
final_price: 123,
gift_card: true,
grams: 123,
handle: '<string>',
id: 123,
image: '<string>',
key: '<string>',
line_level_discount_allocations: [{}],
line_level_total_discount: 123,
line_price: 123,
options_with_values: [{name: '<string>', value: '<string>'}],
original_line_price: 123,
original_price: 123,
price: 123,
product_description: '<string>',
product_has_only_default_variant: true,
product_id: 123,
product_title: '<string>',
product_type: '<string>',
properties: {},
quantity: 123,
requires_shipping: true,
sku: '<string>',
taxable: true,
title: '<string>',
total_discount: 123,
url: '<string>',
variant_id: 123,
variant_options: ['<string>'],
variant_title: {},
vendor: '<string>'
}
],
items_subtotal_price: 123,
note: {},
original_total_price: 123,
requires_shipping: true,
token: '<string>',
total_discount: 123,
total_price: 123,
total_weight: 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-bundlings/discount/{token}",
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([
'cart' => [
'attributes' => [
],
'cart_level_discount_applications' => [
[
]
],
'currency' => '<string>',
'item_count' => 123,
'items' => [
[
'discounted_price' => 123,
'discounts' => [
[
]
],
'featured_image' => [
'alt' => '<string>',
'aspect_ratio' => 123,
'height' => 123,
'url' => '<string>',
'width' => 123
],
'final_line_price' => 123,
'final_price' => 123,
'gift_card' => true,
'grams' => 123,
'handle' => '<string>',
'id' => 123,
'image' => '<string>',
'key' => '<string>',
'line_level_discount_allocations' => [
[
]
],
'line_level_total_discount' => 123,
'line_price' => 123,
'options_with_values' => [
[
'name' => '<string>',
'value' => '<string>'
]
],
'original_line_price' => 123,
'original_price' => 123,
'price' => 123,
'product_description' => '<string>',
'product_has_only_default_variant' => true,
'product_id' => 123,
'product_title' => '<string>',
'product_type' => '<string>',
'properties' => [
],
'quantity' => 123,
'requires_shipping' => true,
'sku' => '<string>',
'taxable' => true,
'title' => '<string>',
'total_discount' => 123,
'url' => '<string>',
'variant_id' => 123,
'variant_options' => [
'<string>'
],
'variant_title' => [
],
'vendor' => '<string>'
]
],
'items_subtotal_price' => 123,
'note' => [
],
'original_total_price' => 123,
'requires_shipping' => true,
'token' => '<string>',
'total_discount' => 123,
'total_price' => 123,
'total_weight' => 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-bundlings/discount/{token}"
payload := strings.NewReader("{\n \"cart\": {\n \"attributes\": {},\n \"cart_level_discount_applications\": [\n {}\n ],\n \"currency\": \"<string>\",\n \"item_count\": 123,\n \"items\": [\n {\n \"discounted_price\": 123,\n \"discounts\": [\n {}\n ],\n \"featured_image\": {\n \"alt\": \"<string>\",\n \"aspect_ratio\": 123,\n \"height\": 123,\n \"url\": \"<string>\",\n \"width\": 123\n },\n \"final_line_price\": 123,\n \"final_price\": 123,\n \"gift_card\": true,\n \"grams\": 123,\n \"handle\": \"<string>\",\n \"id\": 123,\n \"image\": \"<string>\",\n \"key\": \"<string>\",\n \"line_level_discount_allocations\": [\n {}\n ],\n \"line_level_total_discount\": 123,\n \"line_price\": 123,\n \"options_with_values\": [\n {\n \"name\": \"<string>\",\n \"value\": \"<string>\"\n }\n ],\n \"original_line_price\": 123,\n \"original_price\": 123,\n \"price\": 123,\n \"product_description\": \"<string>\",\n \"product_has_only_default_variant\": true,\n \"product_id\": 123,\n \"product_title\": \"<string>\",\n \"product_type\": \"<string>\",\n \"properties\": {},\n \"quantity\": 123,\n \"requires_shipping\": true,\n \"sku\": \"<string>\",\n \"taxable\": true,\n \"title\": \"<string>\",\n \"total_discount\": 123,\n \"url\": \"<string>\",\n \"variant_id\": 123,\n \"variant_options\": [\n \"<string>\"\n ],\n \"variant_title\": {},\n \"vendor\": \"<string>\"\n }\n ],\n \"items_subtotal_price\": 123,\n \"note\": {},\n \"original_total_price\": 123,\n \"requires_shipping\": true,\n \"token\": \"<string>\",\n \"total_discount\": 123,\n \"total_price\": 123,\n \"total_weight\": 123\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-bundlings/discount/{token}")
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 \"cart\": {\n \"attributes\": {},\n \"cart_level_discount_applications\": [\n {}\n ],\n \"currency\": \"<string>\",\n \"item_count\": 123,\n \"items\": [\n {\n \"discounted_price\": 123,\n \"discounts\": [\n {}\n ],\n \"featured_image\": {\n \"alt\": \"<string>\",\n \"aspect_ratio\": 123,\n \"height\": 123,\n \"url\": \"<string>\",\n \"width\": 123\n },\n \"final_line_price\": 123,\n \"final_price\": 123,\n \"gift_card\": true,\n \"grams\": 123,\n \"handle\": \"<string>\",\n \"id\": 123,\n \"image\": \"<string>\",\n \"key\": \"<string>\",\n \"line_level_discount_allocations\": [\n {}\n ],\n \"line_level_total_discount\": 123,\n \"line_price\": 123,\n \"options_with_values\": [\n {\n \"name\": \"<string>\",\n \"value\": \"<string>\"\n }\n ],\n \"original_line_price\": 123,\n \"original_price\": 123,\n \"price\": 123,\n \"product_description\": \"<string>\",\n \"product_has_only_default_variant\": true,\n \"product_id\": 123,\n \"product_title\": \"<string>\",\n \"product_type\": \"<string>\",\n \"properties\": {},\n \"quantity\": 123,\n \"requires_shipping\": true,\n \"sku\": \"<string>\",\n \"taxable\": true,\n \"title\": \"<string>\",\n \"total_discount\": 123,\n \"url\": \"<string>\",\n \"variant_id\": 123,\n \"variant_options\": [\n \"<string>\"\n ],\n \"variant_title\": {},\n \"vendor\": \"<string>\"\n }\n ],\n \"items_subtotal_price\": 123,\n \"note\": {},\n \"original_total_price\": 123,\n \"requires_shipping\": true,\n \"token\": \"<string>\",\n \"total_discount\": 123,\n \"total_price\": 123,\n \"total_weight\": 123\n }\n}"
response = http.request(request)
puts response.read_body{
"discountCode": "BUILD_A_BOX_DISCOUNT_BptcBVDDOP_xreuziyr",
"discountNeeded": true
}Body
application/json
Response
The code for the cart, or no discount
⌘I
Generate discount code for bundle
curl --request PUT \
--url https://subscription-admin.appstle.com/api/external/v2/subscription-bundlings/discount/{token} \
--header 'Content-Type: application/json' \
--data '
{
"cart": {
"attributes": {},
"cart_level_discount_applications": [
{}
],
"currency": "<string>",
"item_count": 123,
"items": [
{
"discounted_price": 123,
"discounts": [
{}
],
"featured_image": {
"alt": "<string>",
"aspect_ratio": 123,
"height": 123,
"url": "<string>",
"width": 123
},
"final_line_price": 123,
"final_price": 123,
"gift_card": true,
"grams": 123,
"handle": "<string>",
"id": 123,
"image": "<string>",
"key": "<string>",
"line_level_discount_allocations": [
{}
],
"line_level_total_discount": 123,
"line_price": 123,
"options_with_values": [
{
"name": "<string>",
"value": "<string>"
}
],
"original_line_price": 123,
"original_price": 123,
"price": 123,
"product_description": "<string>",
"product_has_only_default_variant": true,
"product_id": 123,
"product_title": "<string>",
"product_type": "<string>",
"properties": {},
"quantity": 123,
"requires_shipping": true,
"sku": "<string>",
"taxable": true,
"title": "<string>",
"total_discount": 123,
"url": "<string>",
"variant_id": 123,
"variant_options": [
"<string>"
],
"variant_title": {},
"vendor": "<string>"
}
],
"items_subtotal_price": 123,
"note": {},
"original_total_price": 123,
"requires_shipping": true,
"token": "<string>",
"total_discount": 123,
"total_price": 123,
"total_weight": 123
}
}
'import requests
url = "https://subscription-admin.appstle.com/api/external/v2/subscription-bundlings/discount/{token}"
payload = { "cart": {
"attributes": {},
"cart_level_discount_applications": [{}],
"currency": "<string>",
"item_count": 123,
"items": [
{
"discounted_price": 123,
"discounts": [{}],
"featured_image": {
"alt": "<string>",
"aspect_ratio": 123,
"height": 123,
"url": "<string>",
"width": 123
},
"final_line_price": 123,
"final_price": 123,
"gift_card": True,
"grams": 123,
"handle": "<string>",
"id": 123,
"image": "<string>",
"key": "<string>",
"line_level_discount_allocations": [{}],
"line_level_total_discount": 123,
"line_price": 123,
"options_with_values": [
{
"name": "<string>",
"value": "<string>"
}
],
"original_line_price": 123,
"original_price": 123,
"price": 123,
"product_description": "<string>",
"product_has_only_default_variant": True,
"product_id": 123,
"product_title": "<string>",
"product_type": "<string>",
"properties": {},
"quantity": 123,
"requires_shipping": True,
"sku": "<string>",
"taxable": True,
"title": "<string>",
"total_discount": 123,
"url": "<string>",
"variant_id": 123,
"variant_options": ["<string>"],
"variant_title": {},
"vendor": "<string>"
}
],
"items_subtotal_price": 123,
"note": {},
"original_total_price": 123,
"requires_shipping": True,
"token": "<string>",
"total_discount": 123,
"total_price": 123,
"total_weight": 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({
cart: {
attributes: {},
cart_level_discount_applications: [{}],
currency: '<string>',
item_count: 123,
items: [
{
discounted_price: 123,
discounts: [{}],
featured_image: {alt: '<string>', aspect_ratio: 123, height: 123, url: '<string>', width: 123},
final_line_price: 123,
final_price: 123,
gift_card: true,
grams: 123,
handle: '<string>',
id: 123,
image: '<string>',
key: '<string>',
line_level_discount_allocations: [{}],
line_level_total_discount: 123,
line_price: 123,
options_with_values: [{name: '<string>', value: '<string>'}],
original_line_price: 123,
original_price: 123,
price: 123,
product_description: '<string>',
product_has_only_default_variant: true,
product_id: 123,
product_title: '<string>',
product_type: '<string>',
properties: {},
quantity: 123,
requires_shipping: true,
sku: '<string>',
taxable: true,
title: '<string>',
total_discount: 123,
url: '<string>',
variant_id: 123,
variant_options: ['<string>'],
variant_title: {},
vendor: '<string>'
}
],
items_subtotal_price: 123,
note: {},
original_total_price: 123,
requires_shipping: true,
token: '<string>',
total_discount: 123,
total_price: 123,
total_weight: 123
}
})
};
fetch('https://subscription-admin.appstle.com/api/external/v2/subscription-bundlings/discount/{token}', 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-bundlings/discount/{token}';
const options = {
method: 'PUT',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
cart: {
attributes: {},
cart_level_discount_applications: [{}],
currency: '<string>',
item_count: 123,
items: [
{
discounted_price: 123,
discounts: [{}],
featured_image: {alt: '<string>', aspect_ratio: 123, height: 123, url: '<string>', width: 123},
final_line_price: 123,
final_price: 123,
gift_card: true,
grams: 123,
handle: '<string>',
id: 123,
image: '<string>',
key: '<string>',
line_level_discount_allocations: [{}],
line_level_total_discount: 123,
line_price: 123,
options_with_values: [{name: '<string>', value: '<string>'}],
original_line_price: 123,
original_price: 123,
price: 123,
product_description: '<string>',
product_has_only_default_variant: true,
product_id: 123,
product_title: '<string>',
product_type: '<string>',
properties: {},
quantity: 123,
requires_shipping: true,
sku: '<string>',
taxable: true,
title: '<string>',
total_discount: 123,
url: '<string>',
variant_id: 123,
variant_options: ['<string>'],
variant_title: {},
vendor: '<string>'
}
],
items_subtotal_price: 123,
note: {},
original_total_price: 123,
requires_shipping: true,
token: '<string>',
total_discount: 123,
total_price: 123,
total_weight: 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-bundlings/discount/{token}",
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([
'cart' => [
'attributes' => [
],
'cart_level_discount_applications' => [
[
]
],
'currency' => '<string>',
'item_count' => 123,
'items' => [
[
'discounted_price' => 123,
'discounts' => [
[
]
],
'featured_image' => [
'alt' => '<string>',
'aspect_ratio' => 123,
'height' => 123,
'url' => '<string>',
'width' => 123
],
'final_line_price' => 123,
'final_price' => 123,
'gift_card' => true,
'grams' => 123,
'handle' => '<string>',
'id' => 123,
'image' => '<string>',
'key' => '<string>',
'line_level_discount_allocations' => [
[
]
],
'line_level_total_discount' => 123,
'line_price' => 123,
'options_with_values' => [
[
'name' => '<string>',
'value' => '<string>'
]
],
'original_line_price' => 123,
'original_price' => 123,
'price' => 123,
'product_description' => '<string>',
'product_has_only_default_variant' => true,
'product_id' => 123,
'product_title' => '<string>',
'product_type' => '<string>',
'properties' => [
],
'quantity' => 123,
'requires_shipping' => true,
'sku' => '<string>',
'taxable' => true,
'title' => '<string>',
'total_discount' => 123,
'url' => '<string>',
'variant_id' => 123,
'variant_options' => [
'<string>'
],
'variant_title' => [
],
'vendor' => '<string>'
]
],
'items_subtotal_price' => 123,
'note' => [
],
'original_total_price' => 123,
'requires_shipping' => true,
'token' => '<string>',
'total_discount' => 123,
'total_price' => 123,
'total_weight' => 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-bundlings/discount/{token}"
payload := strings.NewReader("{\n \"cart\": {\n \"attributes\": {},\n \"cart_level_discount_applications\": [\n {}\n ],\n \"currency\": \"<string>\",\n \"item_count\": 123,\n \"items\": [\n {\n \"discounted_price\": 123,\n \"discounts\": [\n {}\n ],\n \"featured_image\": {\n \"alt\": \"<string>\",\n \"aspect_ratio\": 123,\n \"height\": 123,\n \"url\": \"<string>\",\n \"width\": 123\n },\n \"final_line_price\": 123,\n \"final_price\": 123,\n \"gift_card\": true,\n \"grams\": 123,\n \"handle\": \"<string>\",\n \"id\": 123,\n \"image\": \"<string>\",\n \"key\": \"<string>\",\n \"line_level_discount_allocations\": [\n {}\n ],\n \"line_level_total_discount\": 123,\n \"line_price\": 123,\n \"options_with_values\": [\n {\n \"name\": \"<string>\",\n \"value\": \"<string>\"\n }\n ],\n \"original_line_price\": 123,\n \"original_price\": 123,\n \"price\": 123,\n \"product_description\": \"<string>\",\n \"product_has_only_default_variant\": true,\n \"product_id\": 123,\n \"product_title\": \"<string>\",\n \"product_type\": \"<string>\",\n \"properties\": {},\n \"quantity\": 123,\n \"requires_shipping\": true,\n \"sku\": \"<string>\",\n \"taxable\": true,\n \"title\": \"<string>\",\n \"total_discount\": 123,\n \"url\": \"<string>\",\n \"variant_id\": 123,\n \"variant_options\": [\n \"<string>\"\n ],\n \"variant_title\": {},\n \"vendor\": \"<string>\"\n }\n ],\n \"items_subtotal_price\": 123,\n \"note\": {},\n \"original_total_price\": 123,\n \"requires_shipping\": true,\n \"token\": \"<string>\",\n \"total_discount\": 123,\n \"total_price\": 123,\n \"total_weight\": 123\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-bundlings/discount/{token}")
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 \"cart\": {\n \"attributes\": {},\n \"cart_level_discount_applications\": [\n {}\n ],\n \"currency\": \"<string>\",\n \"item_count\": 123,\n \"items\": [\n {\n \"discounted_price\": 123,\n \"discounts\": [\n {}\n ],\n \"featured_image\": {\n \"alt\": \"<string>\",\n \"aspect_ratio\": 123,\n \"height\": 123,\n \"url\": \"<string>\",\n \"width\": 123\n },\n \"final_line_price\": 123,\n \"final_price\": 123,\n \"gift_card\": true,\n \"grams\": 123,\n \"handle\": \"<string>\",\n \"id\": 123,\n \"image\": \"<string>\",\n \"key\": \"<string>\",\n \"line_level_discount_allocations\": [\n {}\n ],\n \"line_level_total_discount\": 123,\n \"line_price\": 123,\n \"options_with_values\": [\n {\n \"name\": \"<string>\",\n \"value\": \"<string>\"\n }\n ],\n \"original_line_price\": 123,\n \"original_price\": 123,\n \"price\": 123,\n \"product_description\": \"<string>\",\n \"product_has_only_default_variant\": true,\n \"product_id\": 123,\n \"product_title\": \"<string>\",\n \"product_type\": \"<string>\",\n \"properties\": {},\n \"quantity\": 123,\n \"requires_shipping\": true,\n \"sku\": \"<string>\",\n \"taxable\": true,\n \"title\": \"<string>\",\n \"total_discount\": 123,\n \"url\": \"<string>\",\n \"variant_id\": 123,\n \"variant_options\": [\n \"<string>\"\n ],\n \"variant_title\": {},\n \"vendor\": \"<string>\"\n }\n ],\n \"items_subtotal_price\": 123,\n \"note\": {},\n \"original_total_price\": 123,\n \"requires_shipping\": true,\n \"token\": \"<string>\",\n \"total_discount\": 123,\n \"total_price\": 123,\n \"total_weight\": 123\n }\n}"
response = http.request(request)
puts response.read_body{
"discountCode": "BUILD_A_BOX_DISCOUNT_BptcBVDDOP_xreuziyr",
"discountNeeded": true
}