Skip to main content
POST
/
api
/
external
/
v2
/
product-swaps-by-variant-groups
Get product swap options for subscription items
curl --request POST \
  --url https://membership-admin.appstle.com/api/external/v2/product-swaps-by-variant-groups \
  --header 'Content-Type: application/json' \
  --data '
{
  "variantQuantityList": [
    {
      "quantity": 2,
      "variantId": 123456
    },
    {
      "quantity": 1,
      "variantId": 789012
    }
  ]
}
'
import requests

url = "https://membership-admin.appstle.com/api/external/v2/product-swaps-by-variant-groups"

payload = { "variantQuantityList": [
{
"quantity": 2,
"variantId": 123456
},
{
"quantity": 1,
"variantId": 789012
}
] }
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, variantId: 123456}, {quantity: 1, variantId: 789012}]
})
};

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

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/product-swaps-by-variant-groups",
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,
'variantId' => 123456
],
[
'quantity' => 1,
'variantId' => 789012
]
]
]),
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/product-swaps-by-variant-groups"

payload := strings.NewReader("{\n \"variantQuantityList\": [\n {\n \"quantity\": 2,\n \"variantId\": 123456\n },\n {\n \"quantity\": 1,\n \"variantId\": 789012\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://membership-admin.appstle.com/api/external/v2/product-swaps-by-variant-groups")

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 \"variantId\": 123456\n },\n {\n \"quantity\": 1,\n \"variantId\": 789012\n }\n ]\n}"

response = http.request(request)
puts response.read_body
"<array>"
[
[
{
"image": "<string>",
"productId": "<string>",
"productTitle": "<string>",
"quantity": 123,
"sellingPlanId": "<string>",
"title": "<string>",
"variantId": 123
}
]
]
[
[
{
"image": "<string>",
"productId": "<string>",
"productTitle": "<string>",
"quantity": 123,
"sellingPlanId": "<string>",
"title": "<string>",
"variantId": 123
}
]
]
[
[
{
"image": "<string>",
"productId": "<string>",
"productTitle": "<string>",
"quantity": 123,
"sellingPlanId": "<string>",
"title": "<string>",
"variantId": 123
}
]
]

Headers

X-API-Key
string

API Key for authentication (Preferred method - use this instead of api_key parameter)

Query Parameters

api_key
string

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

Body

application/json

List of variants with quantities to find swap options for

variantQuantityList
object[]

Response

Swap options successfully retrieved with up to 5 levels of suggestions