Subscription Products
Remove product from subscription
Removes a specific product line item from an existing subscription contract. Can optionally retain prorated discounts associated with the removed product.
Key Features:
- Validates minimum subscription requirements before removal
- Handles discount cleanup for line-specific discounts
- Enforces minimum cycle commitments on products
- Supports Build-a-Box quantity validation
- Automatic retry on concurrent modification conflicts
- Email notifications for subscription changes
Validation Rules:
- At least one recurring subscription product must remain after removal
- One-time products and free products don’t count toward the minimum
- Products with minimum cycle commitments cannot be removed until fulfilled
- Build-a-Box subscriptions validate against minimum/maximum quantity rules
Discount Handling:
When removeDiscount=true (default):
- Discounts applied only to the removed line item are deleted
- Discounts applied to multiple line items are retained
- System automatically identifies which discounts to remove
Retry Mechanism: The endpoint automatically retries in these scenarios:
- Concurrent modification detected (another process updated the subscription)
- Invalid discount code errors (removes problematic discount and retries)
- This ensures reliable operation in high-traffic environments
Post-Removal Actions:
- Activity log created for audit trail
- Email notification sent to customer
- Shipping price recalculated asynchronously
- Build-a-Box discounts resynced if applicable
- Product-specific discounts resynced
Authentication: Requires valid X-API-Key header
PUT
/
api
/
external
/
v2
/
subscription-contracts-remove-line-item
Remove product from subscription
curl --request PUT \
--url https://subscription-admin.appstle.com/api/external/v2/subscription-contracts-remove-line-item \
--header 'X-API-Key: <x-api-key>'import requests
url = "https://subscription-admin.appstle.com/api/external/v2/subscription-contracts-remove-line-item"
headers = {"X-API-Key": "<x-api-key>"}
response = requests.put(url, headers=headers)
print(response.text)const options = {method: 'PUT', headers: {'X-API-Key': '<x-api-key>'}};
fetch('https://subscription-admin.appstle.com/api/external/v2/subscription-contracts-remove-line-item', 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/subscription-contracts-remove-line-item';
const options = {method: 'PUT', headers: {'X-API-Key': '<x-api-key>'}};
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/subscription-contracts-remove-line-item",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_HTTPHEADER => [
"X-API-Key: <x-api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://subscription-admin.appstle.com/api/external/v2/subscription-contracts-remove-line-item"
req, _ := http.NewRequest("PUT", url, nil)
req.Header.Add("X-API-Key", "<x-api-key>")
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/subscription-contracts-remove-line-item")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["X-API-Key"] = '<x-api-key>'
response = http.request(request)
puts response.read_body{
"billingPolicy": {
"interval": "MONTH",
"intervalCount": 1
},
"customer": {
"email": "customer@example.com",
"firstName": "John",
"id": "gid://shopify/Customer/987654321",
"lastName": "Doe"
},
"deliveryPolicy": {
"interval": "MONTH",
"intervalCount": 1
},
"discounts": {
"edges": [
{
"node": {
"id": "gid://shopify/SubscriptionManualDiscount/999999",
"targetType": "ALL_LINES",
"title": "10% OFF SUBSCRIPTION",
"value": {
"percentage": 10
}
}
}
]
},
"id": "gid://shopify/SubscriptionContract/123456789",
"lines": {
"edges": [
{
"node": {
"currentPrice": {
"amount": "29.99",
"currencyCode": "USD"
},
"id": "gid://shopify/SubscriptionLine/111111",
"quantity": 2,
"sellingPlanId": "gid://shopify/SellingPlan/123456",
"sellingPlanName": "Deliver every month",
"variantId": "gid://shopify/ProductVariant/42549172011164"
}
}
]
},
"nextBillingDate": "2024-03-01T00:00:00Z",
"status": "ACTIVE"
}Query Parameters
Controls whether to remove discounts that apply only to this line item. When true (default), line-specific discounts are removed. When false, attempts to retain discounts where possible. Note: Discounts that apply to multiple lines are always retained regardless of this setting
Response
Product successfully removed from subscription
⌘I
Remove product from subscription
curl --request PUT \
--url https://subscription-admin.appstle.com/api/external/v2/subscription-contracts-remove-line-item \
--header 'X-API-Key: <x-api-key>'import requests
url = "https://subscription-admin.appstle.com/api/external/v2/subscription-contracts-remove-line-item"
headers = {"X-API-Key": "<x-api-key>"}
response = requests.put(url, headers=headers)
print(response.text)const options = {method: 'PUT', headers: {'X-API-Key': '<x-api-key>'}};
fetch('https://subscription-admin.appstle.com/api/external/v2/subscription-contracts-remove-line-item', 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/subscription-contracts-remove-line-item';
const options = {method: 'PUT', headers: {'X-API-Key': '<x-api-key>'}};
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/subscription-contracts-remove-line-item",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_HTTPHEADER => [
"X-API-Key: <x-api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://subscription-admin.appstle.com/api/external/v2/subscription-contracts-remove-line-item"
req, _ := http.NewRequest("PUT", url, nil)
req.Header.Add("X-API-Key", "<x-api-key>")
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/subscription-contracts-remove-line-item")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["X-API-Key"] = '<x-api-key>'
response = http.request(request)
puts response.read_body{
"billingPolicy": {
"interval": "MONTH",
"intervalCount": 1
},
"customer": {
"email": "customer@example.com",
"firstName": "John",
"id": "gid://shopify/Customer/987654321",
"lastName": "Doe"
},
"deliveryPolicy": {
"interval": "MONTH",
"intervalCount": 1
},
"discounts": {
"edges": [
{
"node": {
"id": "gid://shopify/SubscriptionManualDiscount/999999",
"targetType": "ALL_LINES",
"title": "10% OFF SUBSCRIPTION",
"value": {
"percentage": 10
}
}
}
]
},
"id": "gid://shopify/SubscriptionContract/123456789",
"lines": {
"edges": [
{
"node": {
"currentPrice": {
"amount": "29.99",
"currencyCode": "USD"
},
"id": "gid://shopify/SubscriptionLine/111111",
"quantity": 2,
"sellingPlanId": "gid://shopify/SellingPlan/123456",
"sellingPlanName": "Deliver every month",
"variantId": "gid://shopify/ProductVariant/42549172011164"
}
}
]
},
"nextBillingDate": "2024-03-01T00:00:00Z",
"status": "ACTIVE"
}