Manage subscriptions with the API
Subscriptions, also known as recurring transactions, autopays, or scheduled payments, are a powerful way to automate billing and payment collection. With Payabli’s API, you can manage these transactions, including creating, updating, and deleting subscriptions.
This guide covers the key operations for managing subscriptions through the API.
Considerations
When working with subscriptions, keep the following in mind:
- Payabli automatically tokenizes payment information and assigns stored payment methods to the provided customer.
- Subscriptions are always linked to a customer - if no
customerIdis provided and thecustomerDatafields don’t match an existing customer, a new customer is created. - Best practice is to create the customer first and pass the
customerIdin the customerData object. - When using a stored payment method, ensure the
storedIdin paymentMethod corresponds to the customer incustomerData. - Subscription and autopay transactions typically run between 2:30 AM and 3:30 AM Eastern time.
- If a subscription payment is declined, you can update the subscription and retry the payment. See Subscription retry logic for more information. Payabli doesn’t retry failed autopays.
- If you pass an
invoiceDataobject to a subscription, the payments in the subscription are automatically added to the invoice as they’re processed. - Before enrolling customers in recurring billing, make sure you have clear terms and conditions that cover cancellation policies, refund rules, billing frequency, and payment amounts. Work with your legal team to draft these. Displaying terms and capturing customer consent protects you in the event of a chargeback dispute.
Subscription types
Payabli supports two subscription types, set via the subscriptionType field when you create a subscription:
- Regular (default): Charges a fixed amount each cycle. Set
totalAmountinpaymentDetails(andserviceFeeif you charge one). Use any of the supported frequencies. - BalanceDriven: Charges the payor’s outstanding balance at run time instead of a fixed amount. Each scheduled run reads the live balance and charges that amount. A zero balance is skipped, not charged.
subscriptionType can’t be changed after the subscription is created.
BalanceDriven schedule rules
BalanceDriven subscriptions follow stricter scheduling rules than Regular ones:
- Only the monthly cadences
firstofmonth,fifteenthofmonth, andendofmonthare accepted forscheduleDetails.frequency. scheduleDetails.startDateis calculated automatically from the chosen frequency. Any value you supply is ignored.scheduleDetails.endDatedoesn’t apply — BalanceDriven subscriptions run until cancelled.- No static
totalAmountis stored on the schedule. The amount comes from the live balance at run time.
The three new monthly cadences are valid for Regular subscriptions too.
Pause a subscription or skip a payment
Pausing a subscription stops all future payments until the subscription is unpaused. Skipping payments allows the subscription to continue but skips the next scheduled payment.
For Regular subscriptions, skip a payment by updating the subscription’s totalAmount to 0. To resume payments, update totalAmount to a non-zero amount. If totalAmount is set to 0, then serviceFee must also be set to 0.
For BalanceDriven subscriptions, the totalAmount = 0 skip mechanism doesn’t apply. The charge amount comes from the payor’s live balance, not from a totalAmount you send, so any totalAmount is accepted but ignored at run time. A scheduled run with a zero balance is automatically skipped.
To pause a subscription, send a PUT request to /api/Subscription/\{subscriptionId\} with the setPause field set to true. When you’re ready to resume the subscription, send another PUT request with setPause set to false.
Pause Subscription
Unpause Subscription
Create a subscription
Send a POST request to /api/Subscription/add to create a new subscription or scheduled payment. See the API reference for this endpoint for full documentation.
Card Subscription
Creates an autopay subscription using a card payment method.
ACH Subscription
Creates an autopay subscription using a bank account to pay via ACH.
Stored Method Subscription
Creates a subscription using a saved payment method (also known as a payment token or stored payment method). This is useful for recurring payments where the customer has previously saved their payment information.
Stored Method Subscription with Digital Wallet
Creates a subscription using a saved digital wallet payment method (also known as a payment token or stored payment method). To get a stored payment method for a digital wallet, you need to use the Express Checkout UI component. See Tokenize a payment method for more information on how to tokenize digital wallets with the Express Checkout component. See the Apple Pay overview and Google Pay™ overview docs for more information on Apple Pay and Google Pay.
BalanceDriven Subscription
Creates a BalanceDriven subscription using a card payment method. Each scheduled run bills the payor’s live balance, so the totalAmount you send in paymentDetails isn’t used to determine the charge amount. See BalanceDriven schedule rules for the constraints.
A successful request sends a response that includes the subscription ID (in responseData) and customer ID.
Get subscription details
Send a GET request to /api/Subscription/{subscriptionId} to retrieve details about a specific subscription.
This example gets the details for the subscription with ID 263.
A successful request returns a response that includes all available details about a subscription. The response shape is the same for both subscription types — the SubscriptionType field indicates which one. See the API reference for a full response example.
Regular subscription
BalanceDriven subscription
Update a subscription
Send a PUT request to /api/Subscription/{subscriptionId} to change an existing subscription’s payment details, schedule, or pause status. See the API reference for this endpoint for full documentation.
You can’t change subscriptionType after creation. If you include it in an update request, it’s ignored.
A successful request returns a response that includes the subscription ID (in responseData) and customer ID.
Delete a subscription
Send a DELETE request to /api/Subscription/{subscriptionId} to cancel a subscription and stop future payments. See the API reference for this endpoint for full documentation.
This example deletes the subscription with the ID 396.
A successful deletion returns a response that includes the subscription ID (in responseData) and customer ID.
Next steps
Use the Subscription Utilities to manage your subscriptions. These utilities provide additional functionality, such as retrying failed payments and managing autopay transactions.
Related resources
See these related resources to help you get the most out of Payabli.