Comprehensive API documentation for managing subscriptions, payments, and related operations. These APIs allow you to programmatically manage subscription lifecycles, handle payments, configure products, and integrate subscription functionality into your applications.
- Replace product variants in a subscription contract
External APIs (0.0.1)
Request
Creates a new subscription contract by either splitting (moving) or duplicating selected line items from an existing contract. This endpoint allows you to divide a subscription into multiple contracts or create a copy with specific products.
Split vs Duplicate Mode:
- Split (isSplitContract=true): Moves the selected line items from the original contract to a new contract. The original contract will no longer contain these items.
- Duplicate (isSplitContract=false): Creates a new contract with copies of the selected line items while keeping them in the original contract.
Important Notes:
- When splitting, at least one subscription product must remain in the original contract
- The new contract inherits all settings from the original: customer, payment method, billing/delivery policies, shipping address, and custom attributes
- Billing schedule is automatically generated for the new contract
- One-time products and free products don't count towards the minimum product requirement
Use Cases:
- Split a subscription when customer wants different delivery schedules for different products
- Create a gift subscription from an existing subscription
- Separate products for different shipping addresses
- Duplicate a subscription for testing or backup purposes
Authentication: Requires valid X-API-Key header
- https://subscription-admin.appstle.com/api/external/v2/subscription-contract-details/split-existing-contract
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X POST \
'https://subscription-admin.appstle.com/api/external/v2/subscription-contract-details/split-existing-contract?contractId=0&isSplitContract=false&attemptBilling=false&api_key=string' \
-H 'Content-Type: application/json' \
-H 'X-API-Key: string' \
-d '[
"string"
]'{ "id": "gid://shopify/SubscriptionContract/987654321", "status": "ACTIVE", "nextBillingDate": "2024-02-15T00:00:00Z", "originOrder": { "id": "gid://shopify/Order/123456789" }, "customer": { "id": "gid://shopify/Customer/111111", "email": "customer@example.com" }, "billingPolicy": { "interval": "MONTH", "intervalCount": 1 }, "deliveryPolicy": { "interval": "MONTH", "intervalCount": 1 }, "lines": { "edges": [ … ] }, "customAttributes": [ { … }, { … } ] }
Request
Replaces existing product variants with new ones in a subscription contract. This endpoint supports both regular subscription products and one-time products, allowing you to swap products, update quantities, and manage the product mix in a subscription.
Key Features:
- Bulk Replace: Replace multiple products at once by providing lists of old and new variants
- Line-Specific Replace: Target a specific line item using oldLineId for precise replacement
- Quantity Management: Set new quantities for replaced products
- One-Time Products: Add or remove one-time purchase products independently
- Discount Preservation: Configurable discount carry-forward logic
Discount Carry Forward Options:
- PRODUCT_THEN_EXISTING: First tries to apply the new product's selling plan discount, then falls back to existing discount
- PRODUCT_PLAN: Always uses the new product's selling plan discount
- EXISTING_PLAN: Maintains the existing product's discount structure
Important Notes:
- At least one regular subscription product must remain in the contract
- One-time products and free products don't count towards the minimum product requirement
- The system automatically handles pricing adjustments based on billing/delivery intervals
- Shipping prices are automatically recalculated after changes
Use Cases:
- Product upgrades/downgrades (e.g., switching coffee blend or size)
- Quantity adjustments during product swap
- Adding limited-time or seasonal products as one-time purchases
- Bulk product replacements for subscription migrations
Authentication: Requires valid X-API-Key header
List of variant IDs to remove from the subscription. These are numeric Shopify variant IDs. Either provide oldVariants OR oldLineId, not both.
Map of new variant IDs to their quantities. Key is the numeric Shopify variant ID, value is the desired quantity. If a variant already exists in the subscription and the system is configured to update existing quantities, the quantity will be added to the existing quantity.
Map of one-time product variant IDs to add with their quantities. These products will be charged only once with the next order and won't recur. Useful for add-ons, samples, or limited-time offers.
List of one-time product variant IDs to remove from the subscription. Only removes one-time products that haven't been fulfilled yet.
Specific subscription line ID to replace. Use this for targeted replacement of a single line item. When provided, oldVariants should be empty. Format: gid://shopify/SubscriptionLine/[ID]
Determines how discounts are applied to new products when replacing variants. If not specified, uses the merchant's default setting.
- https://subscription-admin.appstle.com/api/external/v2/subscription-contract-details/replace-variants-v3
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X POST \
'https://subscription-admin.appstle.com/api/external/v2/subscription-contract-details/replace-variants-v3?api_key=string' \
-H 'Content-Type: application/json' \
-H 'X-API-Key: string' \
-d '{
"shop": "abcStore.myshopify.com",
"contractId": 123456789,
"oldVariants": [
42549172011164,
42549172022222
],
"newVariants": {
"42549172033333": 2,
"42549172044444": 1
},
"newOneTimeVariants": {
"42549172066666": 1,
"42549172077777": 2
},
"oldOneTimeVariants": [
42549172055555,
42549172088888
],
"oldLineId": "gid://shopify/SubscriptionLine/987654321",
"eventSource": "CUSTOMER_PORTAL",
"carryForwardDiscount": "PRODUCT_THEN_EXISTING",
"stopSwapEmails": false
}'{ "id": "gid://shopify/SubscriptionContract/123456789", "status": "ACTIVE", "nextBillingDate": "2024-02-15T00:00:00Z", "lines": { "edges": [ … ] } }
Request
Creates a new subscription contract for a customer with specified products, billing frequency, and delivery details. This endpoint allows you to programmatically create subscriptions with custom pricing, delivery schedules, and multiple line items. The subscription will be created in Shopify and synchronized with the Appstle system.
Important Notes:
- Customer must have at least one valid payment method
- If paymentMethodId is not provided, the default payment method will be used
- If delivery interval is not specified, it defaults to the billing interval
- Custom pricing policies can be applied per line item
- All monetary values are in the store's base currency unless currencyCode is specified
- CustomAttributes and line item customAttributes use Shopify's AttributeInput format: {"key": "string", "value": "string"}
Pricing Policy Types:
- SELLING_PLAN_PRICING_POLICY: Uses the default pricing from the selling plan
- CUSTOM_PRICING_POLICY: Allows custom discount cycles defined in pricingPolicy array
- NO_PRICING_POLICY: Uses the base price without any discounts
Authentication: Requires valid X-API-Key header
Customer payment method ID. If not provided, the default payment method will be used. Can be null if createWithoutPaymentMethod is true.
If true, creates subscription without payment method. Status will be set to PAUSED. Charges cannot be processed until a valid payment method is added.
Initial status of the subscription contract
Date when the next billing/order will occur
Billing frequency interval type
Minimum number of billing cycles required before cancellation is allowed
Delivery frequency interval type. If not specified, uses billing interval
Number of intervals between deliveries. If not specified, uses billing interval count
Currency code for the subscription (ISO 4217). If not provided, uses store default currency
Product line items to include in the subscription
Shopify product variant ID (numeric ID without gid prefix)
Selling plan ID to apply to this line item. Required for subscription pricing
Current price per unit after discounts. If not provided, calculated from selling plan
Custom attributes for this line item
Pricing policy type for subscription line items
Allow customer to change delivery address in customer portal
- https://subscription-admin.appstle.com/api/external/v2/subscription-contract-details/create-subscription-contract
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X POST \
'https://subscription-admin.appstle.com/api/external/v2/subscription-contract-details/create-subscription-contract?api_key=string' \
-H 'Content-Type: application/json' \
-H 'X-API-Key: string' \
-d '{
"customerId": "987654321",
"paymentMethodId": "gid://shopify/CustomerPaymentMethod/abc123",
"createWithoutPaymentMethod": false,
"status": "ACTIVE",
"nextBillingDate": "2024-02-01T00:00:00Z",
"billingIntervalType": "MONTH",
"billingIntervalCount": 1,
"maxCycles": 12,
"minCycles": 3,
"deliveryIntervalType": "MONTH",
"deliveryIntervalCount": 1,
"deliveryFirstName": "John",
"deliveryLastName": "Doe",
"deliveryAddress1": "123 Main St",
"deliveryAddress2": "Apt 4B",
"deliveryProvinceCode": "NY",
"deliveryCity": "New York",
"deliveryZip": "10001",
"deliveryCountryCode": "US",
"deliveryPhone": "+1234567890",
"deliveryPriceAmount": 5.99,
"currencyCode": "USD",
"lines": [
{
"quantity": 2,
"variantId": "42549172011164",
"productId": "7234567890123",
"sellingPlanId": "gid://shopify/SellingPlan/123456",
"currentPrice": 25.99,
"unitPrice": 29.99,
"customAttributes": [
{
"key": "engraving",
"value": "Happy Birthday"
}
],
"linePricingPolicy": "SELLING_PLAN_PRICING_POLICY",
"pricingPolicy": [
{
"afterCycle": 3,
"discountType": "PERCENTAGE",
"value": 10,
"freeVariantId": 42549172011164,
"freeProductHandle": "free-gift-product",
"repeatingCycle": true,
"repeatingNumberOfCycle": 6,
"preventDuplicationFreeProduct": true
}
]
}
],
"allowDeliveryAddressOverride": false,
"allowDeliveryPriceOverride": false,
"customAttributes": [
{
"key": "subscription_type",
"value": "premium"
},
{
"key": "gift_message",
"value": "Happy Birthday!"
}
]
}'{ "id": "gid://shopify/SubscriptionContract/123456789", "status": "ACTIVE", "nextBillingDate": "2024-02-01T00:00:00Z", "billingPolicy": { "interval": "MONTH", "intervalCount": 1, "minCycles": 3, "maxCycles": 12 }, "deliveryPolicy": { "interval": "MONTH", "intervalCount": 1 }, "customer": { "id": "gid://shopify/Customer/987654321", "email": "customer@example.com", "firstName": "John", "lastName": "Doe" }, "deliveryPrice": { "amount": "5.99", "currencyCode": "USD" }, "lines": { "edges": [ … ] } }