> 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

# Create subscription

POST https://api-sandbox.payabli.com/api/Subscription/add
Content-Type: application/json

Creates a subscription or scheduled payment to run at a specified time and frequency. You can use stored payment method tokens for card, ACH, and digital wallets by passing them into the `paymentMethod.storedMethodId` field.

Reference: https://docs.payabli.com/developers/api-reference/subscription/create-a-subscription-or-scheduled-payment

## Authentication

- `Authorization` header (bearer token, required)
- `requestToken` header (required) — Long-lived API token sent in the `requestToken` header. See [API token authentication](/developers/api-tokens).

## Servers

- `https://api-sandbox.payabli.com/api` (Sandbox, default)
- `https://api.payabli.com/api` (Production)

## Request

### Query parameters

- `forceCustomerCreation` (boolean, optional) — When `true`, the request creates a new customer record, regardless of whether customer identifiers match an existing customer. Defaults to `false`.

### Headers

- `idempotencyKey` (string, optional) — _Optional but recommended_ A unique ID that you can include to prevent duplicating objects or transactions in the case that a request is sent more than once. This key isn't generated in Payabli, you must generate it yourself. This key persists for 2 minutes. After 2 minutes, you can reuse the key if needed.

### Body (application/json)

- `customerData` (object, optional) — Object describing the customer/payor.
  - `additionalData` (map from string to map from string to any, optional) — Custom dictionary of key:value pairs. You can use this field to store any data related to the object or for your system. If you are using [custom identifiers](/developers/developer-guides/entities-customers), pass those in this object. Max length for a value is 100 characters. Example usage: ```json { "additionalData": { "key1": "value1", "key2": "value2", "key3": "value3" } } ```
  - `billingAddress1` (string, optional) — Billing address.
  - `billingAddress2` (string, optional) — Additional line for the billing address.
  - `billingCity` (string, optional) — Billing city.
  - `billingCountry` (string, optional) — Billing address country.
  - `billingEmail` (string, optional) — Email address.
  - `billingPhone` (string, optional) — Phone number.
  - `billingState` (string, optional) — Billing state. Must be a 2-letter state code for addresses in the US.
  - `billingZip` (string, optional) — Customer's billing ZIP code. For Pay In functions, this field supports 5-digit and 9-digit ZIP codes and alphanumeric Canadian postal codes. For example: "37615-1234" or "37615".
  - `company` (string, optional) — Customer's company name.
  - `customerId` (long, optional) — The Payabli-generated unique ID for the customer.
  - `customerNumber` (string, optional) — User-provided unique identifier for the customer. This is typically the customer ID from your own system.
  - `firstName` (string, optional) — Customer/Payor first name.
  - `identifierFields` (list of string, optional) — List of fields acting as customer identifiers, to be used instead of CustomerNumber.
  - `lastName` (string, optional) — Customer/Payor last name.
  - `shippingAddress1` (string, optional) — The shipping address.
  - `shippingAddress2` (string, optional) — Additional line for shipping address.
  - `shippingCity` (string, optional) — Shipping city.
  - `shippingCountry` (string, optional) — Shipping address country.
  - `shippingState` (string, optional) — Shipping state or province.
  - `shippingZip` (string, optional) — Shipping ZIP code. For Pay In functions, this field supports 5-digit and 9-digit ZIP codes and alphanumeric Canadian postal codes. For example: `37615-1234` or `37615`.
- `entryPoint` (string, optional) — The entrypoint identifier.
- `invoiceData` (object, optional) — Object describing an Invoice linked to the subscription.
  - `AdditionalData` (map from string to string, optional) — Custom dictionary of key:value pairs. You can use this field to store any data related to the object or for your system. If you are using [custom identifiers](/developers/developer-guides/entities-customers), pass those in this object. Max length for a value is 100 characters. ```json { "additionalData": { "key1": "value1", "key2": "value2", "key3": "value3" } } ```
  - `attachments` (list of object, optional) — Array of `fileContent` objects with attached documents. Max upload size is 30 MB.
    - `fContent` (string, optional) — Content of file, Base64-encoded. Ignored if `furl` is specified. Max upload size is 30 MB.
    - `filename` (string, optional) — The name of the attached file.
    - `ftype` (enum, optional) — The MIME type of the file (if content is provided).
      - Allowed values: `pdf`, `doc`, `docx`, `jpg`, `jpeg`, `png`, `gif`, `txt`
    - `furl` (string, optional) — Optional URL provided to show or download the file remotely.
  - `company` (string, optional) — Company name of the recipient of the invoice.
  - `discount` (double, optional) — Discount applied to the invoice.
  - `dutyAmount` (double, optional) — Duty amount.
  - `firstName` (string, optional) — First name of the recipient of the invoice.
  - `freightAmount` (double, optional) — Freight/shipping amount.
  - `frequency` (enum, optional) — Frequency of scheduled invoice.
    - Allowed values: `onetime`, `weekly`, `every2weeks`, `every6months`, `monthly`, `every3months`, `annually`, `firstofmonth`, `fifteenthofmonth`, `endofmonth`
  - `invoiceAmount` (double, optional) — The invoice amount.
  - `invoiceDate` (date, optional) — Invoice date in any of the accepted formats: YYYY-MM-DD, MM/DD/YYYY.
  - `invoiceDueDate` (date, optional) — Invoice due date in one of the accepted formats: YYYY-MM-DD, MM/DD/YYYY.
  - `invoiceEndDate` (date, optional) — Indicate the date to finish a scheduled invoice cycle (`invoiceType`` = 1) in any of the accepted formats: YYYY-MM-DD, MM/DD/YYYY.
  - `invoiceNumber` (string, optional) — Invoice number. Identifies the invoice under a paypoint.
  - `invoiceStatus` (integer, optional) — Invoice status code.
  - `invoiceType` (integer, optional) — Invoice type. Value `0` is for single/one-time invoices, `1` for scheduled invoices.
  - `items` (list of object, optional) — Array of line items included in the invoice.
    - `itemCategories` (list of string, optional) — Array of tags classifying item or product.
    - `itemCommodityCode` (string, optional) — Item or product commodity code. Max length of 250 characters.
    - `itemCost` (double, optional) — Item or product price per unit.
    - `itemDescription` (string, optional) — Item or product description. Max length of 250 characters.
    - `itemMode` (integer, optional) — Internal class of item or product: value `0` is only for invoices, `1` for bills, and `2` is common for both. Required on invoice line items — invoice creation fails with `Invalid item data` if it's omitted.
    - `itemProductCode` (string, optional) — Item or product code. Max length of 250 characters.
    - `itemProductName` (string, optional) — Item or product name. Max length of 250 characters.
    - `itemQty` (integer, optional) — Quantity of item or product.
    - `itemTaxAmount` (double, optional) — Tax amount applied to item or product.
    - `itemTaxRate` (double, optional) — Tax rate applied to item or product.
    - `itemTotalAmount` (double, optional) — Per-line total for this item (unit cost times quantity). Distinct from the invoice's overall total, `invoiceAmount`. Required on invoice line items.
    - `itemUnitOfMeasure` (string, optional) — Unit of measurement. Max length of 100 characters.
  - `lastName` (string, optional) — Last name of the recipient of the invoice.
  - `notes` (string, optional) — Notes included in the invoice.
  - `paymentTerms` (enum, optional) — Payment terms for invoice. If no terms are defined, then response data for this field defaults to `NET30`. Mirrors the values in [`Terms`](#schema-terms).
    - Allowed values: `PIA`, `CIA`, `UR`, `NET10`, `NET20`, `NET30`, `NET45`, `NET60`, `NET90`, `EOM`, `MFI`, `5MFI`, `10MFI`, `15MFI`, `20MFI`, `2/10NET30`, `UF`, `10UF`, `20UF`, `25UF`, `50UF`
  - `purchaseOrder` (string, optional) — Purchase order number.
  - `shippingAddress1` (string, optional) — The shipping address.
  - `shippingAddress2` (string, optional) — Additional line for shipping address.
  - `shippingCity` (string, optional) — Shipping city.
  - `shippingCountry` (string, optional) — Shipping address country.
  - `shippingEmail` (string, optional) — Shipping recipient's contact email address.
  - `shippingFromZip` (string, optional) — Sender shipping ZIP code.
  - `shippingPhone` (string, optional) — Recipient phone number.
  - `shippingState` (string, optional) — Shipping state or province.
  - `shippingZip` (string, optional) — Shipping ZIP code. For Pay In functions, this field supports 5-digit and 9-digit ZIP codes and alphanumeric Canadian postal codes. For example: `37615-1234` or `37615`.
  - `summaryCommodityCode` (string, optional) — Commodity code.
  - `tax` (double, optional) — Tax rate in percent applied to the invoice.
  - `termsConditions` (string, optional) — Custom terms and conditions included in the invoice.
- `paymentDetails` (object, optional) — Object describing details of the payment. For Regular subscriptions, skip a payment by setting `totalAmount` to 0; payments pause until you update it to a non-zero value, and `serviceFee` must also be 0 when `totalAmount` is 0. For BalanceDriven subscriptions, any `totalAmount` you send is accepted but ignored at run time. Each run charges the payor's live balance, and a zero balance is skipped.
  - `totalAmount` (double, required) — Total amount to be charged. If a service fee is sent, then this amount should include the service fee."
  - `categories` (list of object, optional) — Array of payment categories/line items describing the amount to be paid. **Note**: These categories are for information only and aren't validated against the total amount provided.
    - `amount` (double, required) — Price/cost per unit of item or category.
    - `label` (string, required) — Name of item or category.
    - `description` (string, optional) — Description of item or category
    - `qty` (integer, optional, default: 1) — Quantity of item or category
  - `checkImage` (map from string to any, optional) — Object containing image of paper check.
  - `checkNumber` (string, optional) — A check number to be used in the ach transaction. **Required** for payment method = 'check'.
  - `currency` (string, optional) — The currency for the transaction, `USD` or `CAD`. If your paypoint is configured for CAD, you must send the `CAD` value in this field, otherwise it defaults to USD, which will cause the transaction to fail.
  - `serviceFee` (double, optional) — Service fee to be deducted from the total amount. This amount must be a number, percentages aren't accepted. If you are using a percentage-based fee schedule, you must calculate the value manually.
  - `splitFunding` (list of object, optional) — Split funding instructions for the transaction. See [Split a Transaction](/guides/pay-in-developer-routing-split-funds) for more.
    - `accountId` (string, optional) — The accountId for the account the split should be sent to.
    - `amount` (double, optional) — Amount from the transaction to send to this recipient.
    - `description` (string, optional) — A description for the split.
    - `recipientEntryPoint` (string, optional) — The entrypoint the split should be sent to.
  - `checkUniqueId` (string, optional) — Unique identifier for a processed check image. Required for RDC (Remote Deposit Capture) transactions where `achCode` is `BOC`. Use the `id` value from the [check processing](/developers/api-reference/moneyin/check-capture) response.
- `paymentMethod` (object or object or object, optional) — Information about the payment method for the transaction. Required and recommended fields for each payment method type are described in each schema below.
  - PayMethodCredit
    - `cardexp` (string, required) — Card expiration date in format MMYY or MM/YY. Required for card transactions.
    - `cardnumber` (string, required) — The card number. Required when method is `card` and a `storedMethodId` isn't included.
    - `method` ("card", required) — Method to use for the transaction. For transactions with a credit or debit card, or a tokenized card, use `card`.
    - `cardcvv` (string, optional) — Card Verification Value (CVV) associated with the card number. We **strongly recommend** that you include this field when using `card` as a method.
    - `cardHolder` (string, optional) — Cardholder name.
    - `cardzip` (string, optional) — ZIP or postal code for the billing address of cardholder. We **strongly recommend** that you include this field when using `card` as a method.
    - `initiator` (string, optional) — The transaction's initiator. Indicates who initiated the transaction.
    - `saveIfSuccess` (boolean, optional) — When `true`, Payabli saves the payment method if the transaction is successful. The payment method ID is returned in the response as `methodReferenceId`. Defaults to `false`.
  - PayMethodACH
    - `achAccount` (string, required) — Bank account number. This field is **required** when method = 'ach'.
    - `achHolder` (string, required) — Bank account holder. This field is **required** when `method` is `ach` or `check`.
    - `achRouting` (string, required) — ABA/routing number of bank account. This field is **required** when method = 'ach'.
    - `method` ("ach", required)
    - `achAccountType` (enum, optional) — Bank account type. This field is **required** when method = 'ach'.
      - Allowed values: `Checking`, `Savings`
    - `achCode` (string, optional) — Standard Entry Class (SEC) code is a three letter code that describes how an ACH payment was authorized. Supported values are: - **PPD** (Prearranged Payment and Deposit) — Used for credits or debits where an accountholder authorizes a company to initiate either a single or recurring transaction to their personal bank account. Common examples include direct deposit of payroll, mortgage payments, or utility bills. This is the default value for subscription payments. - **WEB** (Internet-Initiated/Mobile Entry) — Used for debit entries when authorization is obtained from an accountholder via the internet or a wireless network. Common examples are online bill payments, ecommerce purchases, and mobile app payments where the consumer enters their banking information online. - **TEL** (Telephone-Initiated Entry) — Used for one-time debit entries where authorization is obtained from a consumer via telephone. Common examples are phone-based purchases or bill payments where the consumer provides their banking information over the phone. - **CCD** (Corporate Credit or Debit) — Used for fund transfers between business accounts. This code is specifically for business-to-business transactions. Common examples include vendor payments and other business-to-business payments. - **BOC** (Back Office Conversion) — Used to convert paper checks received in-person at a point-of-sale or staffed payment location into electronic ACH debits. Required for Remote Deposit Capture (RDC) transactions. Only supports consumer checks; business, government, and mailed checks aren't eligible.
    - `achHolderType` (enum, optional, default: personal) — The bank's accountholder type: personal or business.
      - Allowed values: `personal`, `business`
    - `device` (string, optional) — Identifier of the registered device used in the transaction.
  - RequestSchedulePaymentMethodInitiator
    - `initiator` (string, optional) — The transaction's initiator. Indicates who initiated the transaction.
    - `storedMethodId` (string, optional) — Payabli identifier of a tokenized payment method.
    - `storedMethodUsageType` (string, optional) — **Strongly recommended.** The usage type for the stored method, used for merchant-initiated transactions (MIT). If you don't specify a value, Payabli defaults to `unscheduled`. Available values: - `unscheduled`: One-time or otherwise not pre-scheduled. - `subscription`: Subscription payments. For example, monthly rental fees or ongoing service subscriptions. - `recurring`: Recurring payments per a set plan. For example, splitting an HOA special assessment over 6 monthly payments. See [Understanding CIT and MIT Indicators](/guides/pay-in-transactions-cit-mit-overview) for more information.
- `scheduleDetails` (object, optional) — Object describing the schedule for subscription.
  - `endDate` (string, optional) — Subscription end date in any of the accepted formats: YYYY-MM-DD, MM/DD/YYYY or the value `untilcancelled` to indicate a scheduled payment with infinite cycle. Not applicable for `BalanceDriven` subscriptions, which run until cancelled.
  - `frequency` (enum, optional) — Frequency of the subscription. `BalanceDriven` subscriptions only accept the monthly cadences `firstofmonth`, `fifteenthofmonth`, and `endofmonth`.
    - Allowed values: `onetime`, `weekly`, `every2weeks`, `every6months`, `monthly`, `every3months`, `annually`, `firstofmonth`, `fifteenthofmonth`, `endofmonth`
  - `planId` (integer, optional) — This field is for future development, leave null. Identifier of subscription plan applied in the scheduled payment/subscription.
  - `startDate` (string, optional) — Subscription start date in any of the accepted formats: YYYY-MM-DD, MM/DD/YYYY. This must be a future date. Not applicable for `BalanceDriven` subscriptions, where the start date is calculated automatically from `frequency`.
- `setPause` (boolean, optional) — Flag indicating if subscription is paused. When a subscription is paused, no payments are processed until the subscription is unpaused, and the next payment date isn't calculated automatically. If you want to skip a payment instead, set the `totalAmount` to 0 in the `paymentDetails` object.
- `source` (string, optional) — Custom identifier to indicate the transaction or request source.
- `subdomain` (string, optional) — Refers to the payment page identifier. If provided, then the transaction is linked to the payment page.
- `subscriptionType` (enum, optional) — Subscription type. Defaults to `Regular` when omitted. Can't be changed after the subscription is created. If you send it to the update endpoint, it's ignored.
  - Allowed values: `Regular`, `BalanceDriven`

## Response

### 200

Success

- `responseText` (string, required) — Response text for operation: 'Success' or 'Declined'.
- `responseData` (integer, required) — The identifier of the newly created subscription.
- `customerId` (long, optional) — The Payabli-generated unique ID for the customer.
- `isSuccess` (boolean, optional) — Boolean indicating whether the operation was successful. A `true` value indicates success. A `false` value indicates failure.

## Examples

### CardSubscription

**Request**

```json
{
  "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"
  }
}
```

**Response**

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

**SDK Code**

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

async function main() {
    const client = new PayabliClient({
        clientId: "YOUR_CLIENT_ID",
        clientSecret: "YOUR_CLIENT_SECRET",
    });
    await client.subscription.newSubscription({
        customerData: {
            customerId: 4440,
        },
        entryPoint: "8cfec329267",
        paymentDetails: {
            serviceFee: 0,
            totalAmount: 100,
        },
        paymentMethod: {
            cardcvv: "123",
            cardexp: "12/29",
            cardHolder: "John Cassian",
            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(
    client_id="YOUR_CLIENT_ID",
    client_secret="YOUR_CLIENT_SECRET",
)

client.subscription.new_subscription(
    customer_data=PayorDataRequest(
        customer_id=4440,
    ),
    entry_point="8cfec329267",
    payment_details=PaymentDetail(
        service_fee=0,
        total_amount=100,
    ),
    payment_method=PayMethodCredit(
        cardcvv="123",
        cardexp="12/29",
        card_holder="John Cassian",
        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.PayabliApiClient;
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) {
        PayabliApiClient client = PayabliApiClient.withCredentials("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET")
            .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 PayabliApi;
using System.Threading.Tasks;

public partial class Examples
{
    public async Task Example() {
        var client = new PayabliApiClient(
            clientId: "YOUR_CLIENT_ID",
            clientSecret: "YOUR_CLIENT_SECRET"
        );

        await client.Subscription.NewSubscriptionAsync(
            new RequestSchedule {
                CustomerData = new PayorDataRequest {
                    CustomerId = 4440L
                },
                EntryPoint = "8cfec329267",
                PaymentDetails = new PaymentDetail {
                    ServiceFee = 0,
                    TotalAmount = 100
                },
                PaymentMethod = new PayMethodCredit {
                    Cardcvv = "123",
                    Cardexp = "12/29",
                    CardHolder = "John Cassian",
                    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.WithClientCredentials(
            "YOUR_CLIENT_ID",
            "YOUR_CLIENT_SECRET",
        ),
    )
    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(
    clientId: 'YOUR_CLIENT_ID',
    clientSecret: 'YOUR_CLIENT_SECRET',
);
$client->subscription->newSubscription(
    new RequestSchedule([
        'customerData' => new PayorDataRequest([
            'customerId' => 4440,
        ]),
        'entryPoint' => '8cfec329267',
        'paymentDetails' => new PaymentDetail([
            'serviceFee' => 0,
            'totalAmount' => 100,
        ]),
        'paymentMethod' => new PayMethodCredit([
            'cardcvv' => '123',
            'cardexp' => '12/29',
            'cardHolder' => 'John Cassian',
            '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 = [
  "Authorization": "Bearer <token>",
  "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()
```

### ACHSubscription

**Request**

```json
{
  "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"
  }
}
```

**Response**

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

**SDK Code**

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

async function main() {
    const client = new PayabliClient({
        clientId: "YOUR_CLIENT_ID",
        clientSecret: "YOUR_CLIENT_SECRET",
    });
    await client.subscription.newSubscription({
        customerData: {
            customerId: 4440,
        },
        entryPoint: "8cfec329267",
        paymentDetails: {
            serviceFee: 0,
            totalAmount: 100,
        },
        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(
    client_id="YOUR_CLIENT_ID",
    client_secret="YOUR_CLIENT_SECRET",
)

client.subscription.new_subscription(
    customer_data=PayorDataRequest(
        customer_id=4440,
    ),
    entry_point="8cfec329267",
    payment_details=PaymentDetail(
        service_fee=0,
        total_amount=100,
    ),
    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.PayabliApiClient;
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) {
        PayabliApiClient client = PayabliApiClient.withCredentials("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET")
            .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: {
    achAccount: "3453445666",
    achAccountType: "Checking",
    achCode: "PPD",
    achHolder: "John Cassian",
    achHolderType: "personal",
    achRouting: "021000021",
    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 PayabliApi;
using System.Threading.Tasks;

public partial class Examples
{
    public async Task Example() {
        var client = new PayabliApiClient(
            clientId: "YOUR_CLIENT_ID",
            clientSecret: "YOUR_CLIENT_SECRET"
        );

        await client.Subscription.NewSubscriptionAsync(
            new RequestSchedule {
                CustomerData = new PayorDataRequest {
                    CustomerId = 4440L
                },
                EntryPoint = "8cfec329267",
                PaymentDetails = new PaymentDetail {
                    ServiceFee = 0,
                    TotalAmount = 100
                },
                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.WithClientCredentials(
            "YOUR_CLIENT_ID",
            "YOUR_CLIENT_SECRET",
        ),
    )
    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(
    clientId: 'YOUR_CLIENT_ID',
    clientSecret: 'YOUR_CLIENT_SECRET',
);
$client->subscription->newSubscription(
    new RequestSchedule([
        'customerData' => new PayorDataRequest([
            'customerId' => 4440,
        ]),
        'entryPoint' => '8cfec329267',
        'paymentDetails' => new PaymentDetail([
            'serviceFee' => 0,
            'totalAmount' => 100,
        ]),
        '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 = [
  "Authorization": "Bearer <token>",
  "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()
```

### StoredMethodSubscription

**Request**

```json
{
  "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"
  }
}
```

**Response**

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

**SDK Code**

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

async function main() {
    const client = new PayabliClient({
        clientId: "YOUR_CLIENT_ID",
        clientSecret: "YOUR_CLIENT_SECRET",
    });
    await client.subscription.newSubscription({
        customerData: {
            customerId: 4440,
        },
        entryPoint: "8cfec329267",
        paymentDetails: {
            serviceFee: 0,
            totalAmount: 100,
        },
        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(
    client_id="YOUR_CLIENT_ID",
    client_secret="YOUR_CLIENT_SECRET",
)

client.subscription.new_subscription(
    customer_data=PayorDataRequest(
        customer_id=4440,
    ),
    entry_point="8cfec329267",
    payment_details=PaymentDetail(
        service_fee=0,
        total_amount=100,
    ),
    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.PayabliApiClient;
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) {
        PayabliApiClient client = PayabliApiClient.withCredentials("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET")
            .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",
    storedMethodId: "1ec55af9-7b5a-4ff0-81ed-c12d2f95e135-4440",
    storedMethodUsageType: "recurring",
    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 PayabliApi;
using System.Threading.Tasks;

public partial class Examples
{
    public async Task Example() {
        var client = new PayabliApiClient(
            clientId: "YOUR_CLIENT_ID",
            clientSecret: "YOUR_CLIENT_SECRET"
        );

        await client.Subscription.NewSubscriptionAsync(
            new RequestSchedule {
                CustomerData = new PayorDataRequest {
                    CustomerId = 4440L
                },
                EntryPoint = "8cfec329267",
                PaymentDetails = new PaymentDetail {
                    ServiceFee = 0,
                    TotalAmount = 100
                },
                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.WithClientCredentials(
            "YOUR_CLIENT_ID",
            "YOUR_CLIENT_SECRET",
        ),
    )
    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(
    clientId: 'YOUR_CLIENT_ID',
    clientSecret: 'YOUR_CLIENT_SECRET',
);
$client->subscription->newSubscription(
    new RequestSchedule([
        'customerData' => new PayorDataRequest([
            'customerId' => 4440,
        ]),
        'entryPoint' => '8cfec329267',
        'paymentDetails' => new PaymentDetail([
            'serviceFee' => 0,
            'totalAmount' => 100,
        ]),
        '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 = [
  "Authorization": "Bearer <token>",
  "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()
```

### BalanceDrivenSubscription

**Request**

```json
{
  "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"
}
```

**Response**

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

**SDK Code**

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

async function main() {
    const client = new PayabliClient({
        clientId: "YOUR_CLIENT_ID",
        clientSecret: "YOUR_CLIENT_SECRET",
    });
    await client.subscription.newSubscription({
        customerData: {
            customerId: 4440,
        },
        entryPoint: "8cfec329267",
        paymentDetails: {
            serviceFee: 0,
            totalAmount: 100,
        },
        paymentMethod: {
            cardcvv: "123",
            cardexp: "12/29",
            cardHolder: "John Cassian",
            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(
    client_id="YOUR_CLIENT_ID",
    client_secret="YOUR_CLIENT_SECRET",
)

client.subscription.new_subscription(
    customer_data=PayorDataRequest(
        customer_id=4440,
    ),
    entry_point="8cfec329267",
    payment_details=PaymentDetail(
        service_fee=0,
        total_amount=100,
    ),
    payment_method=PayMethodCredit(
        cardcvv="123",
        cardexp="12/29",
        card_holder="John Cassian",
        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.PayabliApiClient;
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) {
        PayabliApiClient client = PayabliApiClient.withCredentials("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET")
            .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 PayabliApi;
using System.Threading.Tasks;

public partial class Examples
{
    public async Task Example() {
        var client = new PayabliApiClient(
            clientId: "YOUR_CLIENT_ID",
            clientSecret: "YOUR_CLIENT_SECRET"
        );

        await client.Subscription.NewSubscriptionAsync(
            new RequestSchedule {
                CustomerData = new PayorDataRequest {
                    CustomerId = 4440L
                },
                EntryPoint = "8cfec329267",
                PaymentDetails = new PaymentDetail {
                    ServiceFee = 0,
                    TotalAmount = 100
                },
                PaymentMethod = new PayMethodCredit {
                    Cardcvv = "123",
                    Cardexp = "12/29",
                    CardHolder = "John Cassian",
                    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.WithClientCredentials(
            "YOUR_CLIENT_ID",
            "YOUR_CLIENT_SECRET",
        ),
    )
    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(
    clientId: 'YOUR_CLIENT_ID',
    clientSecret: 'YOUR_CLIENT_SECRET',
);
$client->subscription->newSubscription(
    new RequestSchedule([
        'customerData' => new PayorDataRequest([
            'customerId' => 4440,
        ]),
        'entryPoint' => '8cfec329267',
        'paymentDetails' => new PaymentDetail([
            'serviceFee' => 0,
            'totalAmount' => 100,
        ]),
        'paymentMethod' => new PayMethodCredit([
            'cardcvv' => '123',
            'cardexp' => '12/29',
            'cardHolder' => 'John Cassian',
            '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 = [
  "Authorization": "Bearer <token>",
  "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()
```