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 customerId is provided and the customerData fields don’t match an existing customer, a new customer is created.
  • Best practice is to create the customer first and pass the customerId in the customerData object.
  • When using a stored payment method, ensure the storedId in paymentMethod corresponds to the customer in customerData.
  • Subscription and autopay transactions typically run between 2:30 AM and 3:30 AM Eastern time.

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.

Create subscription example
curl --request POST \
     --url 'https://api-sandbox.payabli.com/api/Subscription/add' \
     --header 'accept: application/json' \
     --header 'content-type: application/*+json' \
     --header 'requestToken: <API TOKEN>' \
     --data '
{
  "paymentMethod": {
    "cardnumber": "4111111111111111",
    "cardexp": "02/25",
    "cardcvv": "123",
    "cardzip": "37615",
    "method": "card"
  },
  "paymentDetails": {
    "categories": [
      {
        "qty": 1,
        "label": "Monthly Fee",
        "description": "Monthly Membership Fee -- Gold",
        "amount": 100
      }
    ],
    "totalAmount": 100
  },
  "customerData": {
    "customerId": 1300
  },
  "scheduleDetails": {
    "startDate": "2023-05-09",
    "endDate": "untilcancelled",
    "frequency": "monthly"
  },
  "entryPoint": "e57ce00572",
  "setPause": false
}'

Get subscription details

Send a GET request to /api/Subscription/{subscriptionId} to retrieve details about a specific subscription. See the API reference for this endpoint for full documentation.

This example gets the details for the subscription with ID 263.

Get subscription example
curl --request GET \
     --url https://api-sandbox.payabli.com/api/Subscription/263 \
     --header 'accept: application/json' \
     --header 'requestToken: <API TOKEN>'

A successful request returns a response that includes all available details about an invoice.

Update a subscription

Send a PUT request to /api/Subscription/{subscriptionId} to modify an existing subscription’s payment details, schedule, or pause status. See the API reference for this endpoint for full documentation.

The first example updates the subscription with the ID 263 to paused. The second example updates the payment details.

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 263.

Delete subscription example
curl --request DELETE \
     --url https://api-sandbox.payabli.com/api/Subscription/263 \
     --header 'accept: application/json' \
     --header 'requestToken: <API TOKEN>'

Response format

All subscription operations return a standardized response format:

Response format example
{
  "responseText": "Success",
  "isSuccess": true,
  "responseData": 263, // this is the subscription ID
  "customerId": 1300
}