Skip to main content
PUT
/
api
/
external
/
v2
/
product-swaps
Update an existing product swap automation
curl --request PUT \
  --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.put(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'PUT',
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: 'PUT',
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 => "PUT",
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("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/product-swaps")

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 \"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": "Invalid id",
"status": 400,
"title": "Invalid 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 update 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 update product swap due to business rule violation",
"status": 422,
"title": "Business rule violation",
"type": "https://example.com/errors/unprocessable-entity"
}

Headers

X-API-Key
string

Body

application/json

ProductSwapDTO payload

shop
string
required
carryDiscountForward
boolean
changeNextOrderDateBy
integer<int32>
checkForEveryRecurringOrder
boolean
destinationVariants
string
discountCarryForward
enum<string>
Available options:
NONE,
EXISTING_PLAN,
PRODUCT_PLAN,
PRODUCT_THEN_EXISTING
forBillingCycle
integer<int32>
id
integer<int64>
name
string
ruleSequence
integer<int32>
sourceVariants
string
stopSwapEmails
boolean
updatedFirstOrder
boolean

Response

Product swap updated successfully

shop
string
required
carryDiscountForward
boolean
changeNextOrderDateBy
integer<int32>
checkForEveryRecurringOrder
boolean
destinationVariants
string
discountCarryForward
enum<string>
Available options:
NONE,
EXISTING_PLAN,
PRODUCT_PLAN,
PRODUCT_THEN_EXISTING
forBillingCycle
integer<int32>
id
integer<int64>
name
string
ruleSequence
integer<int32>
sourceVariants
string
stopSwapEmails
boolean
updatedFirstOrder
boolean