Create a new subscription contract
Creates a subscription contract for a customer, with the products, billing frequency and delivery details you send. The contract is created in Shopify and synchronized with Appstle.
Before you start: This endpoint is the API form of manual subscription creation in the Appstle Subscriptions app, so the same requirements apply. A call that doesn’t meet one returns a 400:
- The store’s Appstle plan includes manual subscription creation
- Manual subscription creation is unlocked for the store. If it’s locked, the merchant can ask Appstle support to unlock it
- The store has enough existing subscriptions. The Help Center article Manually create a subscription gives the minimum
- The customer has fewer subscriptions than the limit for one customer, cancelled ones included. The 400 names the limit
Selling plans with fixed billing dates aren’t supported: a request whose sellingPlanId points to one returns a 400.
Required fields:
customerId,nextBillingDate,billingIntervalType,billingIntervalCountand the productlines, each with avariantIdand aquantity- A price on every line:
unitPrice, the base price per unit. A line without asellingPlanIdcan sendcurrentPriceinstead deliveryIntervalTypeanddeliveryIntervalCount, the delivery frequency. For one delivery per billing period, send the same values asbillingIntervalTypeandbillingIntervalCount- The delivery address for shipping, the default
methodType:deliveryAddress1,deliveryCityanddeliveryCountryCode. Shopify also checks the address, so a US address needsdeliveryLastName,deliveryZipanddeliveryProvinceCodeas well. Other countries can need different fields - For local delivery (
LOCAL), the address anddeliveryPhone. For local pickup (PICK_UP),locationIdinstead of an address
A request that’s missing nextBillingDate, a line price or deliveryIntervalCount returns a 400 whose message isn’t a validation message. A missing nextBillingDate, for example, returns temporal. Check these fields before you send the request.
A 400 from Shopify’s address check names one problem at a time, such as UserGeneratedError:Enter a last name., UserGeneratedError:Enter a ZIP / postal code. or UserGeneratedError:Choose a state / province. Send the whole address in your first request.
Status:
status is optional. When the customer’s payment method is used and you omit status, the contract is created PAUSED. To create an active subscription, send status ACTIVE. With createWithoutPaymentMethod set to true, status is ignored: the contract is PAUSED, or ACTIVE when skipPaymentCreateUnpaidOrder is true.
Payment method:
If you omit paymentMethodId, the customer’s only payment method is used. A customer with more than one returns a 400, so send paymentMethodId for them. A customer with none returns a 400 too, unless you set createWithoutPaymentMethod to true.
Important notes:
- Each call that succeeds creates a new contract, and the endpoint takes no idempotency key. Before you retry a call that timed out, check the customer’s subscriptions so you don’t create a second one
- This endpoint counts toward the five writes a store can have in progress at once, and after five error responses in a minute it accepts only 10 calls a minute. Fix a 400 before you retry. See Rate limits
- All monetary values are in the store’s base currency unless
currencyCodeis specified customAttributesand line itemcustomAttributesuse Shopify’s AttributeInput format:{"key": "string", "value": "string"}
Pricing policy types (linePricingPolicy, for a line with a sellingPlanId):
SELLING_PLAN_PRICING_POLICY(the default): the selling plan’s discountsCUSTOM_PRICING_POLICY: the discount cycles you send in the line’spricingPolicyarrayNO_PRICING_POLICY: no discount. The line is chargedcurrentPrice, orunitPriceif you omit it
Authentication: Requires valid X-API-Key header
curl --request POST \
--url https://subscription-admin.appstle.com/api/external/v2/subscription-contract-details/create-subscription-contract \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <x-api-key>' \
--data '
{
"billingIntervalCount": 1,
"billingIntervalType": "MONTH",
"customerId": "300000000001",
"deliveryAddress1": "123 Main St",
"deliveryCity": "Portland",
"deliveryCountryCode": "US",
"deliveryIntervalCount": 1,
"deliveryIntervalType": "MONTH",
"lines": [
{
"quantity": 1,
"sellingPlanId": "800000000001",
"unitPrice": 14.99,
"variantId": "50000000000001"
}
],
"nextBillingDate": "2026-12-15T00:00:00Z"
}
'import requests
url = "https://subscription-admin.appstle.com/api/external/v2/subscription-contract-details/create-subscription-contract"
payload = {
"billingIntervalCount": 1,
"billingIntervalType": "MONTH",
"customerId": "300000000001",
"deliveryAddress1": "123 Main St",
"deliveryCity": "Portland",
"deliveryCountryCode": "US",
"deliveryIntervalCount": 1,
"deliveryIntervalType": "MONTH",
"lines": [
{
"quantity": 1,
"sellingPlanId": "800000000001",
"unitPrice": 14.99,
"variantId": "50000000000001"
}
],
"nextBillingDate": "2026-12-15T00:00:00Z"
}
headers = {
"X-API-Key": "<x-api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<x-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
billingIntervalCount: 1,
billingIntervalType: 'MONTH',
customerId: '300000000001',
deliveryAddress1: '123 Main St',
deliveryCity: 'Portland',
deliveryCountryCode: 'US',
deliveryIntervalCount: 1,
deliveryIntervalType: 'MONTH',
lines: [
{
quantity: 1,
sellingPlanId: '800000000001',
unitPrice: 14.99,
variantId: '50000000000001'
}
],
nextBillingDate: '2026-12-15T00:00:00Z'
})
};
fetch('https://subscription-admin.appstle.com/api/external/v2/subscription-contract-details/create-subscription-contract', 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-contract-details/create-subscription-contract';
const options = {
method: 'POST',
headers: {'X-API-Key': '<x-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
billingIntervalCount: 1,
billingIntervalType: 'MONTH',
customerId: '300000000001',
deliveryAddress1: '123 Main St',
deliveryCity: 'Portland',
deliveryCountryCode: 'US',
deliveryIntervalCount: 1,
deliveryIntervalType: 'MONTH',
lines: [
{
quantity: 1,
sellingPlanId: '800000000001',
unitPrice: 14.99,
variantId: '50000000000001'
}
],
nextBillingDate: '2026-12-15T00:00:00Z'
})
};
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-contract-details/create-subscription-contract",
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([
'billingIntervalCount' => 1,
'billingIntervalType' => 'MONTH',
'customerId' => '300000000001',
'deliveryAddress1' => '123 Main St',
'deliveryCity' => 'Portland',
'deliveryCountryCode' => 'US',
'deliveryIntervalCount' => 1,
'deliveryIntervalType' => 'MONTH',
'lines' => [
[
'quantity' => 1,
'sellingPlanId' => '800000000001',
'unitPrice' => 14.99,
'variantId' => '50000000000001'
]
],
'nextBillingDate' => '2026-12-15T00:00:00Z'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"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"
"strings"
"net/http"
"io"
)
func main() {
url := "https://subscription-admin.appstle.com/api/external/v2/subscription-contract-details/create-subscription-contract"
payload := strings.NewReader("{\n \"billingIntervalCount\": 1,\n \"billingIntervalType\": \"MONTH\",\n \"customerId\": \"300000000001\",\n \"deliveryAddress1\": \"123 Main St\",\n \"deliveryCity\": \"Portland\",\n \"deliveryCountryCode\": \"US\",\n \"deliveryIntervalCount\": 1,\n \"deliveryIntervalType\": \"MONTH\",\n \"lines\": [\n {\n \"quantity\": 1,\n \"sellingPlanId\": \"800000000001\",\n \"unitPrice\": 14.99,\n \"variantId\": \"50000000000001\"\n }\n ],\n \"nextBillingDate\": \"2026-12-15T00:00:00Z\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<x-api-key>")
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/subscription-contract-details/create-subscription-contract")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<x-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"billingIntervalCount\": 1,\n \"billingIntervalType\": \"MONTH\",\n \"customerId\": \"300000000001\",\n \"deliveryAddress1\": \"123 Main St\",\n \"deliveryCity\": \"Portland\",\n \"deliveryCountryCode\": \"US\",\n \"deliveryIntervalCount\": 1,\n \"deliveryIntervalType\": \"MONTH\",\n \"lines\": [\n {\n \"quantity\": 1,\n \"sellingPlanId\": \"800000000001\",\n \"unitPrice\": 14.99,\n \"variantId\": \"50000000000001\"\n }\n ],\n \"nextBillingDate\": \"2026-12-15T00:00:00Z\"\n}"
response = http.request(request)
puts response.read_body{
"billingAttempts": {
"nodes": []
},
"billingPolicy": {
"anchors": [],
"interval": "MONTH",
"intervalCount": 1,
"maxCycles": null,
"minCycles": null
},
"createdAt": "2026-11-10T01:47:04Z",
"customAttributes": [],
"customer": {
"displayName": "Maya Brooks",
"email": "maya.brooks@example.com",
"firstName": "Maya",
"id": "gid://shopify/Customer/300000000001",
"lastName": "Brooks",
"phone": null
},
"deliveryMethod": {
"address": {
"address1": "123 Main St",
"city": "Portland",
"countryCode": "US",
"firstName": "Maya",
"lastName": "Brooks",
"provinceCode": "OR",
"zip": "97205"
}
},
"deliveryPolicy": {
"anchors": [],
"interval": "MONTH",
"intervalCount": 1
},
"deliveryPrice": {
"amount": "0.0",
"currencyCode": "USD"
},
"id": "gid://shopify/SubscriptionContract/100000000001",
"lastPaymentStatus": null,
"lines": {
"nodes": [
{
"currentPrice": {
"amount": "13.49",
"currencyCode": "USD"
},
"id": "gid://shopify/SubscriptionLine/11111111-2222-4333-8444-555555555551",
"pricingPolicy": {
"basePrice": {
"amount": "14.99",
"currencyCode": "USD"
},
"cycleDiscounts": [
{
"adjustmentType": "PERCENTAGE",
"adjustmentValue": {
"percentage": 10
},
"afterCycle": 0,
"computedPrice": {
"amount": "13.49",
"currencyCode": "USD"
}
}
]
},
"productId": "gid://shopify/Product/9000000000001",
"quantity": 1,
"sellingPlanId": "gid://shopify/SellingPlan/800000000001",
"sellingPlanName": "Monthly Subscription",
"title": "House Blend Coffee",
"variantId": "gid://shopify/ProductVariant/50000000000001"
}
]
},
"nextBillingDate": "2026-12-15T00:00:00Z",
"note": null,
"status": "PAUSED",
"updatedAt": "2026-11-10T01:47:04Z"
}Body
Request object for creating a new subscription contract
Initial status of the subscription contract. If omitted, the contract is created PAUSED. Ignored when createWithoutPaymentMethod is true.
ACTIVE, PAUSED, CANCELLED, EXPIRED, FAILED, $UNKNOWN, ACTIVE, PAUSED, CANCELLED, EXPIRED, FAILED "ACTIVE"
Response
Subscription contract created. The example is trimmed
curl --request POST \
--url https://subscription-admin.appstle.com/api/external/v2/subscription-contract-details/create-subscription-contract \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <x-api-key>' \
--data '
{
"billingIntervalCount": 1,
"billingIntervalType": "MONTH",
"customerId": "300000000001",
"deliveryAddress1": "123 Main St",
"deliveryCity": "Portland",
"deliveryCountryCode": "US",
"deliveryIntervalCount": 1,
"deliveryIntervalType": "MONTH",
"lines": [
{
"quantity": 1,
"sellingPlanId": "800000000001",
"unitPrice": 14.99,
"variantId": "50000000000001"
}
],
"nextBillingDate": "2026-12-15T00:00:00Z"
}
'import requests
url = "https://subscription-admin.appstle.com/api/external/v2/subscription-contract-details/create-subscription-contract"
payload = {
"billingIntervalCount": 1,
"billingIntervalType": "MONTH",
"customerId": "300000000001",
"deliveryAddress1": "123 Main St",
"deliveryCity": "Portland",
"deliveryCountryCode": "US",
"deliveryIntervalCount": 1,
"deliveryIntervalType": "MONTH",
"lines": [
{
"quantity": 1,
"sellingPlanId": "800000000001",
"unitPrice": 14.99,
"variantId": "50000000000001"
}
],
"nextBillingDate": "2026-12-15T00:00:00Z"
}
headers = {
"X-API-Key": "<x-api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<x-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
billingIntervalCount: 1,
billingIntervalType: 'MONTH',
customerId: '300000000001',
deliveryAddress1: '123 Main St',
deliveryCity: 'Portland',
deliveryCountryCode: 'US',
deliveryIntervalCount: 1,
deliveryIntervalType: 'MONTH',
lines: [
{
quantity: 1,
sellingPlanId: '800000000001',
unitPrice: 14.99,
variantId: '50000000000001'
}
],
nextBillingDate: '2026-12-15T00:00:00Z'
})
};
fetch('https://subscription-admin.appstle.com/api/external/v2/subscription-contract-details/create-subscription-contract', 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-contract-details/create-subscription-contract';
const options = {
method: 'POST',
headers: {'X-API-Key': '<x-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
billingIntervalCount: 1,
billingIntervalType: 'MONTH',
customerId: '300000000001',
deliveryAddress1: '123 Main St',
deliveryCity: 'Portland',
deliveryCountryCode: 'US',
deliveryIntervalCount: 1,
deliveryIntervalType: 'MONTH',
lines: [
{
quantity: 1,
sellingPlanId: '800000000001',
unitPrice: 14.99,
variantId: '50000000000001'
}
],
nextBillingDate: '2026-12-15T00:00:00Z'
})
};
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-contract-details/create-subscription-contract",
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([
'billingIntervalCount' => 1,
'billingIntervalType' => 'MONTH',
'customerId' => '300000000001',
'deliveryAddress1' => '123 Main St',
'deliveryCity' => 'Portland',
'deliveryCountryCode' => 'US',
'deliveryIntervalCount' => 1,
'deliveryIntervalType' => 'MONTH',
'lines' => [
[
'quantity' => 1,
'sellingPlanId' => '800000000001',
'unitPrice' => 14.99,
'variantId' => '50000000000001'
]
],
'nextBillingDate' => '2026-12-15T00:00:00Z'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"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"
"strings"
"net/http"
"io"
)
func main() {
url := "https://subscription-admin.appstle.com/api/external/v2/subscription-contract-details/create-subscription-contract"
payload := strings.NewReader("{\n \"billingIntervalCount\": 1,\n \"billingIntervalType\": \"MONTH\",\n \"customerId\": \"300000000001\",\n \"deliveryAddress1\": \"123 Main St\",\n \"deliveryCity\": \"Portland\",\n \"deliveryCountryCode\": \"US\",\n \"deliveryIntervalCount\": 1,\n \"deliveryIntervalType\": \"MONTH\",\n \"lines\": [\n {\n \"quantity\": 1,\n \"sellingPlanId\": \"800000000001\",\n \"unitPrice\": 14.99,\n \"variantId\": \"50000000000001\"\n }\n ],\n \"nextBillingDate\": \"2026-12-15T00:00:00Z\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<x-api-key>")
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/subscription-contract-details/create-subscription-contract")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<x-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"billingIntervalCount\": 1,\n \"billingIntervalType\": \"MONTH\",\n \"customerId\": \"300000000001\",\n \"deliveryAddress1\": \"123 Main St\",\n \"deliveryCity\": \"Portland\",\n \"deliveryCountryCode\": \"US\",\n \"deliveryIntervalCount\": 1,\n \"deliveryIntervalType\": \"MONTH\",\n \"lines\": [\n {\n \"quantity\": 1,\n \"sellingPlanId\": \"800000000001\",\n \"unitPrice\": 14.99,\n \"variantId\": \"50000000000001\"\n }\n ],\n \"nextBillingDate\": \"2026-12-15T00:00:00Z\"\n}"
response = http.request(request)
puts response.read_body{
"billingAttempts": {
"nodes": []
},
"billingPolicy": {
"anchors": [],
"interval": "MONTH",
"intervalCount": 1,
"maxCycles": null,
"minCycles": null
},
"createdAt": "2026-11-10T01:47:04Z",
"customAttributes": [],
"customer": {
"displayName": "Maya Brooks",
"email": "maya.brooks@example.com",
"firstName": "Maya",
"id": "gid://shopify/Customer/300000000001",
"lastName": "Brooks",
"phone": null
},
"deliveryMethod": {
"address": {
"address1": "123 Main St",
"city": "Portland",
"countryCode": "US",
"firstName": "Maya",
"lastName": "Brooks",
"provinceCode": "OR",
"zip": "97205"
}
},
"deliveryPolicy": {
"anchors": [],
"interval": "MONTH",
"intervalCount": 1
},
"deliveryPrice": {
"amount": "0.0",
"currencyCode": "USD"
},
"id": "gid://shopify/SubscriptionContract/100000000001",
"lastPaymentStatus": null,
"lines": {
"nodes": [
{
"currentPrice": {
"amount": "13.49",
"currencyCode": "USD"
},
"id": "gid://shopify/SubscriptionLine/11111111-2222-4333-8444-555555555551",
"pricingPolicy": {
"basePrice": {
"amount": "14.99",
"currencyCode": "USD"
},
"cycleDiscounts": [
{
"adjustmentType": "PERCENTAGE",
"adjustmentValue": {
"percentage": 10
},
"afterCycle": 0,
"computedPrice": {
"amount": "13.49",
"currencyCode": "USD"
}
}
]
},
"productId": "gid://shopify/Product/9000000000001",
"quantity": 1,
"sellingPlanId": "gid://shopify/SellingPlan/800000000001",
"sellingPlanName": "Monthly Subscription",
"title": "House Blend Coffee",
"variantId": "gid://shopify/ProductVariant/50000000000001"
}
]
},
"nextBillingDate": "2026-12-15T00:00:00Z",
"note": null,
"status": "PAUSED",
"updatedAt": "2026-11-10T01:47:04Z"
}