Skip to main content
PUT
/
api
/
external
/
v2
/
subscription-bundlings
/
discount
/
{token}
Generate bundle-specific discount code
curl --request PUT \
  --url https://membership-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://membership-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://membership-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://membership-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://membership-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://membership-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://membership-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": "<string>",
  "discountNeeded": true,
  "errorMessage": "<string>"
}
{
"detail": "Invalid discount code format or configuration",
"errorKey": "validation_error",
"status": 400,
"title": "Bad Request"
}
{
"discountCode": "<string>",
"discountNeeded": true,
"errorMessage": "<string>"
}
{
"discountCode": "<string>",
"discountNeeded": true,
"errorMessage": "<string>"
}
{
"discountCode": "<string>",
"discountNeeded": true,
"errorMessage": "<string>"
}

Headers

X-API-Key
string

Path Parameters

token
string
required

Bundle token identifier

Query Parameters

api_key
string

API Key (Deprecated - Use Header X-API-Key instead)

Body

application/json

Discount code configuration including code, value, type, and validity

cart
object

Response

Discount code successfully created in Shopify

discountCode
string
discountNeeded
boolean
errorMessage
string