Skip to content

External APIs (0.0.1)

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.

Languages
Servers
https://subscription-admin.appstle.com

Subscription Management

Core APIs for managing the complete subscription lifecycle including creation, updates, pausing, resuming, and cancellation of subscriptions.

Operations

Replace product variants in a subscription contract

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

Query
api_keystringDeprecated

API Key (Deprecated)

Headers
X-API-Keystringrequired

API Key

Bodyapplication/jsonrequired
shopstringrequired

The Shop of the subscription contract to modify

Example: "abcStore.myshopify.com"
contractIdinteger(int64)required

The ID of the subscription contract to modify

Example: 123456789
oldVariantsArray of integers(int64)

List of variant IDs to remove from the subscription. These are numeric Shopify variant IDs. Either provide oldVariants OR oldLineId, not both.

Example: [42549172011164,42549172022222]
newVariantsobject

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.

Example: {"42549172033333":2,"42549172044444":1}
newOneTimeVariantsobject

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.

Example: {"42549172066666":1,"42549172077777":2}
oldOneTimeVariantsArray of integers(int64)

List of one-time product variant IDs to remove from the subscription. Only removes one-time products that haven't been fulfilled yet.

Example: [42549172055555,42549172088888]
oldLineIdstring

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]

Example: "gid://shopify/SubscriptionLine/987654321"
eventSourcestring
Enum"CUSTOMER_PORTAL""MERCHANT_PORTAL""SHOPIFY_EVENT""SYSTEM_EVENT""MERCHANT_PORTAL_BULK_AUTOMATION""MERCHANT_EXTERNAL_API""SHOPIFY_FLOW"
carryForwardDiscountstring

Determines how discounts are applied to new products when replacing variants. If not specified, uses the merchant's default setting.

Enum"NONE""EXISTING_PLAN""PRODUCT_PLAN""PRODUCT_THEN_EXISTING""PRODUCT_THEN_EXISTING""PRODUCT_PLAN""EXISTING_PLAN"
Example: "PRODUCT_THEN_EXISTING"
stopSwapEmailsboolean

If true, suppresses email notifications about the product swap. Default is false (emails will be sent).

Default false
Example: false
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
  }'

Responses

Products successfully replaced

Bodyapplication/json
get__typenamestring
idstring
createdAtobject
updatedAtobject
nextBillingDateobject
statusstring
Enum"ACTIVE""PAUSED""CANCELLED""EXPIRED""FAILED""$UNKNOWN"
deliveryPriceobject(DeliveryPrice)
lastPaymentStatusstring
Enum"SUCCEEDED""FAILED""$UNKNOWN"
billingPolicyobject(BillingPolicy)
deliveryPolicyobject(DeliveryPolicy)
linesobject(Lines)
customerPaymentMethodobject(CustomerPaymentMethod)
deliveryMethodobject(DeliveryMethod)
originOrderobject(OriginOrder)
customerobject(Customer)
discountsobject(Discounts)
notestring
customAttributesArray of objects(CustomAttribute1)
billingAttemptsobject(BillingAttempts)
Response
application/json
{ "id": "gid://shopify/SubscriptionContract/123456789", "status": "ACTIVE", "nextBillingDate": "2024-02-15T00:00:00Z", "lines": { "edges": [] } }

Create a new subscription contract

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

Query
api_keystringDeprecated

API Key (Deprecated)

Headers
X-API-Keystringrequired

API Key

Bodyapplication/jsonrequired
customerIdstringrequired

Shopify customer ID (numeric ID without gid prefix)

Example: "987654321"
paymentMethodIdstring

Customer payment method ID. If not provided, the default payment method will be used. Can be null if createWithoutPaymentMethod is true.

Example: "gid://shopify/CustomerPaymentMethod/abc123"
createWithoutPaymentMethodboolean

If true, creates subscription without payment method. Status will be set to PAUSED. Charges cannot be processed until a valid payment method is added.

Default false
Example: false
statusstringrequired

Initial status of the subscription contract

Enum"ACTIVE""PAUSED""CANCELLED""EXPIRED""FAILED""$UNKNOWN""ACTIVE""PAUSED""CANCELLED""EXPIRED"
Example: "ACTIVE"
nextBillingDatestring(date-time)required

Date when the next billing/order will occur

Example: "2024-02-01T00:00:00Z"
billingIntervalTypestringrequired

Billing frequency interval type

Enum"DAY""WEEK""MONTH""YEAR""$UNKNOWN""DAY""WEEK""MONTH""YEAR"
Example: "MONTH"
billingIntervalCountinteger(int32)>= 1required

Number of intervals between billings

Example: 1
maxCyclesinteger(int32)>= 1

Maximum number of billing cycles. Null for unlimited

Example: 12
minCyclesinteger(int32)>= 1

Minimum number of billing cycles required before cancellation is allowed

Example: 3
deliveryIntervalTypestring

Delivery frequency interval type. If not specified, uses billing interval

Enum"DAY""WEEK""MONTH""YEAR""$UNKNOWN""DAY""WEEK""MONTH""YEAR"
Example: "MONTH"
deliveryIntervalCountinteger(int32)>= 1

Number of intervals between deliveries. If not specified, uses billing interval count

Example: 1
deliveryFirstNamestring

Delivery address first name

Example: "John"
deliveryLastNamestring

Delivery address last name

Example: "Doe"
deliveryAddress1stringrequired

Delivery address line 1

Example: "123 Main St"
deliveryAddress2string

Delivery address line 2

Example: "Apt 4B"
deliveryProvinceCodestring

Delivery address province/state code (ISO 3166-2)

Example: "NY"
deliveryCitystringrequired

Delivery address city

Example: "New York"
deliveryZipstring

Delivery address postal/zip code

Example: "10001"
deliveryCountryCodestringrequired

Delivery address country code (ISO 3166-1 alpha-2)

Example: "US"
deliveryPhonestring

Delivery phone number

Example: "+1234567890"
deliveryPriceAmountnumber(double)

Fixed delivery price amount in store currency

Example: 5.99
currencyCodestring

Currency code for the subscription (ISO 4217). If not provided, uses store default currency

Example: "USD"
linesArray of objects(SubscriptionContractLineDTO)required

Product line items to include in the subscription

lines[].​quantityinteger(int32)>= 1required

Quantity of the product variant

Example: 2
lines[].​variantIdstringrequired

Shopify product variant ID (numeric ID without gid prefix)

Example: "42549172011164"
lines[].​productIdstring

Shopify product ID (numeric ID without gid prefix)

Example: "7234567890123"
lines[].​sellingPlanIdstring

Selling plan ID to apply to this line item. Required for subscription pricing

Example: "gid://shopify/SellingPlan/123456"
lines[].​currentPricenumber(double)

Current price per unit after discounts. If not provided, calculated from selling plan

Example: 25.99
lines[].​unitPricenumber(double)

Base price per unit before any discounts

Example: 29.99
lines[].​customAttributesArray of objects(AttributeInput)

Custom attributes for this line item

Example: [{"key":"engraving","value":"Happy Birthday"}]
lines[].​linePricingPolicystring

Pricing policy type for subscription line items

Enum"SELLING_PLAN_PRICING_POLICY""CUSTOM_PRICING_POLICY""NO_PRICING_POLICY"
Example: "SELLING_PLAN_PRICING_POLICY"
lines[].​pricingPolicyArray of objects(AppstleCycle)

Custom pricing policy cycles when linePricingPolicy is CUSTOM_PRICING_POLICY

allowDeliveryAddressOverrideboolean

Allow customer to change delivery address in customer portal

Default false
Example: false
allowDeliveryPriceOverrideboolean

Allow delivery price to be overridden

Default false
Example: false
customAttributesobject(AttributeInput)

Custom attributes to attach to the subscription contract

Example: [{"key":"subscription_type","value":"premium"},{"key":"gift_message","value":"Happy Birthday!"}]
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!"
      }
    ]
  }'

Responses

Subscription contract successfully created

Bodyapplication/json
get__typenamestring
idstring
createdAtobject
updatedAtobject
nextBillingDateobject
statusstring
Enum"ACTIVE""PAUSED""CANCELLED""EXPIRED""FAILED""$UNKNOWN"
deliveryPriceobject(DeliveryPrice)
lastPaymentStatusstring
Enum"SUCCEEDED""FAILED""$UNKNOWN"
billingPolicyobject(BillingPolicy)
deliveryPolicyobject(DeliveryPolicy)
linesobject(Lines)
customerPaymentMethodobject(CustomerPaymentMethod)
deliveryMethodobject(DeliveryMethod)
originOrderobject(OriginOrder)
customerobject(Customer)
discountsobject(Discounts)
notestring
customAttributesArray of objects(CustomAttribute1)
billingAttemptsobject(BillingAttempts)
Response
application/json
{ "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": [] } }

Get raw Shopify GraphQL contract response

Request

Retrieves the complete, unprocessed subscription contract data directly from Shopify's GraphQL API. This endpoint returns the full Shopify subscription contract object exactly as Shopify provides it, including all nested fields, relationships, and GraphQL metadata.

What This Endpoint Returns: Unlike processed/transformed endpoints, this returns Shopify's raw SubscriptionContract GraphQL object with all available fields. This is the same data structure you would receive if querying Shopify's GraphQL API directly, making it ideal for:

  • Debugging Shopify data synchronization issues
  • Accessing fields not exposed in other endpoints
  • Understanding complete Shopify contract structure
  • Building custom integrations requiring full data
  • Comparing Shopify source data with processed data

Data Included:

Contract Core:

  • Full subscription contract object from Shopify
  • All GraphQL __typename fields preserved
  • Complete nested object structures
  • All available Shopify contract fields

Customer Information:

  • Complete customer object with all fields
  • Default address details
  • Customer tags and metadata
  • Marketing preferences

Line Items:

  • Full line item details with edges/nodes structure
  • Product and variant complete objects
  • Pricing policies with all cycle discounts
  • Line item custom attributes
  • Current and original prices

Billing & Delivery:

  • Complete billing policy object
  • Full delivery policy details
  • Delivery method with all fields
  • Delivery price breakdown
  • Billing anchor details

Payment Information:

  • Payment method details (if available)
  • Customer payment instrument
  • Payment gateway information

Orders & History:

  • Origin order details
  • Last payment status
  • Historical billing attempts (in Appstle)

Use Cases:

1. Debugging & Troubleshooting:

  • Investigate data sync discrepancies
  • Verify what Shopify actually stores
  • Debug webhook payload issues
  • Compare expected vs actual data

2. Advanced Integrations:

  • Access Shopify-specific fields not in standard APIs
  • Build custom analytics using raw data
  • Integrate with Shopify GraphQL directly
  • Extract fields for custom processing

3. Data Analysis:

  • Analyze complete contract structure
  • Extract all available metadata
  • Build comprehensive data exports
  • Perform deep data audits

4. Development & Testing:

  • Understand Shopify's data model
  • Test new feature development
  • Verify API responses
  • Documentation and examples

Response Structure:

Returns SubscriptionContractQuery.SubscriptionContract object:

{
  "id": "gid://shopify/SubscriptionContract/123456789",
  "status": "ACTIVE",
  "nextBillingDate": "2024-03-15T00:00:00Z",
  "customer": {
    "id": "gid://shopify/Customer/987654321",
    "email": "customer@example.com",
    "displayName": "John Doe",
    "__typename": "Customer"
  },
  "lines": {
    "edges": [
      {
        "node": {
          "id": "gid://shopify/SubscriptionLine/111111",
          "quantity": 2,
          "variantId": "gid://shopify/ProductVariant/222222",
          "title": "Monthly Coffee Box",
          "variantTitle": "Medium Roast",
          "currentPrice": {
            "amount": "29.99",
            "currencyCode": "USD"
          },
          "pricingPolicy": {...},
          "__typename": "SubscriptionLine"
        }
      }
    ]
  },
  "billingPolicy": {
    "interval": "MONTH",
    "intervalCount": 1,
    "minCycles": 3,
    "maxCycles": 12
  },
  "deliveryPolicy": {...},
  "deliveryMethod": {...},
  "__typename": "SubscriptionContract"
}

Important Considerations:

Data Source:

  • Queries Shopify GraphQL API in real-time
  • NOT cached in Appstle database
  • Always returns current Shopify state
  • Subject to Shopify API rate limits

Performance:

  • Slower than database queries (500-1500ms typical)
  • Makes real-time call to Shopify
  • Response size can be large (10-50 KB)
  • Use sparingly to avoid rate limits

GraphQL Structure:

  • Includes __typename fields throughout
  • Uses GraphQL ID format (gid://shopify/...)
  • Nested edges/nodes structure for lists
  • All fields as defined in Shopify's schema

Best Practices:

  1. Use for Debugging: Perfect for troubleshooting data issues
  2. Avoid Polling: Don't call repeatedly - use cached/processed endpoints instead
  3. Cache Response: Cache the response if using for display
  4. Parse Carefully: Handle GraphQL structure (edges/nodes)
  5. Monitor Rate Limits: Each call counts against Shopify API limits

When to Use vs Other Endpoints:

Use this endpoint when:

  • Need complete Shopify contract data
  • Debugging synchronization issues
  • Accessing Shopify-specific fields
  • Building Shopify GraphQL integrations

Use /api/external/v2/subscription-contract-details when:

  • Need processed, filtered contract data
  • Want faster response times
  • Querying multiple contracts
  • Building customer-facing UIs

Authentication: Requires valid X-API-Key header

Path
contractIdinteger(int64)required

Contract ID

Query
api_keystring

API Key (Deprecated - Use Header X-API-Key instead)

Headers
X-API-Keystring
curl -i -X GET \
  'https://subscription-admin.appstle.com/api/external/v2/subscription-contracts/contract-external/{contractId}?api_key=string' \
  -H 'X-API-Key: string'

Responses

Successfully retrieved raw Shopify contract data

Bodyapplication/json
get__typenamestring
idstring
createdAtobject
updatedAtobject
nextBillingDateobject
statusstring
Enum"ACTIVE""PAUSED""CANCELLED""EXPIRED""FAILED""$UNKNOWN"
deliveryPriceobject(DeliveryPrice)
lastPaymentStatusstring
Enum"SUCCEEDED""FAILED""$UNKNOWN"
billingPolicyobject(BillingPolicy)
deliveryPolicyobject(DeliveryPolicy)
linesobject(Lines)
customerPaymentMethodobject(CustomerPaymentMethod)
deliveryMethodobject(DeliveryMethod)
originOrderobject(OriginOrder)
customerobject(Customer)
discountsobject(Discounts)
notestring
customAttributesArray of objects(CustomAttribute1)
billingAttemptsobject(BillingAttempts)
Response
application/json
{ "get__typename": "string", "id": "string", "createdAt": {}, "updatedAt": {}, "nextBillingDate": {}, "status": "ACTIVE", "deliveryPrice": { "get__typename": "string", "amount": {}, "currencyCode": "USD" }, "lastPaymentStatus": "SUCCEEDED", "billingPolicy": { "get__typename": "string", "interval": "DAY", "intervalCount": 0, "anchors": [], "maxCycles": 0, "minCycles": 0 }, "deliveryPolicy": { "get__typename": "string", "interval": "DAY", "intervalCount": 0, "anchors": [] }, "lines": { "get__typename": "string", "nodes": [], "pageInfo": {} }, "customerPaymentMethod": { "get__typename": "string", "id": "string", "instrument": {}, "revokedAt": {}, "revokedReason": "AUTHORIZE_NET_GATEWAY_NOT_ENABLED" }, "deliveryMethod": { "get__typename": "string" }, "originOrder": { "get__typename": "string", "id": "string", "name": "string", "fulfillmentOrders": {} }, "customer": { "get__typename": "string", "id": "string", "email": "string", "displayName": "string", "firstName": "string", "lastName": "string", "phone": "string" }, "discounts": { "get__typename": "string", "nodes": [], "pageInfo": {} }, "note": "string", "customAttributes": [ {} ], "billingAttempts": { "get__typename": "string", "nodes": [] } }

Subscription Payments

APIs for managing subscription payment methods, processing payments, handling payment retries, and updating billing information.

Operations

Subscription Contracts

APIs for managing subscription contracts including delivery schedules, pricing, order notes, billing cycles, and shipping addresses.

Operations

Subscription Products

APIs for managing products within subscriptions including adding, removing, updating quantities, and swapping products.

Operations

Billing & Payments

APIs for handling billing operations, payment processing, and financial transactions related to subscriptions.

Operations

Subscription Discounts

APIs for managing discounts and promotional codes applied to subscriptions.

Operations

Subscription One-Time Products

APIs for managing one-time add-on products that can be purchased alongside recurring subscription items.

Operations

Subscription Plans

APIs for managing subscription plans, pricing tiers, and plan configurations.

Operations

Build-a-Box & Bundles

APIs for managing customizable product boxes and bundles where customers can select multiple items.

Operations

Product Catalog

APIs for managing the product catalog including product information, variants, and inventory.

Operations

Operations & Settings

APIs for managing operational settings, configurations, and administrative functions.

Operations

Customer Portal

APIs powering the customer-facing portal where subscribers can manage their own subscriptions.

Operations

Customers

APIs for managing customer information, profiles, and account details.

Operations