Create a new subscription contract
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": "987654321",
"deliveryAddress1": "123 Main St",
"deliveryCity": "New York",
"deliveryCountryCode": "US",
"lines": [
{
"quantity": 2,
"variantId": "42549172011164",
"currentPrice": 25.99,
"customAttributes": [
{
"key": "engraving",
"value": "Happy Birthday"
}
],
"linePricingPolicy": "SELLING_PLAN_PRICING_POLICY",
"pricingPolicy": [
{
"afterCycle": 3,
"discountType": "PERCENTAGE",
"freeProductHandle": "free-gift-product",
"freeProductImage": "https://cdn.shopify.com/s/files/1/0000/0000/products/mug.jpg",
"freeProductTitle": "Ceramic Mug",
"freeProducts": [
{
"freeProductHandle": "free-gift-product",
"freeProductImage": "https://cdn.shopify.com/s/files/1/0000/0000/products/mug.jpg",
"freeProductTitle": "Ceramic Mug",
"freeVariantId": 42549172011164
}
],
"freeVariantId": 42549172011164,
"preventDuplicationFreeProduct": true,
"repeatingCycle": true,
"repeatingNumberOfCycle": 6,
"tierRole": "<string>",
"value": 10
}
],
"productId": "7234567890123",
"sellingPlanId": "gid://shopify/SellingPlan/123456",
"unitPrice": 29.99
}
],
"nextBillingDate": "2024-02-01T00:00:00Z",
"status": "ACTIVE"
}
'import requests
url = "https://subscription-admin.appstle.com/api/external/v2/subscription-contract-details/create-subscription-contract"
payload = {
"billingIntervalCount": 1,
"billingIntervalType": "MONTH",
"customerId": "987654321",
"deliveryAddress1": "123 Main St",
"deliveryCity": "New York",
"deliveryCountryCode": "US",
"lines": [
{
"quantity": 2,
"variantId": "42549172011164",
"currentPrice": 25.99,
"customAttributes": [
{
"key": "engraving",
"value": "Happy Birthday"
}
],
"linePricingPolicy": "SELLING_PLAN_PRICING_POLICY",
"pricingPolicy": [
{
"afterCycle": 3,
"discountType": "PERCENTAGE",
"freeProductHandle": "free-gift-product",
"freeProductImage": "https://cdn.shopify.com/s/files/1/0000/0000/products/mug.jpg",
"freeProductTitle": "Ceramic Mug",
"freeProducts": [
{
"freeProductHandle": "free-gift-product",
"freeProductImage": "https://cdn.shopify.com/s/files/1/0000/0000/products/mug.jpg",
"freeProductTitle": "Ceramic Mug",
"freeVariantId": 42549172011164
}
],
"freeVariantId": 42549172011164,
"preventDuplicationFreeProduct": True,
"repeatingCycle": True,
"repeatingNumberOfCycle": 6,
"tierRole": "<string>",
"value": 10
}
],
"productId": "7234567890123",
"sellingPlanId": "gid://shopify/SellingPlan/123456",
"unitPrice": 29.99
}
],
"nextBillingDate": "2024-02-01T00:00:00Z",
"status": "ACTIVE"
}
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: '987654321',
deliveryAddress1: '123 Main St',
deliveryCity: 'New York',
deliveryCountryCode: 'US',
lines: [
{
quantity: 2,
variantId: '42549172011164',
currentPrice: 25.99,
customAttributes: [{key: 'engraving', value: 'Happy Birthday'}],
linePricingPolicy: 'SELLING_PLAN_PRICING_POLICY',
pricingPolicy: [
{
afterCycle: 3,
discountType: 'PERCENTAGE',
freeProductHandle: 'free-gift-product',
freeProductImage: 'https://cdn.shopify.com/s/files/1/0000/0000/products/mug.jpg',
freeProductTitle: 'Ceramic Mug',
freeProducts: [
{
freeProductHandle: 'free-gift-product',
freeProductImage: 'https://cdn.shopify.com/s/files/1/0000/0000/products/mug.jpg',
freeProductTitle: 'Ceramic Mug',
freeVariantId: 42549172011164
}
],
freeVariantId: 42549172011164,
preventDuplicationFreeProduct: true,
repeatingCycle: true,
repeatingNumberOfCycle: 6,
tierRole: '<string>',
value: 10
}
],
productId: '7234567890123',
sellingPlanId: 'gid://shopify/SellingPlan/123456',
unitPrice: 29.99
}
],
nextBillingDate: '2024-02-01T00:00:00Z',
status: 'ACTIVE'
})
};
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: '987654321',
deliveryAddress1: '123 Main St',
deliveryCity: 'New York',
deliveryCountryCode: 'US',
lines: [
{
quantity: 2,
variantId: '42549172011164',
currentPrice: 25.99,
customAttributes: [{key: 'engraving', value: 'Happy Birthday'}],
linePricingPolicy: 'SELLING_PLAN_PRICING_POLICY',
pricingPolicy: [
{
afterCycle: 3,
discountType: 'PERCENTAGE',
freeProductHandle: 'free-gift-product',
freeProductImage: 'https://cdn.shopify.com/s/files/1/0000/0000/products/mug.jpg',
freeProductTitle: 'Ceramic Mug',
freeProducts: [
{
freeProductHandle: 'free-gift-product',
freeProductImage: 'https://cdn.shopify.com/s/files/1/0000/0000/products/mug.jpg',
freeProductTitle: 'Ceramic Mug',
freeVariantId: 42549172011164
}
],
freeVariantId: 42549172011164,
preventDuplicationFreeProduct: true,
repeatingCycle: true,
repeatingNumberOfCycle: 6,
tierRole: '<string>',
value: 10
}
],
productId: '7234567890123',
sellingPlanId: 'gid://shopify/SellingPlan/123456',
unitPrice: 29.99
}
],
nextBillingDate: '2024-02-01T00:00:00Z',
status: 'ACTIVE'
})
};
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' => '987654321',
'deliveryAddress1' => '123 Main St',
'deliveryCity' => 'New York',
'deliveryCountryCode' => 'US',
'lines' => [
[
'quantity' => 2,
'variantId' => '42549172011164',
'currentPrice' => 25.99,
'customAttributes' => [
[
'key' => 'engraving',
'value' => 'Happy Birthday'
]
],
'linePricingPolicy' => 'SELLING_PLAN_PRICING_POLICY',
'pricingPolicy' => [
[
'afterCycle' => 3,
'discountType' => 'PERCENTAGE',
'freeProductHandle' => 'free-gift-product',
'freeProductImage' => 'https://cdn.shopify.com/s/files/1/0000/0000/products/mug.jpg',
'freeProductTitle' => 'Ceramic Mug',
'freeProducts' => [
[
'freeProductHandle' => 'free-gift-product',
'freeProductImage' => 'https://cdn.shopify.com/s/files/1/0000/0000/products/mug.jpg',
'freeProductTitle' => 'Ceramic Mug',
'freeVariantId' => 42549172011164
]
],
'freeVariantId' => 42549172011164,
'preventDuplicationFreeProduct' => true,
'repeatingCycle' => true,
'repeatingNumberOfCycle' => 6,
'tierRole' => '<string>',
'value' => 10
]
],
'productId' => '7234567890123',
'sellingPlanId' => 'gid://shopify/SellingPlan/123456',
'unitPrice' => 29.99
]
],
'nextBillingDate' => '2024-02-01T00:00:00Z',
'status' => 'ACTIVE'
]),
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\": \"987654321\",\n \"deliveryAddress1\": \"123 Main St\",\n \"deliveryCity\": \"New York\",\n \"deliveryCountryCode\": \"US\",\n \"lines\": [\n {\n \"quantity\": 2,\n \"variantId\": \"42549172011164\",\n \"currentPrice\": 25.99,\n \"customAttributes\": [\n {\n \"key\": \"engraving\",\n \"value\": \"Happy Birthday\"\n }\n ],\n \"linePricingPolicy\": \"SELLING_PLAN_PRICING_POLICY\",\n \"pricingPolicy\": [\n {\n \"afterCycle\": 3,\n \"discountType\": \"PERCENTAGE\",\n \"freeProductHandle\": \"free-gift-product\",\n \"freeProductImage\": \"https://cdn.shopify.com/s/files/1/0000/0000/products/mug.jpg\",\n \"freeProductTitle\": \"Ceramic Mug\",\n \"freeProducts\": [\n {\n \"freeProductHandle\": \"free-gift-product\",\n \"freeProductImage\": \"https://cdn.shopify.com/s/files/1/0000/0000/products/mug.jpg\",\n \"freeProductTitle\": \"Ceramic Mug\",\n \"freeVariantId\": 42549172011164\n }\n ],\n \"freeVariantId\": 42549172011164,\n \"preventDuplicationFreeProduct\": true,\n \"repeatingCycle\": true,\n \"repeatingNumberOfCycle\": 6,\n \"tierRole\": \"<string>\",\n \"value\": 10\n }\n ],\n \"productId\": \"7234567890123\",\n \"sellingPlanId\": \"gid://shopify/SellingPlan/123456\",\n \"unitPrice\": 29.99\n }\n ],\n \"nextBillingDate\": \"2024-02-01T00:00:00Z\",\n \"status\": \"ACTIVE\"\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\": \"987654321\",\n \"deliveryAddress1\": \"123 Main St\",\n \"deliveryCity\": \"New York\",\n \"deliveryCountryCode\": \"US\",\n \"lines\": [\n {\n \"quantity\": 2,\n \"variantId\": \"42549172011164\",\n \"currentPrice\": 25.99,\n \"customAttributes\": [\n {\n \"key\": \"engraving\",\n \"value\": \"Happy Birthday\"\n }\n ],\n \"linePricingPolicy\": \"SELLING_PLAN_PRICING_POLICY\",\n \"pricingPolicy\": [\n {\n \"afterCycle\": 3,\n \"discountType\": \"PERCENTAGE\",\n \"freeProductHandle\": \"free-gift-product\",\n \"freeProductImage\": \"https://cdn.shopify.com/s/files/1/0000/0000/products/mug.jpg\",\n \"freeProductTitle\": \"Ceramic Mug\",\n \"freeProducts\": [\n {\n \"freeProductHandle\": \"free-gift-product\",\n \"freeProductImage\": \"https://cdn.shopify.com/s/files/1/0000/0000/products/mug.jpg\",\n \"freeProductTitle\": \"Ceramic Mug\",\n \"freeVariantId\": 42549172011164\n }\n ],\n \"freeVariantId\": 42549172011164,\n \"preventDuplicationFreeProduct\": true,\n \"repeatingCycle\": true,\n \"repeatingNumberOfCycle\": 6,\n \"tierRole\": \"<string>\",\n \"value\": 10\n }\n ],\n \"productId\": \"7234567890123\",\n \"sellingPlanId\": \"gid://shopify/SellingPlan/123456\",\n \"unitPrice\": 29.99\n }\n ],\n \"nextBillingDate\": \"2024-02-01T00:00:00Z\",\n \"status\": \"ACTIVE\"\n}"
response = http.request(request)
puts response.read_bodyHeaders
API Key
Query Parameters
API Key (Deprecated)
Body
Request object for creating a new subscription contract
Number of intervals between billings
x >= 11
Billing frequency interval type
DAY, WEEK, MONTH, YEAR, $UNKNOWN, DAY, WEEK, MONTH, YEAR "MONTH"
Shopify customer ID (numeric ID without gid prefix)
"987654321"
Delivery address line 1
"123 Main St"
Delivery address city
"New York"
Delivery address country code (ISO 3166-1 alpha-2)
"US"
Product line items to include in the subscription
Show child attributes
Show child attributes
Date when the next billing/order will occur
"2024-02-01T00:00:00Z"
Initial status of the subscription contract
ACTIVE, PAUSED, CANCELLED, EXPIRED, FAILED, $UNKNOWN, ACTIVE, PAUSED, CANCELLED, EXPIRED, FAILED "ACTIVE"
Allow customer to change delivery address in customer portal
false
Allow delivery price to be overridden
false
If true, creates subscription without payment method. Status will be set to PAUSED unless skipPaymentCreateUnpaidOrder is also true.
false
Currency code for the subscription (ISO 4217). If not provided, uses store default currency
"USD"
Custom attributes to attach to the subscription contract
Show child attributes
Show child attributes
[ { "key": "subscription_type", "value": "premium" }, { "key": "gift_message", "value": "Happy Birthday!" } ]
Delivery address line 2
"Apt 4B"
Delivery address first name
"John"
Number of intervals between deliveries. If not specified, uses billing interval count
x >= 11
Delivery frequency interval type. If not specified, uses billing interval
DAY, WEEK, MONTH, YEAR, $UNKNOWN, DAY, WEEK, MONTH, YEAR "MONTH"
Delivery address last name
"Doe"
Delivery phone number
"+1234567890"
Fixed delivery price amount in store currency
5.99
Delivery address province/state code (ISO 3166-2)
"NY"
Delivery address postal/zip code
"10001"
Shopify location ID used for local pickup. Required when methodType is PICK_UP
"gid://shopify/Location/123456789"
Maximum number of billing cycles. Null for unlimited
x >= 112
Delivery method. LOCAL requires deliveryPhone, PICK_UP requires locationId
SHIPPING, LOCAL, PICK_UP "SHIPPING"
Minimum number of billing cycles required before cancellation is allowed
x >= 13
Customer payment method ID. If not provided, the default payment method will be used. Can be null if createWithoutPaymentMethod is true.
"gid://shopify/CustomerPaymentMethod/abc123"
If true, billing attempts on this contract will create unpaid orders instead of failing when no payment method is present. Requires createWithoutPaymentMethod=true. Contract will be created as ACTIVE (not PAUSED) so billing can proceed.
false
Response
Subscription contract successfully created
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
SUCCEEDED, FAILED, $UNKNOWN Show child attributes
Show child attributes
Show child attributes
Show child attributes
ACTIVE, PAUSED, CANCELLED, EXPIRED, FAILED, $UNKNOWN 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": "987654321",
"deliveryAddress1": "123 Main St",
"deliveryCity": "New York",
"deliveryCountryCode": "US",
"lines": [
{
"quantity": 2,
"variantId": "42549172011164",
"currentPrice": 25.99,
"customAttributes": [
{
"key": "engraving",
"value": "Happy Birthday"
}
],
"linePricingPolicy": "SELLING_PLAN_PRICING_POLICY",
"pricingPolicy": [
{
"afterCycle": 3,
"discountType": "PERCENTAGE",
"freeProductHandle": "free-gift-product",
"freeProductImage": "https://cdn.shopify.com/s/files/1/0000/0000/products/mug.jpg",
"freeProductTitle": "Ceramic Mug",
"freeProducts": [
{
"freeProductHandle": "free-gift-product",
"freeProductImage": "https://cdn.shopify.com/s/files/1/0000/0000/products/mug.jpg",
"freeProductTitle": "Ceramic Mug",
"freeVariantId": 42549172011164
}
],
"freeVariantId": 42549172011164,
"preventDuplicationFreeProduct": true,
"repeatingCycle": true,
"repeatingNumberOfCycle": 6,
"tierRole": "<string>",
"value": 10
}
],
"productId": "7234567890123",
"sellingPlanId": "gid://shopify/SellingPlan/123456",
"unitPrice": 29.99
}
],
"nextBillingDate": "2024-02-01T00:00:00Z",
"status": "ACTIVE"
}
'import requests
url = "https://subscription-admin.appstle.com/api/external/v2/subscription-contract-details/create-subscription-contract"
payload = {
"billingIntervalCount": 1,
"billingIntervalType": "MONTH",
"customerId": "987654321",
"deliveryAddress1": "123 Main St",
"deliveryCity": "New York",
"deliveryCountryCode": "US",
"lines": [
{
"quantity": 2,
"variantId": "42549172011164",
"currentPrice": 25.99,
"customAttributes": [
{
"key": "engraving",
"value": "Happy Birthday"
}
],
"linePricingPolicy": "SELLING_PLAN_PRICING_POLICY",
"pricingPolicy": [
{
"afterCycle": 3,
"discountType": "PERCENTAGE",
"freeProductHandle": "free-gift-product",
"freeProductImage": "https://cdn.shopify.com/s/files/1/0000/0000/products/mug.jpg",
"freeProductTitle": "Ceramic Mug",
"freeProducts": [
{
"freeProductHandle": "free-gift-product",
"freeProductImage": "https://cdn.shopify.com/s/files/1/0000/0000/products/mug.jpg",
"freeProductTitle": "Ceramic Mug",
"freeVariantId": 42549172011164
}
],
"freeVariantId": 42549172011164,
"preventDuplicationFreeProduct": True,
"repeatingCycle": True,
"repeatingNumberOfCycle": 6,
"tierRole": "<string>",
"value": 10
}
],
"productId": "7234567890123",
"sellingPlanId": "gid://shopify/SellingPlan/123456",
"unitPrice": 29.99
}
],
"nextBillingDate": "2024-02-01T00:00:00Z",
"status": "ACTIVE"
}
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: '987654321',
deliveryAddress1: '123 Main St',
deliveryCity: 'New York',
deliveryCountryCode: 'US',
lines: [
{
quantity: 2,
variantId: '42549172011164',
currentPrice: 25.99,
customAttributes: [{key: 'engraving', value: 'Happy Birthday'}],
linePricingPolicy: 'SELLING_PLAN_PRICING_POLICY',
pricingPolicy: [
{
afterCycle: 3,
discountType: 'PERCENTAGE',
freeProductHandle: 'free-gift-product',
freeProductImage: 'https://cdn.shopify.com/s/files/1/0000/0000/products/mug.jpg',
freeProductTitle: 'Ceramic Mug',
freeProducts: [
{
freeProductHandle: 'free-gift-product',
freeProductImage: 'https://cdn.shopify.com/s/files/1/0000/0000/products/mug.jpg',
freeProductTitle: 'Ceramic Mug',
freeVariantId: 42549172011164
}
],
freeVariantId: 42549172011164,
preventDuplicationFreeProduct: true,
repeatingCycle: true,
repeatingNumberOfCycle: 6,
tierRole: '<string>',
value: 10
}
],
productId: '7234567890123',
sellingPlanId: 'gid://shopify/SellingPlan/123456',
unitPrice: 29.99
}
],
nextBillingDate: '2024-02-01T00:00:00Z',
status: 'ACTIVE'
})
};
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: '987654321',
deliveryAddress1: '123 Main St',
deliveryCity: 'New York',
deliveryCountryCode: 'US',
lines: [
{
quantity: 2,
variantId: '42549172011164',
currentPrice: 25.99,
customAttributes: [{key: 'engraving', value: 'Happy Birthday'}],
linePricingPolicy: 'SELLING_PLAN_PRICING_POLICY',
pricingPolicy: [
{
afterCycle: 3,
discountType: 'PERCENTAGE',
freeProductHandle: 'free-gift-product',
freeProductImage: 'https://cdn.shopify.com/s/files/1/0000/0000/products/mug.jpg',
freeProductTitle: 'Ceramic Mug',
freeProducts: [
{
freeProductHandle: 'free-gift-product',
freeProductImage: 'https://cdn.shopify.com/s/files/1/0000/0000/products/mug.jpg',
freeProductTitle: 'Ceramic Mug',
freeVariantId: 42549172011164
}
],
freeVariantId: 42549172011164,
preventDuplicationFreeProduct: true,
repeatingCycle: true,
repeatingNumberOfCycle: 6,
tierRole: '<string>',
value: 10
}
],
productId: '7234567890123',
sellingPlanId: 'gid://shopify/SellingPlan/123456',
unitPrice: 29.99
}
],
nextBillingDate: '2024-02-01T00:00:00Z',
status: 'ACTIVE'
})
};
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' => '987654321',
'deliveryAddress1' => '123 Main St',
'deliveryCity' => 'New York',
'deliveryCountryCode' => 'US',
'lines' => [
[
'quantity' => 2,
'variantId' => '42549172011164',
'currentPrice' => 25.99,
'customAttributes' => [
[
'key' => 'engraving',
'value' => 'Happy Birthday'
]
],
'linePricingPolicy' => 'SELLING_PLAN_PRICING_POLICY',
'pricingPolicy' => [
[
'afterCycle' => 3,
'discountType' => 'PERCENTAGE',
'freeProductHandle' => 'free-gift-product',
'freeProductImage' => 'https://cdn.shopify.com/s/files/1/0000/0000/products/mug.jpg',
'freeProductTitle' => 'Ceramic Mug',
'freeProducts' => [
[
'freeProductHandle' => 'free-gift-product',
'freeProductImage' => 'https://cdn.shopify.com/s/files/1/0000/0000/products/mug.jpg',
'freeProductTitle' => 'Ceramic Mug',
'freeVariantId' => 42549172011164
]
],
'freeVariantId' => 42549172011164,
'preventDuplicationFreeProduct' => true,
'repeatingCycle' => true,
'repeatingNumberOfCycle' => 6,
'tierRole' => '<string>',
'value' => 10
]
],
'productId' => '7234567890123',
'sellingPlanId' => 'gid://shopify/SellingPlan/123456',
'unitPrice' => 29.99
]
],
'nextBillingDate' => '2024-02-01T00:00:00Z',
'status' => 'ACTIVE'
]),
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\": \"987654321\",\n \"deliveryAddress1\": \"123 Main St\",\n \"deliveryCity\": \"New York\",\n \"deliveryCountryCode\": \"US\",\n \"lines\": [\n {\n \"quantity\": 2,\n \"variantId\": \"42549172011164\",\n \"currentPrice\": 25.99,\n \"customAttributes\": [\n {\n \"key\": \"engraving\",\n \"value\": \"Happy Birthday\"\n }\n ],\n \"linePricingPolicy\": \"SELLING_PLAN_PRICING_POLICY\",\n \"pricingPolicy\": [\n {\n \"afterCycle\": 3,\n \"discountType\": \"PERCENTAGE\",\n \"freeProductHandle\": \"free-gift-product\",\n \"freeProductImage\": \"https://cdn.shopify.com/s/files/1/0000/0000/products/mug.jpg\",\n \"freeProductTitle\": \"Ceramic Mug\",\n \"freeProducts\": [\n {\n \"freeProductHandle\": \"free-gift-product\",\n \"freeProductImage\": \"https://cdn.shopify.com/s/files/1/0000/0000/products/mug.jpg\",\n \"freeProductTitle\": \"Ceramic Mug\",\n \"freeVariantId\": 42549172011164\n }\n ],\n \"freeVariantId\": 42549172011164,\n \"preventDuplicationFreeProduct\": true,\n \"repeatingCycle\": true,\n \"repeatingNumberOfCycle\": 6,\n \"tierRole\": \"<string>\",\n \"value\": 10\n }\n ],\n \"productId\": \"7234567890123\",\n \"sellingPlanId\": \"gid://shopify/SellingPlan/123456\",\n \"unitPrice\": 29.99\n }\n ],\n \"nextBillingDate\": \"2024-02-01T00:00:00Z\",\n \"status\": \"ACTIVE\"\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\": \"987654321\",\n \"deliveryAddress1\": \"123 Main St\",\n \"deliveryCity\": \"New York\",\n \"deliveryCountryCode\": \"US\",\n \"lines\": [\n {\n \"quantity\": 2,\n \"variantId\": \"42549172011164\",\n \"currentPrice\": 25.99,\n \"customAttributes\": [\n {\n \"key\": \"engraving\",\n \"value\": \"Happy Birthday\"\n }\n ],\n \"linePricingPolicy\": \"SELLING_PLAN_PRICING_POLICY\",\n \"pricingPolicy\": [\n {\n \"afterCycle\": 3,\n \"discountType\": \"PERCENTAGE\",\n \"freeProductHandle\": \"free-gift-product\",\n \"freeProductImage\": \"https://cdn.shopify.com/s/files/1/0000/0000/products/mug.jpg\",\n \"freeProductTitle\": \"Ceramic Mug\",\n \"freeProducts\": [\n {\n \"freeProductHandle\": \"free-gift-product\",\n \"freeProductImage\": \"https://cdn.shopify.com/s/files/1/0000/0000/products/mug.jpg\",\n \"freeProductTitle\": \"Ceramic Mug\",\n \"freeVariantId\": 42549172011164\n }\n ],\n \"freeVariantId\": 42549172011164,\n \"preventDuplicationFreeProduct\": true,\n \"repeatingCycle\": true,\n \"repeatingNumberOfCycle\": 6,\n \"tierRole\": \"<string>\",\n \"value\": 10\n }\n ],\n \"productId\": \"7234567890123\",\n \"sellingPlanId\": \"gid://shopify/SellingPlan/123456\",\n \"unitPrice\": 29.99\n }\n ],\n \"nextBillingDate\": \"2024-02-01T00:00:00Z\",\n \"status\": \"ACTIVE\"\n}"
response = http.request(request)
puts response.read_body