Skip to main content
POST
/
api
/
external
/
v2
/
product-swaps-by-variant-groups
/
{contractId}
Get product swap variant groups for a contract
curl --request POST \
  --url https://subscription-admin.appstle.com/api/external/v2/product-swaps-by-variant-groups/{contractId} \
  --header 'Content-Type: application/json' \
  --data '
{
  "variantQuantityList": [
    {
      "quantity": 2,
      "swapId": 1001,
      "variantId": 12345
    },
    {
      "quantity": 2,
      "swapId": 1002,
      "variantId": 67890
    }
  ]
}
'
import requests

url = "https://subscription-admin.appstle.com/api/external/v2/product-swaps-by-variant-groups/{contractId}"

payload = { "variantQuantityList": [
{
"quantity": 2,
"swapId": 1001,
"variantId": 12345
},
{
"quantity": 2,
"swapId": 1002,
"variantId": 67890
}
] }
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({
variantQuantityList: [
{quantity: 2, swapId: 1001, variantId: 12345},
{quantity: 2, swapId: 1002, variantId: 67890}
]
})
};

fetch('https://subscription-admin.appstle.com/api/external/v2/product-swaps-by-variant-groups/{contractId}', 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/product-swaps-by-variant-groups/{contractId}';
const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
variantQuantityList: [
{quantity: 2, swapId: 1001, variantId: 12345},
{quantity: 2, swapId: 1002, variantId: 67890}
]
})
};

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/product-swaps-by-variant-groups/{contractId}",
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([
'variantQuantityList' => [
[
'quantity' => 2,
'swapId' => 1001,
'variantId' => 12345
],
[
'quantity' => 2,
'swapId' => 1002,
'variantId' => 67890
]
]
]),
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/product-swaps-by-variant-groups/{contractId}"

payload := strings.NewReader("{\n \"variantQuantityList\": [\n {\n \"quantity\": 2,\n \"swapId\": 1001,\n \"variantId\": 12345\n },\n {\n \"quantity\": 2,\n \"swapId\": 1002,\n \"variantId\": 67890\n }\n ]\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/product-swaps-by-variant-groups/{contractId}")

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 \"variantQuantityList\": [\n {\n \"quantity\": 2,\n \"swapId\": 1001,\n \"variantId\": 12345\n },\n {\n \"quantity\": 2,\n \"swapId\": 1002,\n \"variantId\": 67890\n }\n ]\n}"

response = http.request(request)
puts response.read_body
[
  [
    {
      "image": "https://cdn.shopify.com/files/1/0000/0000/products/medium-roast.jpg",
      "productId": "gid://shopify/Product/98765",
      "productTitle": "House Blend Coffee",
      "quantity": 2,
      "swapId": 1001,
      "title": "Medium Roast - 12oz",
      "variantId": 12345,
      "variantTitle": "House Blend Coffee - Medium Roast - 12oz"
    },
    {
      "image": "https://cdn.shopify.com/files/1/0000/0000/products/light-roast.jpg",
      "productId": "gid://shopify/Product/98766",
      "productTitle": "Morning Blend Coffee",
      "quantity": 1,
      "swapId": 1001,
      "title": "Light Roast - 8oz",
      "variantId": 12346,
      "variantTitle": "Morning Blend Coffee - Light Roast - 8oz"
    }
  ],
  [
    {
      "image": "https://cdn.shopify.com/files/1/0000/0000/products/dark-roast.jpg",
      "productId": "gid://shopify/Product/88765",
      "productTitle": "Bold Blend Coffee",
      "quantity": 2,
      "swapId": 1002,
      "title": "Dark Roast - 12oz",
      "variantId": 67890,
      "variantTitle": "Bold Blend Coffee - Dark Roast - 12oz"
    }
  ]
]
{
"detail": "Contract does not belong to this shop",
"status": 400,
"title": "Invalid contract",
"type": "https://example.com/errors/bad-request"
}
{
"detail": "Valid X-API-Key header is required",
"status": 401,
"title": "Authentication required",
"type": "https://example.com/errors/unauthorized"
}
{
"detail": "API key does not have permission to view product swaps",
"status": 403,
"title": "Insufficient permissions",
"type": "https://example.com/errors/forbidden"
}
{
"detail": "No product swap variant groups available for this contract",
"status": 404,
"title": "No swap groups found",
"type": "https://example.com/errors/not-found"
}

Headers

X-API-Key
string

Path Parameters

contractId
integer<int64>
required

Query Parameters

api_key
string

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

Body

application/json

VariantQuantityInfo payload

variantQuantityList
object[]

Response

Product swap variant groups returned successfully - Returns swappable variants for the next 10 billing cycles. Each element in the outer array represents the variants that will be swapped to for a specific billing cycle.