> This is Payabli documentation. For a complete page index, fetch https://docs.payabli.com/llms.txt — append .md to any page URL for lightweight markdown. For section-level indexes, query parameters, and other AI-optimized access methods, see https://docs.payabli.com/ai-agents.md

# Manage subscriptions with the API

> Learn how to create, update, and delete your scheduled, subscription, and autopay transactions with the Payabli 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 `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.
* If a subscription payment is declined, you can update the subscription and retry the payment. See [Subscription retry logic](/guides/pay-in-developer-subscriptions-utilities#subscription-retry-logic) for more information. Payabli doesn't retry failed autopays.
* If you pass an `invoiceData` object 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](/guides/pay-ops-disputes-chargebacks-returns-overview#baseline-documentation-requirements).

## 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 `totalAmount` in `paymentDetails` (and `serviceFee` if you charge one). Use any of the supported [frequencies](/developers/api-reference/subscription/create-a-subscription-or-scheduled-payment).
* **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`, and `endofmonth` are accepted for `scheduleDetails.frequency`.
* `scheduleDetails.startDate` is calculated automatically from the chosen frequency. Any value you supply is ignored.
* `scheduleDetails.endDate` doesn't apply — BalanceDriven subscriptions run until cancelled.
* No static `totalAmount` is 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`.

### Request

PUT [https://api-sandbox.payabli.com/api/Subscription/\{subId}](https://api-sandbox.payabli.com/api/Subscription/\{subId})

```curl PauseSubscription
curl -X PUT https://api-sandbox.payabli.com/api/Subscription/231 \
     -H "requestToken: <apiKey>" \
     -H "Content-Type: application/json" \
     -d '{
  "setPause": true
}'
```

```typescript PauseSubscription
import { PayabliClient } from "@payabli/sdk-node";

async function main() {
    const client = new PayabliClient({
        apiKey: "YOUR_API_KEY_HERE",
    });
    await client.subscription.updateSubscription(231, {
        setPause: true,
    });
}
main();

```

```python PauseSubscription
from payabli import payabli

client = payabli(
    api_key="YOUR_API_KEY_HERE",
)

client.subscription.update_subscription(
    sub_id=231,
    set_pause=True,
)

```

```java PauseSubscription
package com.example.usage;

import io.github.payabli.api.PayabliPayabliApiOasClient;
import io.github.payabli.api.resources.subscription.requests.RequestUpdateSchedule;

public class Example {
    public static void main(String[] args) {
        PayabliPayabliApiOasClient client = PayabliPayabliApiOasClient
            .builder()
            .apiKey("YOUR_API_KEY_HERE")
            .build();

        client.subscription().updateSubscription(
            231,
            RequestUpdateSchedule
                .builder()
                .setPause(true)
                .build()
        );
    }
}
```

```ruby PauseSubscription
require "payabli"

client = Payabli::Client.new(api_key: "YOUR_API_KEY_HERE")

client.subscription.update_subscription(
  sub_id: 231,
  set_pause: true
)

```

```csharp PauseSubscription
using PayabliPayabliApiOas;
using System.Threading.Tasks;

namespace Usage;

public class Example
{
    public async Task Do() {
        var client = new PayabliPayabliApiOasClient(
            apiKey: "YOUR_API_KEY_HERE"
        );

        await client.Subscription.UpdateSubscriptionAsync(
            231,
            new RequestUpdateSchedule {
                SetPause = true
            }
        );
    }

}

```

```go PauseSubscription
package example

import (
    context "context"

    payabli "github.com/payabli/sdk-go"
    client "github.com/payabli/sdk-go/client"
    option "github.com/payabli/sdk-go/option"
)

func do() {
    client := client.NewClient(
        option.WithApiKey(
            "YOUR_API_KEY_HERE",
        ),
    )
    request := &payabli.RequestUpdateSchedule{
        SetPause: payabli.Bool(
            true,
        ),
    }
    client.Subscription.UpdateSubscription(
        context.TODO(),
        231,
        request,
    )
}

```

```php PauseSubscription
<?php

namespace Example;

use Payabli\PayabliClient;
use Payabli\Subscription\Requests\RequestUpdateSchedule;

$client = new PayabliClient(
    apiKey: 'YOUR_API_KEY_HERE',
);
$client->subscription->updateSubscription(
    231,
    new RequestUpdateSchedule([
        'setPause' => true,
    ]),
);

```

```swift PauseSubscription
import Foundation

let headers = [
  "requestToken": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = ["setPause": true] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api-sandbox.payabli.com/api/Subscription/231")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PUT"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Request

PUT [https://api-sandbox.payabli.com/api/Subscription/\{subId}](https://api-sandbox.payabli.com/api/Subscription/\{subId})

```curl UnpauseSubscription
curl -X PUT https://api-sandbox.payabli.com/api/Subscription/231 \
     -H "requestToken: <apiKey>" \
     -H "Content-Type: application/json" \
     -d '{
  "setPause": false
}'
```

```typescript UnpauseSubscription
import { PayabliClient } from "@payabli/sdk-node";

async function main() {
    const client = new PayabliClient({
        apiKey: "YOUR_API_KEY_HERE",
    });
    await client.subscription.updateSubscription(231, {
        setPause: false,
    });
}
main();

```

```python UnpauseSubscription
from payabli import payabli

client = payabli(
    api_key="YOUR_API_KEY_HERE",
)

client.subscription.update_subscription(
    sub_id=231,
    set_pause=False,
)

```

```java UnpauseSubscription
package com.example.usage;

import io.github.payabli.api.PayabliPayabliApiOasClient;
import io.github.payabli.api.resources.subscription.requests.RequestUpdateSchedule;

public class Example {
    public static void main(String[] args) {
        PayabliPayabliApiOasClient client = PayabliPayabliApiOasClient
            .builder()
            .apiKey("YOUR_API_KEY_HERE")
            .build();

        client.subscription().updateSubscription(
            231,
            RequestUpdateSchedule
                .builder()
                .setPause(false)
                .build()
        );
    }
}
```

```ruby UnpauseSubscription
require "payabli"

client = Payabli::Client.new(api_key: "YOUR_API_KEY_HERE")

client.subscription.update_subscription(
  sub_id: 231,
  set_pause: false
)

```

```csharp UnpauseSubscription
using PayabliPayabliApiOas;
using System.Threading.Tasks;

namespace Usage;

public class Example
{
    public async Task Do() {
        var client = new PayabliPayabliApiOasClient(
            apiKey: "YOUR_API_KEY_HERE"
        );

        await client.Subscription.UpdateSubscriptionAsync(
            231,
            new RequestUpdateSchedule {
                SetPause = false
            }
        );
    }

}

```

```go UnpauseSubscription
package example

import (
    context "context"

    payabli "github.com/payabli/sdk-go"
    client "github.com/payabli/sdk-go/client"
    option "github.com/payabli/sdk-go/option"
)

func do() {
    client := client.NewClient(
        option.WithApiKey(
            "YOUR_API_KEY_HERE",
        ),
    )
    request := &payabli.RequestUpdateSchedule{
        SetPause: payabli.Bool(
            false,
        ),
    }
    client.Subscription.UpdateSubscription(
        context.TODO(),
        231,
        request,
    )
}

```

```php UnpauseSubscription
<?php

namespace Example;

use Payabli\PayabliClient;
use Payabli\Subscription\Requests\RequestUpdateSchedule;

$client = new PayabliClient(
    apiKey: 'YOUR_API_KEY_HERE',
);
$client->subscription->updateSubscription(
    231,
    new RequestUpdateSchedule([
        'setPause' => false,
    ]),
);

```

```swift UnpauseSubscription
import Foundation

let headers = [
  "requestToken": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = ["setPause": false] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api-sandbox.payabli.com/api/Subscription/231")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PUT"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

## Create a subscription

Send a POST request to `/api/Subscription/add` to create a new subscription or scheduled payment. See the [API reference](/developers/api-reference/subscription/create-a-subscription-or-scheduled-payment) for this endpoint for full documentation.

Creates an autopay subscription using a card payment method.

### Request

POST [https://api-sandbox.payabli.com/api/Subscription/add](https://api-sandbox.payabli.com/api/Subscription/add)

```curl CardSubscription
curl -X POST https://api-sandbox.payabli.com/api/Subscription/add \
     -H "requestToken: <apiKey>" \
     -H "Content-Type: application/json" \
     -d '{
  "customerData": {
    "customerId": 4440
  },
  "entryPoint": "8cfec329267",
  "paymentDetails": {
    "totalAmount": 100,
    "serviceFee": 0
  },
  "paymentMethod": {
    "cardHolder": "John Cassian",
    "cardcvv": "123",
    "cardexp": "12/29",
    "cardnumber": "4111111111111111",
    "cardzip": "37615",
    "initiator": "payor",
    "method": "card"
  },
  "scheduleDetails": {
    "endDate": "2025-03-20",
    "frequency": "weekly",
    "planId": 1,
    "startDate": "2024-09-20"
  }
}'
```

```typescript CardSubscription
import { PayabliClient } from "@payabli/sdk-node";

async function main() {
    const client = new PayabliClient({
        apiKey: "YOUR_API_KEY_HERE",
    });
    await client.subscription.newSubscription({
        customerData: {
            customerId: 4440,
        },
        entryPoint: "8cfec329267",
        paymentDetails: {
            totalAmount: 100,
            serviceFee: 0,
        },
        paymentMethod: {
            cardHolder: "John Cassian",
            cardcvv: "123",
            cardexp: "12/29",
            cardnumber: "4111111111111111",
            cardzip: "37615",
            initiator: "payor",
            method: "card",
        },
        scheduleDetails: {
            endDate: "2025-03-20",
            frequency: "weekly",
            planId: 1,
            startDate: "2024-09-20",
        },
    });
}
main();

```

```python CardSubscription
from payabli import payabli, PayorDataRequest, PaymentDetail, PayMethodCredit, ScheduleDetail

client = payabli(
    api_key="YOUR_API_KEY_HERE",
)

client.subscription.new_subscription(
    customer_data=PayorDataRequest(
        customer_id=4440,
    ),
    entry_point="8cfec329267",
    payment_details=PaymentDetail(
        total_amount=100,
        service_fee=0,
    ),
    payment_method=PayMethodCredit(
        card_holder="John Cassian",
        cardcvv="123",
        cardexp="12/29",
        cardnumber="4111111111111111",
        cardzip="37615",
        initiator="payor",
        method="card",
    ),
    schedule_details=ScheduleDetail(
        end_date="2025-03-20",
        frequency="weekly",
        plan_id=1,
        start_date="2024-09-20",
    ),
)

```

```java CardSubscription
package com.example.usage;

import io.github.payabli.api.PayabliPayabliApiOasClient;
import io.github.payabli.api.resources.subscription.requests.RequestSchedule;
import io.github.payabli.api.types.Frequency;
import io.github.payabli.api.types.PayMethodCredit;
import io.github.payabli.api.types.PayMethodCreditMethod;
import io.github.payabli.api.types.PaymentDetail;
import io.github.payabli.api.types.PayorDataRequest;
import io.github.payabli.api.types.RequestSchedulePaymentMethod;
import io.github.payabli.api.types.ScheduleDetail;
import java.util.Optional;

public class Example {
    public static void main(String[] args) {
        PayabliPayabliApiOasClient client = PayabliPayabliApiOasClient
            .builder()
            .apiKey("YOUR_API_KEY_HERE")
            .build();

        client.subscription().newSubscription(
            RequestSchedule
                .builder()
                .customerData(
                    PayorDataRequest
                        .builder()
                        .customerId(4440L)
                        .build()
                )
                .entryPoint("8cfec329267")
                .paymentDetails(
                    PaymentDetail
                        .builder()
                        .totalAmount(100.0)
                        .serviceFee(0.0)
                        .build()
                )
                .paymentMethod(
                    RequestSchedulePaymentMethod.of(
                        PayMethodCredit
                            .builder()
                            .cardexp("12/29")
                            .cardnumber("4111111111111111")
                            .method(PayMethodCreditMethod.CARD)
                            .cardcvv(Optional.of("123"))
                            .cardHolder(Optional.of("John Cassian"))
                            .cardzip(Optional.of("37615"))
                            .initiator(Optional.of("payor"))
                            .build()
                    )
                )
                .scheduleDetails(
                    ScheduleDetail
                        .builder()
                        .endDate("2025-03-20")
                        .frequency(Frequency.WEEKLY)
                        .planId(1)
                        .startDate("2024-09-20")
                        .build()
                )
                .build()
        );
    }
}
```

```ruby CardSubscription
require "payabli"

client = Payabli::Client.new(api_key: "YOUR_API_KEY_HERE")

client.subscription.new_subscription(
  customer_data: {
    customer_id: 4440
  },
  entry_point: "8cfec329267",
  payment_details: {
    total_amount: 100,
    service_fee: 0
  },
  payment_method: {
    card_holder: "John Cassian",
    cardcvv: "123",
    cardexp: "12/29",
    cardnumber: "4111111111111111",
    cardzip: "37615",
    initiator: "payor",
    method_: "card"
  },
  schedule_details: {
    end_date: "2025-03-20",
    frequency: "weekly",
    plan_id: 1,
    start_date: "2024-09-20"
  }
)

```

```csharp CardSubscription
using PayabliPayabliApiOas;
using System.Threading.Tasks;

namespace Usage;

public class Example
{
    public async Task Do() {
        var client = new PayabliPayabliApiOasClient(
            apiKey: "YOUR_API_KEY_HERE"
        );

        await client.Subscription.NewSubscriptionAsync(
            new RequestSchedule {
                CustomerData = new PayorDataRequest {
                    CustomerId = 4440L
                },
                EntryPoint = "8cfec329267",
                PaymentDetails = new PaymentDetail {
                    TotalAmount = 100,
                    ServiceFee = 0
                },
                PaymentMethod = new PayMethodCredit {
                    CardHolder = "John Cassian",
                    Cardcvv = "123",
                    Cardexp = "12/29",
                    Cardnumber = "4111111111111111",
                    Cardzip = "37615",
                    Initiator = "payor",
                    Method = PayMethodCreditMethod.Card
                },
                ScheduleDetails = new ScheduleDetail {
                    EndDate = "2025-03-20",
                    Frequency = Frequency.Weekly,
                    PlanId = 1,
                    StartDate = "2024-09-20"
                }
            }
        );
    }

}

```

```go CardSubscription
package example

import (
    context "context"

    payabli "github.com/payabli/sdk-go"
    client "github.com/payabli/sdk-go/client"
    option "github.com/payabli/sdk-go/option"
)

func do() {
    client := client.NewClient(
        option.WithApiKey(
            "YOUR_API_KEY_HERE",
        ),
    )
    request := &payabli.RequestSchedule{
        CustomerData: &payabli.PayorDataRequest{
            CustomerId: payabli.Int64(
                int64(4440),
            ),
        },
        EntryPoint: payabli.String(
            "8cfec329267",
        ),
        PaymentDetails: &payabli.PaymentDetail{
            TotalAmount: 100,
            ServiceFee: payabli.Float64(
                0,
            ),
        },
        PaymentMethod: &payabli.RequestSchedulePaymentMethod{
            PayMethodCredit: &payabli.PayMethodCredit{
                CardHolder: payabli.String(
                    "John Cassian",
                ),
                Cardcvv: payabli.String(
                    "123",
                ),
                Cardexp: "12/29",
                Cardnumber: "4111111111111111",
                Cardzip: payabli.String(
                    "37615",
                ),
                Initiator: payabli.String(
                    "payor",
                ),
                Method: payabli.PayMethodCreditMethodCard,
            },
        },
        ScheduleDetails: &payabli.ScheduleDetail{
            EndDate: payabli.String(
                "2025-03-20",
            ),
            Frequency: payabli.FrequencyWeekly.Ptr(),
            PlanId: payabli.Int(
                1,
            ),
            StartDate: payabli.String(
                "2024-09-20",
            ),
        },
    }
    client.Subscription.NewSubscription(
        context.TODO(),
        request,
    )
}

```

```php CardSubscription
<?php

namespace Example;

use Payabli\PayabliClient;
use Payabli\Subscription\Requests\RequestSchedule;
use Payabli\Types\PayorDataRequest;
use Payabli\Types\PaymentDetail;
use Payabli\Types\PayMethodCredit;
use Payabli\Types\PayMethodCreditMethod;
use Payabli\Types\ScheduleDetail;
use Payabli\Types\Frequency;

$client = new PayabliClient(
    apiKey: 'YOUR_API_KEY_HERE',
);
$client->subscription->newSubscription(
    new RequestSchedule([
        'customerData' => new PayorDataRequest([
            'customerId' => 4440,
        ]),
        'entryPoint' => '8cfec329267',
        'paymentDetails' => new PaymentDetail([
            'totalAmount' => 100,
            'serviceFee' => 0,
        ]),
        'paymentMethod' => new PayMethodCredit([
            'cardHolder' => 'John Cassian',
            'cardcvv' => '123',
            'cardexp' => '12/29',
            'cardnumber' => '4111111111111111',
            'cardzip' => '37615',
            'initiator' => 'payor',
            'method' => PayMethodCreditMethod::Card->value,
        ]),
        'scheduleDetails' => new ScheduleDetail([
            'endDate' => '2025-03-20',
            'frequency' => Frequency::Weekly->value,
            'planId' => 1,
            'startDate' => '2024-09-20',
        ]),
    ]),
);

```

```swift CardSubscription
import Foundation

let headers = [
  "requestToken": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "customerData": ["customerId": 4440],
  "entryPoint": "8cfec329267",
  "paymentDetails": [
    "totalAmount": 100,
    "serviceFee": 0
  ],
  "paymentMethod": [
    "cardHolder": "John Cassian",
    "cardcvv": "123",
    "cardexp": "12/29",
    "cardnumber": "4111111111111111",
    "cardzip": "37615",
    "initiator": "payor",
    "method": "card"
  ],
  "scheduleDetails": [
    "endDate": "2025-03-20",
    "frequency": "weekly",
    "planId": 1,
    "startDate": "2024-09-20"
  ]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api-sandbox.payabli.com/api/Subscription/add")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

Creates an autopay subscription using a bank account to pay via ACH.

### Request

POST [https://api-sandbox.payabli.com/api/Subscription/add](https://api-sandbox.payabli.com/api/Subscription/add)

```curl ACHSubscription
curl -X POST https://api-sandbox.payabli.com/api/Subscription/add \
     -H "requestToken: <apiKey>" \
     -H "Content-Type: application/json" \
     -d '{
  "customerData": {
    "customerId": 4440
  },
  "entryPoint": "8cfec329267",
  "paymentDetails": {
    "totalAmount": 100,
    "serviceFee": 0
  },
  "paymentMethod": {
    "achAccount": "3453445666",
    "achAccountType": "Checking",
    "achCode": "PPD",
    "achHolder": "John Cassian",
    "achHolderType": "personal",
    "achRouting": "021000021",
    "method": "ach"
  },
  "scheduleDetails": {
    "endDate": "2025-03-20",
    "frequency": "weekly",
    "planId": 1,
    "startDate": "2024-09-20"
  }
}'
```

```typescript ACHSubscription
import { PayabliClient } from "@payabli/sdk-node";

async function main() {
    const client = new PayabliClient({
        apiKey: "YOUR_API_KEY_HERE",
    });
    await client.subscription.newSubscription({
        customerData: {
            customerId: 4440,
        },
        entryPoint: "8cfec329267",
        paymentDetails: {
            totalAmount: 100,
            serviceFee: 0,
        },
        paymentMethod: {
            achAccount: "3453445666",
            achAccountType: "Checking",
            achCode: "PPD",
            achHolder: "John Cassian",
            achHolderType: "personal",
            achRouting: "021000021",
            method: "ach",
        },
        scheduleDetails: {
            endDate: "2025-03-20",
            frequency: "weekly",
            planId: 1,
            startDate: "2024-09-20",
        },
    });
}
main();

```

```python ACHSubscription
from payabli import payabli, PayorDataRequest, PaymentDetail, PayMethodAch, ScheduleDetail

client = payabli(
    api_key="YOUR_API_KEY_HERE",
)

client.subscription.new_subscription(
    customer_data=PayorDataRequest(
        customer_id=4440,
    ),
    entry_point="8cfec329267",
    payment_details=PaymentDetail(
        total_amount=100,
        service_fee=0,
    ),
    payment_method=PayMethodAch(
        ach_account="3453445666",
        ach_account_type="Checking",
        ach_code="PPD",
        ach_holder="John Cassian",
        ach_holder_type="personal",
        ach_routing="021000021",
        method="ach",
    ),
    schedule_details=ScheduleDetail(
        end_date="2025-03-20",
        frequency="weekly",
        plan_id=1,
        start_date="2024-09-20",
    ),
)

```

```java ACHSubscription
package com.example.usage;

import io.github.payabli.api.PayabliPayabliApiOasClient;
import io.github.payabli.api.resources.subscription.requests.RequestSchedule;
import io.github.payabli.api.types.AchHolderType;
import io.github.payabli.api.types.Achaccounttype;
import io.github.payabli.api.types.Frequency;
import io.github.payabli.api.types.PayMethodAch;
import io.github.payabli.api.types.PayMethodAchMethod;
import io.github.payabli.api.types.PaymentDetail;
import io.github.payabli.api.types.PayorDataRequest;
import io.github.payabli.api.types.RequestSchedulePaymentMethod;
import io.github.payabli.api.types.ScheduleDetail;
import java.util.Optional;

public class Example {
    public static void main(String[] args) {
        PayabliPayabliApiOasClient client = PayabliPayabliApiOasClient
            .builder()
            .apiKey("YOUR_API_KEY_HERE")
            .build();

        client.subscription().newSubscription(
            RequestSchedule
                .builder()
                .customerData(
                    PayorDataRequest
                        .builder()
                        .customerId(4440L)
                        .build()
                )
                .entryPoint("8cfec329267")
                .paymentDetails(
                    PaymentDetail
                        .builder()
                        .totalAmount(100.0)
                        .serviceFee(0.0)
                        .build()
                )
                .paymentMethod(
                    RequestSchedulePaymentMethod.of(
                        PayMethodAch
                            .builder()
                            .achAccount("3453445666")
                            .achHolder("John Cassian")
                            .achRouting("021000021")
                            .method(PayMethodAchMethod.ACH)
                            .achAccountType(Optional.of(Achaccounttype.CHECKING))
                            .achCode(Optional.of("PPD"))
                            .achHolderType(Optional.of(AchHolderType.PERSONAL))
                            .build()
                    )
                )
                .scheduleDetails(
                    ScheduleDetail
                        .builder()
                        .endDate("2025-03-20")
                        .frequency(Frequency.WEEKLY)
                        .planId(1)
                        .startDate("2024-09-20")
                        .build()
                )
                .build()
        );
    }
}
```

```ruby ACHSubscription
require "payabli"

client = Payabli::Client.new(api_key: "YOUR_API_KEY_HERE")

client.subscription.new_subscription(
  customer_data: {
    customer_id: 4440
  },
  entry_point: "8cfec329267",
  payment_details: {
    total_amount: 100,
    service_fee: 0
  },
  payment_method: {
    method_: "ach",
    cardexp: "string",
    cardnumber: "string"
  },
  schedule_details: {
    end_date: "2025-03-20",
    frequency: "weekly",
    plan_id: 1,
    start_date: "2024-09-20"
  }
)

```

```csharp ACHSubscription
using PayabliPayabliApiOas;
using System.Threading.Tasks;

namespace Usage;

public class Example
{
    public async Task Do() {
        var client = new PayabliPayabliApiOasClient(
            apiKey: "YOUR_API_KEY_HERE"
        );

        await client.Subscription.NewSubscriptionAsync(
            new RequestSchedule {
                CustomerData = new PayorDataRequest {
                    CustomerId = 4440L
                },
                EntryPoint = "8cfec329267",
                PaymentDetails = new PaymentDetail {
                    TotalAmount = 100,
                    ServiceFee = 0
                },
                PaymentMethod = new PayMethodAch {
                    AchAccount = "3453445666",
                    AchAccountType = Achaccounttype.Checking,
                    AchCode = "PPD",
                    AchHolder = "John Cassian",
                    AchHolderType = AchHolderType.Personal,
                    AchRouting = "021000021",
                    Method = PayMethodAchMethod.Ach
                },
                ScheduleDetails = new ScheduleDetail {
                    EndDate = "2025-03-20",
                    Frequency = Frequency.Weekly,
                    PlanId = 1,
                    StartDate = "2024-09-20"
                }
            }
        );
    }

}

```

```go ACHSubscription
package example

import (
    context "context"

    payabli "github.com/payabli/sdk-go"
    client "github.com/payabli/sdk-go/client"
    option "github.com/payabli/sdk-go/option"
)

func do() {
    client := client.NewClient(
        option.WithApiKey(
            "YOUR_API_KEY_HERE",
        ),
    )
    request := &payabli.RequestSchedule{
        CustomerData: &payabli.PayorDataRequest{
            CustomerId: payabli.Int64(
                int64(4440),
            ),
        },
        EntryPoint: payabli.String(
            "8cfec329267",
        ),
        PaymentDetails: &payabli.PaymentDetail{
            TotalAmount: 100,
            ServiceFee: payabli.Float64(
                0,
            ),
        },
        PaymentMethod: &payabli.RequestSchedulePaymentMethod{
            PayMethodAch: &payabli.PayMethodAch{
                AchAccount: "3453445666",
                AchAccountType: payabli.AchaccounttypeChecking.Ptr(),
                AchCode: payabli.String(
                    "PPD",
                ),
                AchHolder: "John Cassian",
                AchHolderType: payabli.AchHolderTypePersonal.Ptr(),
                AchRouting: "021000021",
                Method: payabli.PayMethodAchMethodAch,
            },
        },
        ScheduleDetails: &payabli.ScheduleDetail{
            EndDate: payabli.String(
                "2025-03-20",
            ),
            Frequency: payabli.FrequencyWeekly.Ptr(),
            PlanId: payabli.Int(
                1,
            ),
            StartDate: payabli.String(
                "2024-09-20",
            ),
        },
    }
    client.Subscription.NewSubscription(
        context.TODO(),
        request,
    )
}

```

```php ACHSubscription
<?php

namespace Example;

use Payabli\PayabliClient;
use Payabli\Subscription\Requests\RequestSchedule;
use Payabli\Types\PayorDataRequest;
use Payabli\Types\PaymentDetail;
use Payabli\Types\PayMethodCredit;
use Payabli\Types\ScheduleDetail;
use Payabli\Types\Frequency;

$client = new PayabliClient(
    apiKey: 'YOUR_API_KEY_HERE',
);
$client->subscription->newSubscription(
    new RequestSchedule([
        'customerData' => new PayorDataRequest([
            'customerId' => 4440,
        ]),
        'entryPoint' => '8cfec329267',
        'paymentDetails' => new PaymentDetail([
            'totalAmount' => 100,
            'serviceFee' => 0,
        ]),
        'paymentMethod' => new PayMethodCredit([
            'cardexp' => 'value',
            'cardnumber' => 'value',
        ]),
        'scheduleDetails' => new ScheduleDetail([
            'endDate' => '2025-03-20',
            'frequency' => Frequency::Weekly->value,
            'planId' => 1,
            'startDate' => '2024-09-20',
        ]),
    ]),
);

```

```swift ACHSubscription
import Foundation

let headers = [
  "requestToken": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "customerData": ["customerId": 4440],
  "entryPoint": "8cfec329267",
  "paymentDetails": [
    "totalAmount": 100,
    "serviceFee": 0
  ],
  "paymentMethod": [
    "achAccount": "3453445666",
    "achAccountType": "Checking",
    "achCode": "PPD",
    "achHolder": "John Cassian",
    "achHolderType": "personal",
    "achRouting": "021000021",
    "method": "ach"
  ],
  "scheduleDetails": [
    "endDate": "2025-03-20",
    "frequency": "weekly",
    "planId": 1,
    "startDate": "2024-09-20"
  ]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api-sandbox.payabli.com/api/Subscription/add")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

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.

### Request

POST [https://api-sandbox.payabli.com/api/Subscription/add](https://api-sandbox.payabli.com/api/Subscription/add)

```curl StoredMethodSubscription
curl -X POST https://api-sandbox.payabli.com/api/Subscription/add \
     -H "requestToken: <apiKey>" \
     -H "Content-Type: application/json" \
     -d '{
  "customerData": {
    "customerId": 4440
  },
  "entryPoint": "8cfec329267",
  "paymentDetails": {
    "totalAmount": 100,
    "serviceFee": 0
  },
  "paymentMethod": {
    "initiator": "merchant",
    "storedMethodId": "1ec55af9-7b5a-4ff0-81ed-c12d2f95e135-4440",
    "storedMethodUsageType": "recurring"
  },
  "scheduleDetails": {
    "endDate": "2025-03-20",
    "frequency": "weekly",
    "planId": 1,
    "startDate": "2024-09-20"
  }
}'
```

```typescript StoredMethodSubscription
import { PayabliClient } from "@payabli/sdk-node";

async function main() {
    const client = new PayabliClient({
        apiKey: "YOUR_API_KEY_HERE",
    });
    await client.subscription.newSubscription({
        customerData: {
            customerId: 4440,
        },
        entryPoint: "8cfec329267",
        paymentDetails: {
            totalAmount: 100,
            serviceFee: 0,
        },
        paymentMethod: {
            initiator: "merchant",
            storedMethodId: "1ec55af9-7b5a-4ff0-81ed-c12d2f95e135-4440",
            storedMethodUsageType: "recurring",
        },
        scheduleDetails: {
            endDate: "2025-03-20",
            frequency: "weekly",
            planId: 1,
            startDate: "2024-09-20",
        },
    });
}
main();

```

```python StoredMethodSubscription
from payabli import payabli, PayorDataRequest, PaymentDetail, RequestSchedulePaymentMethodInitiator, ScheduleDetail

client = payabli(
    api_key="YOUR_API_KEY_HERE",
)

client.subscription.new_subscription(
    customer_data=PayorDataRequest(
        customer_id=4440,
    ),
    entry_point="8cfec329267",
    payment_details=PaymentDetail(
        total_amount=100,
        service_fee=0,
    ),
    payment_method=RequestSchedulePaymentMethodInitiator(
        initiator="merchant",
        stored_method_id="1ec55af9-7b5a-4ff0-81ed-c12d2f95e135-4440",
        stored_method_usage_type="recurring",
    ),
    schedule_details=ScheduleDetail(
        end_date="2025-03-20",
        frequency="weekly",
        plan_id=1,
        start_date="2024-09-20",
    ),
)

```

```java StoredMethodSubscription
package com.example.usage;

import io.github.payabli.api.PayabliPayabliApiOasClient;
import io.github.payabli.api.resources.subscription.requests.RequestSchedule;
import io.github.payabli.api.types.Frequency;
import io.github.payabli.api.types.PaymentDetail;
import io.github.payabli.api.types.PayorDataRequest;
import io.github.payabli.api.types.RequestSchedulePaymentMethod;
import io.github.payabli.api.types.RequestSchedulePaymentMethodInitiator;
import io.github.payabli.api.types.ScheduleDetail;
import java.util.Optional;

public class Example {
    public static void main(String[] args) {
        PayabliPayabliApiOasClient client = PayabliPayabliApiOasClient
            .builder()
            .apiKey("YOUR_API_KEY_HERE")
            .build();

        client.subscription().newSubscription(
            RequestSchedule
                .builder()
                .customerData(
                    PayorDataRequest
                        .builder()
                        .customerId(4440L)
                        .build()
                )
                .entryPoint("8cfec329267")
                .paymentDetails(
                    PaymentDetail
                        .builder()
                        .totalAmount(100.0)
                        .serviceFee(0.0)
                        .build()
                )
                .paymentMethod(
                    RequestSchedulePaymentMethod.of(
                        RequestSchedulePaymentMethodInitiator
                            .builder()
                            .initiator(Optional.of("merchant"))
                            .storedMethodId(Optional.of("1ec55af9-7b5a-4ff0-81ed-c12d2f95e135-4440"))
                            .storedMethodUsageType(Optional.of("recurring"))
                            .build()
                    )
                )
                .scheduleDetails(
                    ScheduleDetail
                        .builder()
                        .endDate("2025-03-20")
                        .frequency(Frequency.WEEKLY)
                        .planId(1)
                        .startDate("2024-09-20")
                        .build()
                )
                .build()
        );
    }
}
```

```ruby StoredMethodSubscription
require "payabli"

client = Payabli::Client.new(api_key: "YOUR_API_KEY_HERE")

client.subscription.new_subscription(
  customer_data: {
    customer_id: 4440
  },
  entry_point: "8cfec329267",
  payment_details: {
    total_amount: 100,
    service_fee: 0
  },
  payment_method: {
    initiator: "merchant",
    cardexp: "string",
    cardnumber: "string",
    method_: "card"
  },
  schedule_details: {
    end_date: "2025-03-20",
    frequency: "weekly",
    plan_id: 1,
    start_date: "2024-09-20"
  }
)

```

```csharp StoredMethodSubscription
using PayabliPayabliApiOas;
using System.Threading.Tasks;

namespace Usage;

public class Example
{
    public async Task Do() {
        var client = new PayabliPayabliApiOasClient(
            apiKey: "YOUR_API_KEY_HERE"
        );

        await client.Subscription.NewSubscriptionAsync(
            new RequestSchedule {
                CustomerData = new PayorDataRequest {
                    CustomerId = 4440L
                },
                EntryPoint = "8cfec329267",
                PaymentDetails = new PaymentDetail {
                    TotalAmount = 100,
                    ServiceFee = 0
                },
                PaymentMethod = new RequestSchedulePaymentMethodInitiator {
                    Initiator = "merchant",
                    StoredMethodId = "1ec55af9-7b5a-4ff0-81ed-c12d2f95e135-4440",
                    StoredMethodUsageType = "recurring"
                },
                ScheduleDetails = new ScheduleDetail {
                    EndDate = "2025-03-20",
                    Frequency = Frequency.Weekly,
                    PlanId = 1,
                    StartDate = "2024-09-20"
                }
            }
        );
    }

}

```

```go StoredMethodSubscription
package example

import (
    context "context"

    payabli "github.com/payabli/sdk-go"
    client "github.com/payabli/sdk-go/client"
    option "github.com/payabli/sdk-go/option"
)

func do() {
    client := client.NewClient(
        option.WithApiKey(
            "YOUR_API_KEY_HERE",
        ),
    )
    request := &payabli.RequestSchedule{
        CustomerData: &payabli.PayorDataRequest{
            CustomerId: payabli.Int64(
                int64(4440),
            ),
        },
        EntryPoint: payabli.String(
            "8cfec329267",
        ),
        PaymentDetails: &payabli.PaymentDetail{
            TotalAmount: 100,
            ServiceFee: payabli.Float64(
                0,
            ),
        },
        PaymentMethod: &payabli.RequestSchedulePaymentMethod{
            RequestSchedulePaymentMethodInitiator: &payabli.RequestSchedulePaymentMethodInitiator{
                Initiator: payabli.String(
                    "merchant",
                ),
                StoredMethodId: payabli.String(
                    "1ec55af9-7b5a-4ff0-81ed-c12d2f95e135-4440",
                ),
                StoredMethodUsageType: payabli.String(
                    "recurring",
                ),
            },
        },
        ScheduleDetails: &payabli.ScheduleDetail{
            EndDate: payabli.String(
                "2025-03-20",
            ),
            Frequency: payabli.FrequencyWeekly.Ptr(),
            PlanId: payabli.Int(
                1,
            ),
            StartDate: payabli.String(
                "2024-09-20",
            ),
        },
    }
    client.Subscription.NewSubscription(
        context.TODO(),
        request,
    )
}

```

```php StoredMethodSubscription
<?php

namespace Example;

use Payabli\PayabliClient;
use Payabli\Subscription\Requests\RequestSchedule;
use Payabli\Types\PayorDataRequest;
use Payabli\Types\PaymentDetail;
use Payabli\Types\PayMethodCredit;
use Payabli\Types\PayMethodCreditMethod;
use Payabli\Types\ScheduleDetail;
use Payabli\Types\Frequency;

$client = new PayabliClient(
    apiKey: 'YOUR_API_KEY_HERE',
);
$client->subscription->newSubscription(
    new RequestSchedule([
        'customerData' => new PayorDataRequest([
            'customerId' => 4440,
        ]),
        'entryPoint' => '8cfec329267',
        'paymentDetails' => new PaymentDetail([
            'totalAmount' => 100,
            'serviceFee' => 0,
        ]),
        'paymentMethod' => new PayMethodCredit([
            'initiator' => 'merchant',
            'cardexp' => 'value',
            'cardnumber' => 'value',
            'method' => PayMethodCreditMethod::Card->value,
        ]),
        'scheduleDetails' => new ScheduleDetail([
            'endDate' => '2025-03-20',
            'frequency' => Frequency::Weekly->value,
            'planId' => 1,
            'startDate' => '2024-09-20',
        ]),
    ]),
);

```

```swift StoredMethodSubscription
import Foundation

let headers = [
  "requestToken": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "customerData": ["customerId": 4440],
  "entryPoint": "8cfec329267",
  "paymentDetails": [
    "totalAmount": 100,
    "serviceFee": 0
  ],
  "paymentMethod": [
    "initiator": "merchant",
    "storedMethodId": "1ec55af9-7b5a-4ff0-81ed-c12d2f95e135-4440",
    "storedMethodUsageType": "recurring"
  ],
  "scheduleDetails": [
    "endDate": "2025-03-20",
    "frequency": "weekly",
    "planId": 1,
    "startDate": "2024-09-20"
  ]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api-sandbox.payabli.com/api/Subscription/add")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

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](/guides/pay-in-components-express-checkout#tokenize-a-payment-method-1) for more information on how to tokenize digital wallets with the Express Checkout component.
See the [Apple Pay overview](/guides/pay-in-wallets-apple-pay-overview) and [Google Pay™ overview](/guides/pay-in-wallets-google-pay-overview) docs for more information on Apple Pay and Google Pay.

### Request

POST [https://api-sandbox.payabli.com/api/Subscription/add](https://api-sandbox.payabli.com/api/Subscription/add)

```curl StoredMethodSubscription
curl -X POST https://api-sandbox.payabli.com/api/Subscription/add \
     -H "requestToken: <apiKey>" \
     -H "Content-Type: application/json" \
     -d '{
  "customerData": {
    "customerId": 4440
  },
  "entryPoint": "8cfec329267",
  "paymentDetails": {
    "totalAmount": 100,
    "serviceFee": 0
  },
  "paymentMethod": {
    "initiator": "merchant",
    "storedMethodId": "1ec55af9-7b5a-4ff0-81ed-c12d2f95e135-4440",
    "storedMethodUsageType": "recurring"
  },
  "scheduleDetails": {
    "endDate": "2025-03-20",
    "frequency": "weekly",
    "planId": 1,
    "startDate": "2024-09-20"
  }
}'
```

```typescript StoredMethodSubscription
import { PayabliClient } from "@payabli/sdk-node";

async function main() {
    const client = new PayabliClient({
        apiKey: "YOUR_API_KEY_HERE",
    });
    await client.subscription.newSubscription({
        customerData: {
            customerId: 4440,
        },
        entryPoint: "8cfec329267",
        paymentDetails: {
            totalAmount: 100,
            serviceFee: 0,
        },
        paymentMethod: {
            initiator: "merchant",
            storedMethodId: "1ec55af9-7b5a-4ff0-81ed-c12d2f95e135-4440",
            storedMethodUsageType: "recurring",
        },
        scheduleDetails: {
            endDate: "2025-03-20",
            frequency: "weekly",
            planId: 1,
            startDate: "2024-09-20",
        },
    });
}
main();

```

```python StoredMethodSubscription
from payabli import payabli, PayorDataRequest, PaymentDetail, RequestSchedulePaymentMethodInitiator, ScheduleDetail

client = payabli(
    api_key="YOUR_API_KEY_HERE",
)

client.subscription.new_subscription(
    customer_data=PayorDataRequest(
        customer_id=4440,
    ),
    entry_point="8cfec329267",
    payment_details=PaymentDetail(
        total_amount=100,
        service_fee=0,
    ),
    payment_method=RequestSchedulePaymentMethodInitiator(
        initiator="merchant",
        stored_method_id="1ec55af9-7b5a-4ff0-81ed-c12d2f95e135-4440",
        stored_method_usage_type="recurring",
    ),
    schedule_details=ScheduleDetail(
        end_date="2025-03-20",
        frequency="weekly",
        plan_id=1,
        start_date="2024-09-20",
    ),
)

```

```java StoredMethodSubscription
package com.example.usage;

import io.github.payabli.api.PayabliPayabliApiOasClient;
import io.github.payabli.api.resources.subscription.requests.RequestSchedule;
import io.github.payabli.api.types.Frequency;
import io.github.payabli.api.types.PaymentDetail;
import io.github.payabli.api.types.PayorDataRequest;
import io.github.payabli.api.types.RequestSchedulePaymentMethod;
import io.github.payabli.api.types.RequestSchedulePaymentMethodInitiator;
import io.github.payabli.api.types.ScheduleDetail;
import java.util.Optional;

public class Example {
    public static void main(String[] args) {
        PayabliPayabliApiOasClient client = PayabliPayabliApiOasClient
            .builder()
            .apiKey("YOUR_API_KEY_HERE")
            .build();

        client.subscription().newSubscription(
            RequestSchedule
                .builder()
                .customerData(
                    PayorDataRequest
                        .builder()
                        .customerId(4440L)
                        .build()
                )
                .entryPoint("8cfec329267")
                .paymentDetails(
                    PaymentDetail
                        .builder()
                        .totalAmount(100.0)
                        .serviceFee(0.0)
                        .build()
                )
                .paymentMethod(
                    RequestSchedulePaymentMethod.of(
                        RequestSchedulePaymentMethodInitiator
                            .builder()
                            .initiator(Optional.of("merchant"))
                            .storedMethodId(Optional.of("1ec55af9-7b5a-4ff0-81ed-c12d2f95e135-4440"))
                            .storedMethodUsageType(Optional.of("recurring"))
                            .build()
                    )
                )
                .scheduleDetails(
                    ScheduleDetail
                        .builder()
                        .endDate("2025-03-20")
                        .frequency(Frequency.WEEKLY)
                        .planId(1)
                        .startDate("2024-09-20")
                        .build()
                )
                .build()
        );
    }
}
```

```ruby StoredMethodSubscription
require "payabli"

client = Payabli::Client.new(api_key: "YOUR_API_KEY_HERE")

client.subscription.new_subscription(
  customer_data: {
    customer_id: 4440
  },
  entry_point: "8cfec329267",
  payment_details: {
    total_amount: 100,
    service_fee: 0
  },
  payment_method: {
    initiator: "merchant",
    cardexp: "string",
    cardnumber: "string",
    method_: "card"
  },
  schedule_details: {
    end_date: "2025-03-20",
    frequency: "weekly",
    plan_id: 1,
    start_date: "2024-09-20"
  }
)

```

```csharp StoredMethodSubscription
using PayabliPayabliApiOas;
using System.Threading.Tasks;

namespace Usage;

public class Example
{
    public async Task Do() {
        var client = new PayabliPayabliApiOasClient(
            apiKey: "YOUR_API_KEY_HERE"
        );

        await client.Subscription.NewSubscriptionAsync(
            new RequestSchedule {
                CustomerData = new PayorDataRequest {
                    CustomerId = 4440L
                },
                EntryPoint = "8cfec329267",
                PaymentDetails = new PaymentDetail {
                    TotalAmount = 100,
                    ServiceFee = 0
                },
                PaymentMethod = new RequestSchedulePaymentMethodInitiator {
                    Initiator = "merchant",
                    StoredMethodId = "1ec55af9-7b5a-4ff0-81ed-c12d2f95e135-4440",
                    StoredMethodUsageType = "recurring"
                },
                ScheduleDetails = new ScheduleDetail {
                    EndDate = "2025-03-20",
                    Frequency = Frequency.Weekly,
                    PlanId = 1,
                    StartDate = "2024-09-20"
                }
            }
        );
    }

}

```

```go StoredMethodSubscription
package example

import (
    context "context"

    payabli "github.com/payabli/sdk-go"
    client "github.com/payabli/sdk-go/client"
    option "github.com/payabli/sdk-go/option"
)

func do() {
    client := client.NewClient(
        option.WithApiKey(
            "YOUR_API_KEY_HERE",
        ),
    )
    request := &payabli.RequestSchedule{
        CustomerData: &payabli.PayorDataRequest{
            CustomerId: payabli.Int64(
                int64(4440),
            ),
        },
        EntryPoint: payabli.String(
            "8cfec329267",
        ),
        PaymentDetails: &payabli.PaymentDetail{
            TotalAmount: 100,
            ServiceFee: payabli.Float64(
                0,
            ),
        },
        PaymentMethod: &payabli.RequestSchedulePaymentMethod{
            RequestSchedulePaymentMethodInitiator: &payabli.RequestSchedulePaymentMethodInitiator{
                Initiator: payabli.String(
                    "merchant",
                ),
                StoredMethodId: payabli.String(
                    "1ec55af9-7b5a-4ff0-81ed-c12d2f95e135-4440",
                ),
                StoredMethodUsageType: payabli.String(
                    "recurring",
                ),
            },
        },
        ScheduleDetails: &payabli.ScheduleDetail{
            EndDate: payabli.String(
                "2025-03-20",
            ),
            Frequency: payabli.FrequencyWeekly.Ptr(),
            PlanId: payabli.Int(
                1,
            ),
            StartDate: payabli.String(
                "2024-09-20",
            ),
        },
    }
    client.Subscription.NewSubscription(
        context.TODO(),
        request,
    )
}

```

```php StoredMethodSubscription
<?php

namespace Example;

use Payabli\PayabliClient;
use Payabli\Subscription\Requests\RequestSchedule;
use Payabli\Types\PayorDataRequest;
use Payabli\Types\PaymentDetail;
use Payabli\Types\PayMethodCredit;
use Payabli\Types\PayMethodCreditMethod;
use Payabli\Types\ScheduleDetail;
use Payabli\Types\Frequency;

$client = new PayabliClient(
    apiKey: 'YOUR_API_KEY_HERE',
);
$client->subscription->newSubscription(
    new RequestSchedule([
        'customerData' => new PayorDataRequest([
            'customerId' => 4440,
        ]),
        'entryPoint' => '8cfec329267',
        'paymentDetails' => new PaymentDetail([
            'totalAmount' => 100,
            'serviceFee' => 0,
        ]),
        'paymentMethod' => new PayMethodCredit([
            'initiator' => 'merchant',
            'cardexp' => 'value',
            'cardnumber' => 'value',
            'method' => PayMethodCreditMethod::Card->value,
        ]),
        'scheduleDetails' => new ScheduleDetail([
            'endDate' => '2025-03-20',
            'frequency' => Frequency::Weekly->value,
            'planId' => 1,
            'startDate' => '2024-09-20',
        ]),
    ]),
);

```

```swift StoredMethodSubscription
import Foundation

let headers = [
  "requestToken": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "customerData": ["customerId": 4440],
  "entryPoint": "8cfec329267",
  "paymentDetails": [
    "totalAmount": 100,
    "serviceFee": 0
  ],
  "paymentMethod": [
    "initiator": "merchant",
    "storedMethodId": "1ec55af9-7b5a-4ff0-81ed-c12d2f95e135-4440",
    "storedMethodUsageType": "recurring"
  ],
  "scheduleDetails": [
    "endDate": "2025-03-20",
    "frequency": "weekly",
    "planId": 1,
    "startDate": "2024-09-20"
  ]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api-sandbox.payabli.com/api/Subscription/add")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

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](#balancedriven-schedule-rules) for the constraints.

### Request

POST [https://api-sandbox.payabli.com/api/Subscription/add](https://api-sandbox.payabli.com/api/Subscription/add)

```curl BalanceDrivenSubscription
curl -X POST https://api-sandbox.payabli.com/api/Subscription/add \
     -H "requestToken: <apiKey>" \
     -H "Content-Type: application/json" \
     -d '{
  "customerData": {
    "customerId": 4440
  },
  "entryPoint": "8cfec329267",
  "paymentDetails": {
    "totalAmount": 100,
    "serviceFee": 0
  },
  "paymentMethod": {
    "cardHolder": "John Cassian",
    "cardcvv": "123",
    "cardexp": "12/29",
    "cardnumber": "4111111111111111",
    "cardzip": "37615",
    "initiator": "payor",
    "method": "card"
  },
  "scheduleDetails": {
    "frequency": "endofmonth"
  },
  "subscriptionType": "BalanceDriven"
}'
```

```typescript BalanceDrivenSubscription
import { PayabliClient } from "@payabli/sdk-node";

async function main() {
    const client = new PayabliClient({
        apiKey: "YOUR_API_KEY_HERE",
    });
    await client.subscription.newSubscription({
        customerData: {
            customerId: 4440,
        },
        entryPoint: "8cfec329267",
        paymentDetails: {
            totalAmount: 100,
            serviceFee: 0,
        },
        paymentMethod: {
            cardHolder: "John Cassian",
            cardcvv: "123",
            cardexp: "12/29",
            cardnumber: "4111111111111111",
            cardzip: "37615",
            initiator: "payor",
            method: "card",
        },
        scheduleDetails: {
            frequency: "endofmonth",
        },
        subscriptionType: "BalanceDriven",
    });
}
main();

```

```python BalanceDrivenSubscription
from payabli import payabli, PayorDataRequest, PaymentDetail, PayMethodCredit, ScheduleDetail

client = payabli(
    api_key="YOUR_API_KEY_HERE",
)

client.subscription.new_subscription(
    customer_data=PayorDataRequest(
        customer_id=4440,
    ),
    entry_point="8cfec329267",
    payment_details=PaymentDetail(
        total_amount=100,
        service_fee=0,
    ),
    payment_method=PayMethodCredit(
        card_holder="John Cassian",
        cardcvv="123",
        cardexp="12/29",
        cardnumber="4111111111111111",
        cardzip="37615",
        initiator="payor",
        method="card",
    ),
    schedule_details=ScheduleDetail(
        frequency="endofmonth",
    ),
    subscription_type="BalanceDriven",
)

```

```java BalanceDrivenSubscription
package com.example.usage;

import io.github.payabli.api.PayabliPayabliApiOasClient;
import io.github.payabli.api.resources.subscription.requests.RequestSchedule;
import io.github.payabli.api.types.Frequency;
import io.github.payabli.api.types.PayMethodCredit;
import io.github.payabli.api.types.PayMethodCreditMethod;
import io.github.payabli.api.types.PaymentDetail;
import io.github.payabli.api.types.PayorDataRequest;
import io.github.payabli.api.types.RequestSchedulePaymentMethod;
import io.github.payabli.api.types.ScheduleDetail;
import io.github.payabli.api.types.SubscriptionType;
import java.util.Optional;

public class Example {
    public static void main(String[] args) {
        PayabliPayabliApiOasClient client = PayabliPayabliApiOasClient
            .builder()
            .apiKey("YOUR_API_KEY_HERE")
            .build();

        client.subscription().newSubscription(
            RequestSchedule
                .builder()
                .customerData(
                    PayorDataRequest
                        .builder()
                        .customerId(4440L)
                        .build()
                )
                .entryPoint("8cfec329267")
                .paymentDetails(
                    PaymentDetail
                        .builder()
                        .totalAmount(100.0)
                        .serviceFee(0.0)
                        .build()
                )
                .paymentMethod(
                    RequestSchedulePaymentMethod.of(
                        PayMethodCredit
                            .builder()
                            .cardexp("12/29")
                            .cardnumber("4111111111111111")
                            .method(PayMethodCreditMethod.CARD)
                            .cardcvv(Optional.of("123"))
                            .cardHolder(Optional.of("John Cassian"))
                            .cardzip(Optional.of("37615"))
                            .initiator(Optional.of("payor"))
                            .build()
                    )
                )
                .scheduleDetails(
                    ScheduleDetail
                        .builder()
                        .frequency(Frequency.END_OF_MONTH)
                        .build()
                )
                .subscriptionType(SubscriptionType.BALANCE_DRIVEN)
                .build()
        );
    }
}
```

```ruby BalanceDrivenSubscription
require "payabli"

client = Payabli::Client.new(api_key: "YOUR_API_KEY_HERE")

client.subscription.new_subscription(
  customer_data: {
    customer_id: 4440
  },
  entry_point: "8cfec329267",
  payment_details: {
    total_amount: 100,
    service_fee: 0
  },
  payment_method: {
    card_holder: "John Cassian",
    cardcvv: "123",
    cardexp: "12/29",
    cardnumber: "4111111111111111",
    cardzip: "37615",
    initiator: "payor",
    method_: "card"
  },
  schedule_details: {}
)

```

```csharp BalanceDrivenSubscription
using PayabliPayabliApiOas;
using System.Threading.Tasks;

namespace Usage;

public class Example
{
    public async Task Do() {
        var client = new PayabliPayabliApiOasClient(
            apiKey: "YOUR_API_KEY_HERE"
        );

        await client.Subscription.NewSubscriptionAsync(
            new RequestSchedule {
                CustomerData = new PayorDataRequest {
                    CustomerId = 4440L
                },
                EntryPoint = "8cfec329267",
                PaymentDetails = new PaymentDetail {
                    TotalAmount = 100,
                    ServiceFee = 0
                },
                PaymentMethod = new PayMethodCredit {
                    CardHolder = "John Cassian",
                    Cardcvv = "123",
                    Cardexp = "12/29",
                    Cardnumber = "4111111111111111",
                    Cardzip = "37615",
                    Initiator = "payor",
                    Method = PayMethodCreditMethod.Card
                },
                ScheduleDetails = new ScheduleDetail {
                    Frequency = Frequency.EndOfMonth
                },
                SubscriptionType = SubscriptionType.BalanceDriven
            }
        );
    }

}

```

```go BalanceDrivenSubscription
package example

import (
    context "context"

    payabli "github.com/payabli/sdk-go"
    client "github.com/payabli/sdk-go/client"
    option "github.com/payabli/sdk-go/option"
)

func do() {
    client := client.NewClient(
        option.WithApiKey(
            "YOUR_API_KEY_HERE",
        ),
    )
    request := &payabli.RequestSchedule{
        CustomerData: &payabli.PayorDataRequest{
            CustomerId: payabli.Int64(
                int64(4440),
            ),
        },
        EntryPoint: payabli.String(
            "8cfec329267",
        ),
        PaymentDetails: &payabli.PaymentDetail{
            TotalAmount: 100,
            ServiceFee: payabli.Float64(
                0,
            ),
        },
        PaymentMethod: &payabli.RequestSchedulePaymentMethod{
            PayMethodCredit: &payabli.PayMethodCredit{
                CardHolder: payabli.String(
                    "John Cassian",
                ),
                Cardcvv: payabli.String(
                    "123",
                ),
                Cardexp: "12/29",
                Cardnumber: "4111111111111111",
                Cardzip: payabli.String(
                    "37615",
                ),
                Initiator: payabli.String(
                    "payor",
                ),
                Method: payabli.PayMethodCreditMethodCard,
            },
        },
        ScheduleDetails: &payabli.ScheduleDetail{
            Frequency: payabli.FrequencyEndOfMonth.Ptr(),
        },
        SubscriptionType: payabli.SubscriptionTypeBalanceDriven.Ptr(),
    }
    client.Subscription.NewSubscription(
        context.TODO(),
        request,
    )
}

```

```php BalanceDrivenSubscription
<?php

namespace Example;

use Payabli\PayabliClient;
use Payabli\Subscription\Requests\RequestSchedule;
use Payabli\Types\PayorDataRequest;
use Payabli\Types\PaymentDetail;
use Payabli\Types\PayMethodCredit;
use Payabli\Types\PayMethodCreditMethod;
use Payabli\Types\ScheduleDetail;
use Payabli\Types\Frequency;
use Payabli\Types\SubscriptionType;

$client = new PayabliClient(
    apiKey: 'YOUR_API_KEY_HERE',
);
$client->subscription->newSubscription(
    new RequestSchedule([
        'customerData' => new PayorDataRequest([
            'customerId' => 4440,
        ]),
        'entryPoint' => '8cfec329267',
        'paymentDetails' => new PaymentDetail([
            'totalAmount' => 100,
            'serviceFee' => 0,
        ]),
        'paymentMethod' => new PayMethodCredit([
            'cardHolder' => 'John Cassian',
            'cardcvv' => '123',
            'cardexp' => '12/29',
            'cardnumber' => '4111111111111111',
            'cardzip' => '37615',
            'initiator' => 'payor',
            'method' => PayMethodCreditMethod::Card->value,
        ]),
        'scheduleDetails' => new ScheduleDetail([
            'frequency' => Frequency::EndOfMonth->value,
        ]),
        'subscriptionType' => SubscriptionType::BalanceDriven->value,
    ]),
);

```

```swift BalanceDrivenSubscription
import Foundation

let headers = [
  "requestToken": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "customerData": ["customerId": 4440],
  "entryPoint": "8cfec329267",
  "paymentDetails": [
    "totalAmount": 100,
    "serviceFee": 0
  ],
  "paymentMethod": [
    "cardHolder": "John Cassian",
    "cardcvv": "123",
    "cardexp": "12/29",
    "cardnumber": "4111111111111111",
    "cardzip": "37615",
    "initiator": "payor",
    "method": "card"
  ],
  "scheduleDetails": ["frequency": "endofmonth"],
  "subscriptionType": "BalanceDriven"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api-sandbox.payabli.com/api/Subscription/add")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

A successful request sends a response that includes the subscription ID (in `responseData`) and customer ID.

### Response (200)

```json
{
  "responseText": "Success",
  "responseData": 396,
  "customerId": 4440,
  "isSuccess": true
}
```

## 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`.

### Request

GET [https://api-sandbox.payabli.com/api/Subscription/\{subId}](https://api-sandbox.payabli.com/api/Subscription/\{subId})

```curl GetSubscription
curl https://api-sandbox.payabli.com/api/Subscription/231 \
     -H "requestToken: <apiKey>"
```

```typescript GetSubscription
import { PayabliClient } from "@payabli/sdk-node";

async function main() {
    const client = new PayabliClient({
        apiKey: "YOUR_API_KEY_HERE",
    });
    await client.subscription.getSubscription(231);
}
main();

```

```python GetSubscription
from payabli import payabli

client = payabli(
    api_key="YOUR_API_KEY_HERE",
)

client.subscription.get_subscription(
    sub_id=231,
)

```

```java GetSubscription
package com.example.usage;

import io.github.payabli.api.PayabliPayabliApiOasClient;

public class Example {
    public static void main(String[] args) {
        PayabliPayabliApiOasClient client = PayabliPayabliApiOasClient
            .builder()
            .apiKey("YOUR_API_KEY_HERE")
            .build();

        client.subscription().getSubscription(231);
    }
}
```

```ruby GetSubscription
require "payabli"

client = Payabli::Client.new(api_key: "YOUR_API_KEY_HERE")

client.subscription.get_subscription(sub_id: 231)

```

```csharp GetSubscription
using PayabliPayabliApiOas;
using System.Threading.Tasks;

namespace Usage;

public class Example
{
    public async Task Do() {
        var client = new PayabliPayabliApiOasClient(
            apiKey: "YOUR_API_KEY_HERE"
        );

        await client.Subscription.GetSubscriptionAsync(
            231
        );
    }

}

```

```go GetSubscription
package example

import (
    context "context"

    client "github.com/payabli/sdk-go/client"
    option "github.com/payabli/sdk-go/option"
)

func do() {
    client := client.NewClient(
        option.WithApiKey(
            "YOUR_API_KEY_HERE",
        ),
    )
    client.Subscription.GetSubscription(
        context.TODO(),
        231,
    )
}

```

```php GetSubscription
<?php

namespace Example;

use Payabli\PayabliClient;

$client = new PayabliClient(
    apiKey: 'YOUR_API_KEY_HERE',
);
$client->subscription->getSubscription(
    231,
);

```

```swift GetSubscription
import Foundation

let headers = ["requestToken": "<apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api-sandbox.payabli.com/api/Subscription/231")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

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](/developers/api-reference/subscription/get-subscription) for a full response example.

### Response (200)

```json
{
  "EndDate": "2025-10-19T00:00:00Z",
  "LastRun": "2025-10-19T00:00:00Z",
  "NextDate": "2025-10-19T00:00:00Z",
  "StartDate": "2025-10-19T00:00:00Z",
  "CreatedAt": "2022-07-01T15:00:01Z",
  "Customer": {
    "Identifiers": [
      "\\\"firstname\\\"",
      "\\\"lastname\\\"",
      "\\\"email\\\"",
      "\\\"customId\\\""
    ],
    "FirstName": "John",
    "LastName": "Doe",
    "CompanyName": "Sunshine LLC",
    "BillingAddress1": "1111 West 1st Street",
    "BillingAddress2": "Suite 200",
    "BillingCity": "Miami",
    "BillingState": "FL",
    "BillingZip": "45567",
    "BillingCountry": "US",
    "BillingPhone": "5555555555",
    "BillingEmail": "example@email.com",
    "CustomerNumber": "C-90010",
    "ShippingAddress1": "123 Walnut St",
    "ShippingAddress2": "STE 900",
    "ShippingCity": "Johnson City",
    "ShippingState": "TN",
    "ShippingZip": "37619",
    "ShippingCountry": "US",
    "customerId": 4440,
    "customerStatus": 1,
    "AdditionalData": null
  },
  "EntrypageId": 0,
  "ExternalPaypointID": "Paypoint-100",
  "FeeAmount": 3,
  "Frequency": "monthly",
  "IdSub": 396,
  "invoiceData": {
    "AdditionalData": null,
    "attachments": [
      {}
    ],
    "company": "ACME, INC",
    "discount": 10,
    "dutyAmount": 0,
    "firstName": "Chad",
    "freightAmount": 10,
    "frequency": "onetime",
    "invoiceAmount": 105,
    "invoiceDate": "2025-07-01",
    "invoiceDueDate": "2025-07-01",
    "invoiceEndDate": "2025-07-01",
    "invoiceNumber": "INV-2345",
    "invoiceStatus": 1,
    "invoiceType": 0,
    "items": [
      {
        "itemCost": 5,
        "itemProductName": "Materials deposit",
        "itemQty": 1
      }
    ],
    "lastName": "Mercia",
    "notes": "Example notes.",
    "paymentTerms": "PIA",
    "purchaseOrder": "PO-345",
    "shippingAddress1": "123 Walnut St",
    "shippingAddress2": "STE 900",
    "shippingCity": "Johnson City",
    "shippingCountry": "US",
    "shippingEmail": "example@email.com",
    "shippingFromZip": "30040",
    "shippingPhone": "5555555555",
    "shippingState": "TN",
    "shippingZip": "37619",
    "summaryCommodityCode": "501718",
    "tax": 2.05,
    "termsConditions": "Must be paid before work scheduled."
  },
  "LastUpdated": "2022-07-01T15:00:01Z",
  "LeftCycles": 15,
  "Method": "card",
  "NetAmount": 3762.87,
  "ParentOrgName": "PropertyManager Pro",
  "PaymentData": {
    "AccountExp": "11/29",
    "accountId": "accountId",
    "AccountType": "visa",
    "AccountZip": "90210",
    "binData": {
      "binMatchedLength": "6",
      "binCardBrand": "Visa",
      "binCardType": "Credit",
      "binCardCategory": "PLATINUM",
      "binCardIssuer": "Bank of Example",
      "binCardIssuerCountry": "United States",
      "binCardIssuerCountryCodeA2": "US",
      "binCardIssuerCountryNumber": "840",
      "binCardIsRegulated": "false",
      "binCardUseCategory": "Consumer",
      "binCardIssuerCountryCodeA3": "USA"
    },
    "HolderName": "Chad Mercia",
    "Initiator": "payor",
    "MaskedAccount": "4XXXXXXXX1111",
    "orderDescription": "Depost for materials for 123 Walnut St",
    "paymentDetails": {
      "totalAmount": 100,
      "categories": [
        {
          "amount": 1000,
          "label": "Deposit"
        }
      ],
      "checkImage": {
        "key": "value"
      },
      "checkNumber": "107",
      "currency": "USD",
      "serviceFee": 0,
      "splitFunding": [
        {}
      ]
    },
    "Sequence": "subsequent",
    "SignatureData": "SignatureData",
    "StoredId": "1ec55af9-7b5a-4ff0-81ed-c12d2f95e135-4440",
    "StoredMethodUsageType": "subscription"
  },
  "PaypointDbaname": "Sunshine Gutters",
  "PaypointEntryname": "d193cf9a46",
  "PaypointId": 3040,
  "PaypointLegalname": "Sunshine Services, LLC",
  "PlanId": 0,
  "Source": "api",
  "SubEvents": [
    {
      "description": "TransferCreated",
      "eventTime": "2023-07-05T22:31:06Z",
      "extraData": null,
      "refData": "refData",
      "source": "api"
    }
  ],
  "SubStatus": 1,
  "SubscriptionType": "Regular",
  "TotalAmount": 103,
  "TotalCycles": 24,
  "UntilCancelled": true
}
```

A BalanceDriven subscription returns `SubscriptionType: BalanceDriven`, a monthly `Frequency`, and `UntilCancelled: true`. The `executed` event in `SubEvents` shows the amount charged on each run.

### Response (200)

```json
{
  "EndDate": "2046-05-01T00:00:00Z",
  "LastRun": "2026-05-13T14:14:22Z",
  "NextDate": "2026-06-01T00:00:00Z",
  "StartDate": "2026-05-01T00:00:00Z",
  "StoredMethod": {
    "IdPmethod": "1ec55af9-7b5a-4ff0-81ed-c12d2f95e135-4440",
    "Method": "card",
    "Descriptor": "visa",
    "MaskedAccount": "4XXXXXXXX1111",
    "ExpDate": "1129",
    "HolderName": "Chad Mercia",
    "AchSecCode": null,
    "AchHolderType": null,
    "IsValidatedACH": false,
    "BIN": "",
    "binData": {
      "binMatchedLength": "6",
      "binCardBrand": "Visa",
      "binCardType": "Credit",
      "binCardCategory": "PLATINUM",
      "binCardIssuer": "Bank of Example",
      "binCardIssuerCountry": "United States",
      "binCardIssuerCountryCodeA2": "US",
      "binCardIssuerCountryNumber": "840",
      "binCardIsRegulated": "false",
      "binCardUseCategory": "Consumer",
      "binCardIssuerCountryCodeA3": "USA"
    },
    "ABA": "",
    "PostalCode": "37619",
    "MethodType": "Single Merchant",
    "LastUpdated": "2026-05-12T15:25:28Z",
    "CardUpdatedOn": "1970-01-01T00:00:00Z"
  },
  "CreatedAt": "2026-05-12T15:25:28Z",
  "Customer": {
    "Identifiers": [
      "\\\"firstname\\\"",
      "\\\"lastname\\\""
    ],
    "FirstName": "John",
    "LastName": "Doe",
    "CompanyName": "Sunshine LLC",
    "BillingAddress1": "1111 West 1st Street",
    "BillingAddress2": "Suite 200",
    "BillingCity": "Miami",
    "BillingState": "FL",
    "BillingZip": "45567",
    "BillingCountry": "US",
    "BillingPhone": "5555555555",
    "BillingEmail": "example@email.com",
    "CustomerNumber": "C-90010",
    "ShippingAddress1": "123 Walnut St",
    "ShippingAddress2": "STE 900",
    "ShippingCity": "Johnson City",
    "ShippingState": "TN",
    "ShippingZip": "37619",
    "ShippingCountry": "US",
    "customerId": 4440,
    "customerStatus": 1,
    "AdditionalData": null
  },
  "EntrypageId": 0,
  "ExternalPaypointID": "Paypoint-100",
  "FeeAmount": 0,
  "Frequency": "firstofmonth",
  "IdSub": 50317,
  "invoiceData": null,
  "LastUpdated": "2026-05-12T15:25:28Z",
  "LeftCycles": 238,
  "Method": "card",
  "NetAmount": 0,
  "ParentOrgName": "PropertyManager Pro",
  "PaymentData": {
    "AccountExp": "11/29",
    "accountId": "accountId",
    "AccountType": "visa",
    "AccountZip": "90210",
    "binData": {
      "binMatchedLength": "6",
      "binCardBrand": "Visa",
      "binCardType": "Credit",
      "binCardCategory": "PLATINUM",
      "binCardIssuer": "Bank of Example",
      "binCardIssuerCountry": "United States",
      "binCardIssuerCountryCodeA2": "US",
      "binCardIssuerCountryNumber": "840",
      "binCardIsRegulated": "false",
      "binCardUseCategory": "Consumer",
      "binCardIssuerCountryCodeA3": "USA"
    },
    "HolderName": "Chad Mercia",
    "Initiator": "payor",
    "MaskedAccount": "4XXXXXXXX1111",
    "orderDescription": null,
    "paymentDetails": {
      "totalAmount": 0,
      "categories": [],
      "checkImage": null,
      "checkNumber": null,
      "currency": "USD",
      "serviceFee": 0,
      "splitFunding": []
    },
    "Sequence": "subsequent",
    "SignatureData": null,
    "StoredId": "1ec55af9-7b5a-4ff0-81ed-c12d2f95e135-4440",
    "StoredMethodUsageType": "subscription"
  },
  "PaypointDbaname": "Sunshine Gutters",
  "PaypointEntryname": "d193cf9a46",
  "PaypointId": 3040,
  "PaypointLegalname": "Sunshine Services, LLC",
  "PlanId": 0,
  "Source": "api",
  "SubEvents": [
    {
      "description": "created",
      "eventTime": "2026-05-12T15:25:27Z",
      "extraData": null,
      "refData": "0HNLG6L6JNIP5:00000001",
      "source": null
    },
    {
      "description": "executed",
      "eventTime": "2026-05-13T14:14:27Z",
      "extraData": "{\"totalAmount\":13.5,\"serviceFee\":1.5}",
      "refData": "autopay worker",
      "source": null
    }
  ],
  "SubStatus": 1,
  "SubscriptionType": "BalanceDriven",
  "TotalAmount": 0,
  "TotalCycles": 239,
  "UntilCancelled": true
}
```

## 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](/developers/api-reference/subscription/update-subscription) for this endpoint for full documentation.

You can't change `subscriptionType` after creation. If you include it in an update request, it's ignored.

### Request

PUT [https://api-sandbox.payabli.com/api/Subscription/\{subId}](https://api-sandbox.payabli.com/api/Subscription/\{subId})

```curl UpdateSubscription
curl -X PUT https://api-sandbox.payabli.com/api/Subscription/231 \
     -H "requestToken: <apiKey>" \
     -H "Content-Type: application/json" \
     -d '{
  "paymentDetails": {
    "totalAmount": 100,
    "serviceFee": 0
  },
  "scheduleDetails": {
    "endDate": "2025-03-20",
    "frequency": "weekly",
    "planId": 1,
    "startDate": "2024-09-20"
  }
}'
```

```typescript UpdateSubscription
import { PayabliClient } from "@payabli/sdk-node";

async function main() {
    const client = new PayabliClient({
        apiKey: "YOUR_API_KEY_HERE",
    });
    await client.subscription.updateSubscription(231, {
        paymentDetails: {
            totalAmount: 100,
            serviceFee: 0,
        },
        scheduleDetails: {
            endDate: "2025-03-20",
            frequency: "weekly",
            planId: 1,
            startDate: "2024-09-20",
        },
    });
}
main();

```

```python UpdateSubscription
from payabli import payabli, PaymentDetail, ScheduleDetail

client = payabli(
    api_key="YOUR_API_KEY_HERE",
)

client.subscription.update_subscription(
    sub_id=231,
    payment_details=PaymentDetail(
        total_amount=100,
        service_fee=0,
    ),
    schedule_details=ScheduleDetail(
        end_date="2025-03-20",
        frequency="weekly",
        plan_id=1,
        start_date="2024-09-20",
    ),
)

```

```java UpdateSubscription
package com.example.usage;

import io.github.payabli.api.PayabliPayabliApiOasClient;
import io.github.payabli.api.resources.subscription.requests.RequestUpdateSchedule;
import io.github.payabli.api.types.Frequency;
import io.github.payabli.api.types.PaymentDetail;
import io.github.payabli.api.types.ScheduleDetail;

public class Example {
    public static void main(String[] args) {
        PayabliPayabliApiOasClient client = PayabliPayabliApiOasClient
            .builder()
            .apiKey("YOUR_API_KEY_HERE")
            .build();

        client.subscription().updateSubscription(
            231,
            RequestUpdateSchedule
                .builder()
                .paymentDetails(
                    PaymentDetail
                        .builder()
                        .totalAmount(100.0)
                        .serviceFee(0.0)
                        .build()
                )
                .scheduleDetails(
                    ScheduleDetail
                        .builder()
                        .endDate("2025-03-20")
                        .frequency(Frequency.WEEKLY)
                        .planId(1)
                        .startDate("2024-09-20")
                        .build()
                )
                .build()
        );
    }
}
```

```ruby UpdateSubscription
require "payabli"

client = Payabli::Client.new(api_key: "YOUR_API_KEY_HERE")

client.subscription.update_subscription(
  sub_id: 231,
  payment_details: {
    total_amount: 100,
    service_fee: 0
  },
  schedule_details: {
    end_date: "2025-03-20",
    frequency: "weekly",
    plan_id: 1,
    start_date: "2024-09-20"
  }
)

```

```csharp UpdateSubscription
using PayabliPayabliApiOas;
using System.Threading.Tasks;

namespace Usage;

public class Example
{
    public async Task Do() {
        var client = new PayabliPayabliApiOasClient(
            apiKey: "YOUR_API_KEY_HERE"
        );

        await client.Subscription.UpdateSubscriptionAsync(
            231,
            new RequestUpdateSchedule {
                PaymentDetails = new PaymentDetail {
                    TotalAmount = 100,
                    ServiceFee = 0
                },
                ScheduleDetails = new ScheduleDetail {
                    EndDate = "2025-03-20",
                    Frequency = Frequency.Weekly,
                    PlanId = 1,
                    StartDate = "2024-09-20"
                }
            }
        );
    }

}

```

```go UpdateSubscription
package example

import (
    context "context"

    payabli "github.com/payabli/sdk-go"
    client "github.com/payabli/sdk-go/client"
    option "github.com/payabli/sdk-go/option"
)

func do() {
    client := client.NewClient(
        option.WithApiKey(
            "YOUR_API_KEY_HERE",
        ),
    )
    request := &payabli.RequestUpdateSchedule{
        PaymentDetails: &payabli.PaymentDetail{
            TotalAmount: 100,
            ServiceFee: payabli.Float64(
                0,
            ),
        },
        ScheduleDetails: &payabli.ScheduleDetail{
            EndDate: payabli.String(
                "2025-03-20",
            ),
            Frequency: payabli.FrequencyWeekly.Ptr(),
            PlanId: payabli.Int(
                1,
            ),
            StartDate: payabli.String(
                "2024-09-20",
            ),
        },
    }
    client.Subscription.UpdateSubscription(
        context.TODO(),
        231,
        request,
    )
}

```

```php UpdateSubscription
<?php

namespace Example;

use Payabli\PayabliClient;
use Payabli\Subscription\Requests\RequestUpdateSchedule;
use Payabli\Types\PaymentDetail;
use Payabli\Types\ScheduleDetail;
use Payabli\Types\Frequency;

$client = new PayabliClient(
    apiKey: 'YOUR_API_KEY_HERE',
);
$client->subscription->updateSubscription(
    231,
    new RequestUpdateSchedule([
        'paymentDetails' => new PaymentDetail([
            'totalAmount' => 100,
            'serviceFee' => 0,
        ]),
        'scheduleDetails' => new ScheduleDetail([
            'endDate' => '2025-03-20',
            'frequency' => Frequency::Weekly->value,
            'planId' => 1,
            'startDate' => '2024-09-20',
        ]),
    ]),
);

```

```swift UpdateSubscription
import Foundation

let headers = [
  "requestToken": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "paymentDetails": [
    "totalAmount": 100,
    "serviceFee": 0
  ],
  "scheduleDetails": [
    "endDate": "2025-03-20",
    "frequency": "weekly",
    "planId": 1,
    "startDate": "2024-09-20"
  ]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api-sandbox.payabli.com/api/Subscription/231")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PUT"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

A successful request returns a response that includes the subscription ID (in `responseData`) and customer ID.

### Response (200)

```json
{
  "responseText": "Success",
  "isSuccess": true,
  "responseData": "396 updated",
  "customerId": 4440
}
```

## Delete a subscription

Send a DELETE request to `/api/Subscription/{subscriptionId}` to cancel a subscription and stop future payments. See the [API reference](/developers/api-reference/subscription/remove-a-subscription) for this endpoint for full documentation.

This example deletes the subscription with the ID `396`.

### Request

DELETE [https://api-sandbox.payabli.com/api/Subscription/\{subId}](https://api-sandbox.payabli.com/api/Subscription/\{subId})

```curl
curl -X DELETE https://api-sandbox.payabli.com/api/Subscription/231 \
     -H "requestToken: <apiKey>"
```

```typescript
import { PayabliClient } from "@payabli/sdk-node";

async function main() {
    const client = new PayabliClient({
        apiKey: "YOUR_API_KEY_HERE",
    });
    await client.subscription.removeSubscription(231);
}
main();

```

```python
from payabli import payabli

client = payabli(
    api_key="YOUR_API_KEY_HERE",
)

client.subscription.remove_subscription(
    sub_id=231,
)

```

```java
package com.example.usage;

import io.github.payabli.api.PayabliPayabliApiOasClient;

public class Example {
    public static void main(String[] args) {
        PayabliPayabliApiOasClient client = PayabliPayabliApiOasClient
            .builder()
            .apiKey("YOUR_API_KEY_HERE")
            .build();

        client.subscription().removeSubscription(231);
    }
}
```

```ruby
require "payabli"

client = Payabli::Client.new(api_key: "YOUR_API_KEY_HERE")

client.subscription.remove_subscription(sub_id: 231)

```

```csharp
using PayabliPayabliApiOas;
using System.Threading.Tasks;

namespace Usage;

public class Example
{
    public async Task Do() {
        var client = new PayabliPayabliApiOasClient(
            apiKey: "YOUR_API_KEY_HERE"
        );

        await client.Subscription.RemoveSubscriptionAsync(
            231
        );
    }

}

```

```go
package example

import (
    context "context"

    client "github.com/payabli/sdk-go/client"
    option "github.com/payabli/sdk-go/option"
)

func do() {
    client := client.NewClient(
        option.WithApiKey(
            "YOUR_API_KEY_HERE",
        ),
    )
    client.Subscription.RemoveSubscription(
        context.TODO(),
        231,
    )
}

```

```php
<?php

namespace Example;

use Payabli\PayabliClient;

$client = new PayabliClient(
    apiKey: 'YOUR_API_KEY_HERE',
);
$client->subscription->removeSubscription(
    231,
);

```

```swift
import Foundation

let headers = ["requestToken": "<apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api-sandbox.payabli.com/api/Subscription/231")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "DELETE"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

A successful deletion returns a response that includes the subscription ID (in `responseData`) and customer ID.

### Response (200)

```json
{
  "responseText": "Success",
  "isSuccess": true,
  "responseData": "396"
}
```

## Next steps

Use the [Subscription Utilities](/guides/pay-in-developer-subscriptions-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.

* **[Subscription utility code](/guides/pay-in-developer-subscriptions-utilities)** - Use example code to enhance your subscription management via the API
* **[Create an autopay](/guides/pay-in-portal-autopays-create)** - Schedule automatic recurring charges for customers directly from their record in the Payabli Portal
* **[Manage autopays](/guides/pay-in-portal-autopays-manage)** - View, edit, pause, resume, and cancel scheduled autopays from the Payabli Portal