Product Catalog
Create a new product swap automation
deprecated
Creates a new product swap automation rule for the authenticated shop. Product swaps automatically replace products in subscription orders based on billing cycles or recurring schedules.
**Required Fields:**
- **shop**: Your Shopify shop domain
- **sourceVariants**: JSON string of variants to swap FROM (format: [{"id":12345,"quantity":2}])
- **destinationVariants**: JSON string of variants to swap TO (format: [{"id":67890,"quantity":2}])
- **name**: Descriptive name for this swap rule
**Optional Fields:**
- **forBillingCycle**: Specific cycle number when swap occurs (e.g., 4 = swap at 4th order). Leave null for recurring swaps.
- **checkForEveryRecurringOrder**: If true, applies swap to every order (overrides forBillingCycle)
- **updatedFirstOrder**: If true, can affect the first subscription order
- **changeNextOrderDateBy**: Days to adjust next order date after swap (positive or negative integer)
- **discountCarryForward**: How to handle discounts - NONE, PERCENTAGE, FIXED_AMOUNT, or PRICE
- **carryDiscountForward**: Legacy boolean field (deprecated, use discountCarryForward instead)
- **stopSwapEmails**: If true, suppresses customer notification emails about the swap
- **ruleSequence**: Priority order when multiple swaps apply (lower number = higher priority)
**Variant JSON Format:**
The API enriches your variant data with product details from Shopify. You only need to provide:
```json
[{"id": 12345, "quantity": 2}]
```
The response will include enriched data: displayName, imageSrc, productTitle, etc.
**Authentication:** Requires valid X-API-Key header
POST
/
api
/
external
/
v2
/
product-swaps
Create a new product swap automation
curl --request POST \
--url https://subscription-admin.appstle.com/api/external/v2/product-swaps \
--header 'Content-Type: application/json' \
--data '
{
"shop": "example-shop"
}
'import requests
url = "https://subscription-admin.appstle.com/api/external/v2/product-swaps"
payload = { "shop": "example-shop" }
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: 'example-shop'})
};
fetch('https://subscription-admin.appstle.com/api/external/v2/product-swaps', 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';
const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({shop: 'example-shop'})
};
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",
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' => 'example-shop'
]),
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"
payload := strings.NewReader("{\n \"shop\": \"example-shop\"\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")
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\": \"example-shop\"\n}"
response = http.request(request)
puts response.read_body{
"carryDiscountForward": false,
"changeNextOrderDateBy": null,
"checkForEveryRecurringOrder": false,
"destinationVariants": "[{\"id\":67890,\"displayName\":\"test-product\",\"imageSrc\":\"https://test.com/image.png\",\"quantity\":2}]",
"discountCarryForward": "NONE",
"forBillingCycle": 2,
"id": 10782,
"name": "swap test",
"ruleSequence": 0,
"shop": "example-shop",
"sourceVariants": "[{\"id\":12345,\"displayName\":\"test-product\",\"imageSrc\":\"https://test.com/image.png\",\"quantity\":2}]",
"stopSwapEmails": false,
"updatedFirstOrder": false
}{
"detail": "A new productSwap cannot already have an ID",
"status": 400,
"title": "A new productSwap cannot already have an ID",
"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 create product swaps",
"status": 403,
"title": "Insufficient permissions",
"type": "https://example.com/errors/forbidden"
}{
"detail": "Resource not found",
"status": 404,
"title": "Resource not found",
"type": "https://example.com/errors/not-found"
}{
"detail": "Cannot create product swap due to business rule violation",
"status": 422,
"title": "Business rule violation",
"type": "https://example.com/errors/unprocessable-entity"
}Headers
Body
application/json
ProductSwapDTO payload
Available options:
NONE, EXISTING_PLAN, PRODUCT_PLAN, PRODUCT_THEN_EXISTING Response
Product swap created successfully
Available options:
NONE, EXISTING_PLAN, PRODUCT_PLAN, PRODUCT_THEN_EXISTING ⌘I
Create a new product swap automation
curl --request POST \
--url https://subscription-admin.appstle.com/api/external/v2/product-swaps \
--header 'Content-Type: application/json' \
--data '
{
"shop": "example-shop"
}
'import requests
url = "https://subscription-admin.appstle.com/api/external/v2/product-swaps"
payload = { "shop": "example-shop" }
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: 'example-shop'})
};
fetch('https://subscription-admin.appstle.com/api/external/v2/product-swaps', 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';
const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({shop: 'example-shop'})
};
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",
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' => 'example-shop'
]),
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"
payload := strings.NewReader("{\n \"shop\": \"example-shop\"\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")
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\": \"example-shop\"\n}"
response = http.request(request)
puts response.read_body{
"carryDiscountForward": false,
"changeNextOrderDateBy": null,
"checkForEveryRecurringOrder": false,
"destinationVariants": "[{\"id\":67890,\"displayName\":\"test-product\",\"imageSrc\":\"https://test.com/image.png\",\"quantity\":2}]",
"discountCarryForward": "NONE",
"forBillingCycle": 2,
"id": 10782,
"name": "swap test",
"ruleSequence": 0,
"shop": "example-shop",
"sourceVariants": "[{\"id\":12345,\"displayName\":\"test-product\",\"imageSrc\":\"https://test.com/image.png\",\"quantity\":2}]",
"stopSwapEmails": false,
"updatedFirstOrder": false
}{
"detail": "A new productSwap cannot already have an ID",
"status": 400,
"title": "A new productSwap cannot already have an ID",
"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 create product swaps",
"status": 403,
"title": "Insufficient permissions",
"type": "https://example.com/errors/forbidden"
}{
"detail": "Resource not found",
"status": 404,
"title": "Resource not found",
"type": "https://example.com/errors/not-found"
}{
"detail": "Cannot create product swap due to business rule violation",
"status": 422,
"title": "Business rule violation",
"type": "https://example.com/errors/unprocessable-entity"
}