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

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

Get customer details with subscriptions

Request

Retrieves comprehensive customer information including their subscription contracts. This endpoint provides customer profile data along with a paginated list of their active and historical subscriptions.

Key Features:

  • Customer profile information (name, email, phone, addresses)
  • Complete subscription history with pagination
  • Payment method details
  • Customer account state and metadata
  • Order history related to subscriptions
  • Customer tags and notes

Subscription Data Included:

  • All subscription contracts (active, paused, cancelled)
  • Contract details with line items
  • Billing and delivery policies
  • Next billing dates and amounts
  • Applied discounts

Pagination:

  • Subscription contracts are paginated
  • Default page size varies by Shopify plan
  • Use cursor for subsequent pages
  • Cursor-based pagination ensures consistency

Use Cases:

  • Customer service representatives viewing customer details
  • Integration with CRM systems
  • Customer analytics and reporting
  • Subscription management interfaces
  • Billing reconciliation

Important Notes:

  • Customer ID is numeric (without gid:// prefix)
  • Returns null if customer not found
  • Includes both active and inactive subscriptions
  • Payment methods may be masked for security

Authentication: Requires valid X-API-Key header

Path
idinteger(int64)>= 1required

Customer ID to retrieve. Provide the numeric ID without the gid:// prefix

Example: 987654321
Query
cursorstring

Pagination cursor for subscription contracts. Use the cursor from previous response's pageInfo.endCursor to get the next page

Example: cursor=eyJsYXN0X2lkIjoxMjM0NTY3ODksImxhc3RfdmFsdWUiOiIyMDI0LTAxLTE1IDEwOjAwOjAwIn0=
api_keystringDeprecated

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

Headers
X-API-Keystringrequired

API Key for authentication

Example: sk_live_1234567890abcdef
curl -i -X GET \
  'https://subscription-admin.appstle.com/api/external/v2/subscription-customers/987654321?cursor=eyJsYXN0X2lkIjoxMjM0NTY3ODksImxhc3RfdmFsdWUiOiIyMDI0LTAxLTE1IDEwOjAwOjAwIn0%3D&api_key=string' \
  -H 'X-API-Key: sk_live_1234567890abcdef'

Responses

Customer details successfully retrieved

Bodyapplication/json
get__typenamestring
idstring
displayNamestring
firstNamestring
lastNamestring
emailstringDeprecated
phonestringDeprecated
Response
application/json
{ "id": "gid://shopify/Customer/987654321", "displayName": "John Doe", "firstName": "John", "lastName": "Doe", "email": "john.doe@example.com", "phone": "+12125551234", "state": "ENABLED", "acceptsMarketing": true, "createdAt": "2023-01-15T10:30:00Z", "updatedAt": "2024-03-15T14:45:00Z", "tags": [ "VIP", "Subscription" ], "note": "Preferred customer - handle with care", "verifiedEmail": true, "validEmailAddress": true, "defaultAddress": { "id": "gid://shopify/MailingAddress/123456789", "address1": "123 Main St", "address2": "Apt 4B", "city": "New York", "province": "New York", "provinceCode": "NY", "country": "United States", "countryCode": "US", "zip": "10001", "phone": "+12125551234", "firstName": "John", "lastName": "Doe", "company": "Acme Corp" }, "addresses": [ {}, {} ], "paymentMethods": [ {} ], "subscriptionContracts": { "edges": [], "pageInfo": {} }, "numberOfOrders": "15" }

Get valid subscription contract IDs for a customer

Request

Retrieves a set of all valid (active, paused, or otherwise non-deleted) subscription contract IDs for a specific customer. This endpoint returns only the contract IDs without detailed subscription information, making it ideal for quick lookups and validation checks.

What Are Valid Subscription Contracts? Valid contracts are subscriptions that exist in the system and haven't been permanently deleted. This includes subscriptions in all states except those that have been hard-deleted or hidden from the system. The contract IDs returned represent subscriptions that can be queried, modified, or managed through other API endpoints.

Contract States Included:

Active States:

  • ACTIVE - Currently active and billing recurring subscriptions
  • PAUSED - Temporarily paused subscriptions (customer can resume)

Inactive States:

  • CANCELLED - Cancelled subscriptions (retained for historical data)
  • EXPIRED - Subscriptions that reached their max cycle limit
  • FAILED - Subscriptions with payment failures (may be in dunning)

Excluded:

  • Hard-deleted subscription records
  • Hidden subscriptions (marked for cleanup)
  • Subscriptions from test/development that were purged

Use Cases:

1. Customer Portal:

  • Check if customer has any subscriptions before showing portal
  • Display subscription count in dashboard
  • Validate customer access to subscription management

2. Integration & Automation:

  • Pre-flight check before bulk operations
  • Verify customer has subscriptions before sending emails
  • Filter customers for targeted campaigns (has active subscriptions)

3. Validation & Security:

  • Verify a specific contract ID belongs to a customer
  • Validate user permissions before showing subscription details
  • Check authorization for subscription modification requests

4. Analytics & Reporting:

  • Count total subscriptions per customer
  • Identify customers with multiple subscriptions
  • Build customer segmentation based on subscription count

Response Format:

Returns a Set containing Shopify subscription contract IDs.

[123456789, 123456790, 123456791]

Set Properties:

  • Unique values: No duplicate contract IDs
  • Unordered: IDs are not in any specific order
  • Numeric: IDs are Long integers (not GraphQL GIDs)

Common Response Scenarios:

Customer with multiple subscriptions:

[5234567890, 5234567891, 5234567892, 5234567893]

Customer with single subscription:

[5234567890]

Customer with no subscriptions:

[]

Integration Examples:

Example 1: Check if customer has subscriptions

const contractIds = await fetch('/api/external/v2/subscription-customers/valid/12345', {
  headers: { 'X-API-Key': 'your-api-key' }
}).then(r => r.json());

if (contractIds.length > 0) {
  console.log(`Customer has ${contractIds.length} subscriptions`);
  // Show customer portal
} else {
  console.log('Customer has no subscriptions');
  // Redirect to create subscription page
}

Example 2: Validate contract ownership

const customerId = 12345;
const contractIdToVerify = 5234567890;

const validContracts = await fetch(`/api/external/v2/subscription-customers/valid/${customerId}`, {
  headers: { 'X-API-Key': 'your-api-key' }
}).then(r => r.json());

if (validContracts.includes(contractIdToVerify)) {
  console.log('Customer owns this contract - allowing access');
  // Proceed with subscription modification
} else {
  console.log('Unauthorized - contract does not belong to customer');
  // Return 403 Forbidden
}

Performance Characteristics:

Fast Response:

  • Lightweight query (returns only IDs, not full subscription data)
  • Typical response time: 50-200ms
  • Suitable for real-time validation checks

Scalability:

  • Efficient even for customers with 100+ subscriptions
  • Database query uses indexed customer ID field
  • Minimal network payload (just array of numbers)

Important Notes:

Contract ID Format:

  • Returns numeric Shopify contract IDs (e.g., 5234567890)
  • NOT Shopify GraphQL GIDs (e.g., gid://shopify/SubscriptionContract/...)
  • Use these IDs with other Appstle API endpoints

Data Freshness:

  • Returns data from Appstle database (not real-time Shopify query)
  • Data is updated via webhooks (typically < 1 second lag)
  • If data seems stale, use sync endpoint to refresh

Empty Response:

  • Empty array [] means customer has no valid subscriptions
  • This is NOT an error - it's a valid response
  • Returns 200 OK with empty array (not 404)

Security & Authorization:

  • Customer ID is validated against authenticated shop
  • Cannot query customers from other shops
  • API key must have customer read permissions

Best Practices:

  1. Use for Validation: Perfect for quick ownership/existence checks
  2. Cache Locally: Cache results briefly to reduce API calls
  3. Check Empty Array: Always handle empty array case gracefully
  4. Combine with Details: Use this for initial check, then fetch full details if needed
  5. Avoid Polling: Don't poll this endpoint repeatedly - use webhooks for updates

When to Use vs. Other Endpoints:

Use this endpoint when you:

  • Need just the contract IDs (not full subscription details)
  • Want to validate a customer has subscriptions
  • Need to verify contract ownership for authorization
  • Want fast, lightweight responses

Use subscription-customers-detail endpoint when you:

  • Need full subscription details (status, products, billing dates, etc.)
  • Want to display subscription information to users
  • Need to make decisions based on subscription state

Related Endpoints:

  • GET /api/external/v2/subscription-customers-detail/valid/{customerId} - Get full subscription details
  • GET /api/external/v2/subscription-contract-details - Query subscriptions with filters
  • GET /api/external/v2/subscription-contracts/contract-external/{contractId} - Get single contract details

Authentication: Requires valid X-API-Key header or api_key parameter (deprecated)

Path
customerIdinteger(int64)required

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-customers/valid/{customerId}?api_key=string' \
  -H 'X-API-Key: string'

Responses

Successfully retrieved valid subscription contract IDs. Returns a set of contract IDs (may be empty if customer has no subscriptions).

Bodyapplication/jsonArray [
integer(int64)
]
Response
application/json
[ 5234567890, 5234567891, 5234567892, 5234567893 ]

Sync customer subscription details from Shopify

Request

Synchronizes customer subscription information from Shopify to the Appstle subscription system. This endpoint fetches the latest customer data from Shopify and updates the local database to ensure data consistency across platforms.

What Does This Endpoint Do? This endpoint triggers a synchronization process that pulls customer subscription data from Shopify's GraphQL API and updates the Appstle subscription database with the latest information. It ensures that customer details, subscription statuses, and associated metadata are current and accurate.

Sync Process:

  1. Data Retrieval: Fetches customer subscription data from Shopify using their GraphQL API
  2. Validation: Validates the retrieved data against existing records
  3. Update: Updates customer subscription details in Appstle database
  4. Reconciliation: Reconciles any discrepancies between Shopify and Appstle data
  5. Logging: Logs all sync activities for audit trail

What Gets Synchronized:

Customer Information:

  • Customer ID and Shopify GraphQL ID
  • Customer name and email address
  • Customer tags and metadata
  • Customer acceptance status
  • Marketing preferences

Subscription Details:

  • Active subscription contracts
  • Subscription statuses (ACTIVE, PAUSED, CANCELLED, EXPIRED)
  • Next billing dates
  • Billing interval and delivery interval
  • Subscription line items (products and variants)
  • Pricing and discounts

Payment Information:

  • Associated payment methods
  • Payment instrument status
  • Billing address details

Delivery Information:

  • Shipping address details
  • Delivery method and profile
  • Delivery preferences

Use Cases:

1. Data Consistency:

  • Resolve data discrepancies between Shopify and Appstle
  • Update customer information after changes in Shopify admin
  • Sync subscription modifications made directly in Shopify

2. Troubleshooting:

  • Fix sync issues for specific customers
  • Recover from webhook delivery failures
  • Debug customer portal display issues

3. Migration & Integration:

  • Initial data sync after app installation
  • Re-sync after system maintenance or updates
  • Integration testing and validation

4. Customer Support:

  • Refresh customer data when assisting with support tickets
  • Verify latest subscription status during customer inquiries
  • Update data after manual changes in Shopify

When to Use This Endpoint:

Recommended Scenarios:

  • Customer reports incorrect subscription data in portal
  • After making manual changes to subscriptions in Shopify admin
  • When troubleshooting webhook sync failures
  • Before running bulk operations on customer subscriptions
  • During migration or data reconciliation processes

Avoid Using For:

  • Real-time data refresh (webhooks handle this automatically)
  • Frequent polling (use webhooks instead to avoid rate limits)
  • Bulk syncs of many customers (use batch endpoints or scheduled jobs)

Sync Behavior:

Synchronous Operation:

  • Endpoint blocks until sync completes
  • Returns void on success
  • Throws exception on failure

Data Precedence:

  • Shopify data is always treated as source of truth
  • Local Appstle data is overwritten with Shopify values
  • Custom Appstle-specific fields are preserved

Error Handling:

  • Invalid customer ID: Returns 400 Bad Request
  • Customer not found in Shopify: Returns 404 Not Found
  • Shopify API errors: Returns 502 Bad Gateway
  • Rate limit exceeded: Returns 429 Too Many Requests

Important Considerations:

Performance:

  • Sync duration depends on number of subscriptions (typically 1-5 seconds)
  • May timeout for customers with 100+ active subscriptions
  • Consider using asynchronous sync for high-volume customers

Rate Limiting:

  • Subject to Shopify GraphQL API rate limits
  • Frequent calls may exhaust rate limit budget
  • Use webhooks for real-time sync instead of polling this endpoint

Data Integrity:

  • Always creates audit log entries for tracking
  • Preserves historical data and activity logs
  • Does not delete local-only data (e.g., custom notes)

Best Practices:

  1. Use Sparingly: Rely on webhooks for automatic sync; use this only when needed
  2. Check Logs: Review activity logs after sync to verify changes
  3. Validate Results: Query customer data after sync to confirm updates
  4. Handle Errors: Implement retry logic with exponential backoff
  5. Monitor Rate Limits: Track Shopify API usage to avoid hitting limits

Security Notes:

  • Requires valid API key authentication via X-API-Key header
  • Customer ID is validated against shop ownership
  • Cannot sync customers from other shops
  • All sync operations are logged for audit compliance

Response:

  • Returns HTTP 204 No Content on successful sync
  • No response body returned
  • Check activity logs for detailed sync results

Alternative Approaches:

If you need to:

  • Sync multiple customers: Use bulk sync endpoint or scheduled job
  • Real-time updates: Rely on webhook subscriptions
  • Verify data without modifying: Use GET endpoints to retrieve current data

Integration Workflow Example:

1. Customer contacts support about incorrect billing date
2. Support agent checks subscription in Appstle admin
3. Agent makes correction in Shopify admin
4. Agent calls sync endpoint for this customer
5. Sync retrieves latest data from Shopify
6. Appstle database is updated with corrected billing date
7. Customer portal now shows correct date
8. Support ticket resolved

Authentication: Requires valid X-API-Key header or api_key parameter (deprecated)

Path
customerIdinteger(int64)required

Customer 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-customers/sync-info/{customerId}?api_key=string' \
  -H 'X-API-Key: string'

Responses

Customer subscription data successfully synchronized from Shopify. No response body returned. Check activity logs to verify sync completion and review changes made.

Bodyapplication/json
Response
application/json
null