> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://beta-docs.payabli.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://beta-docs.payabli.com/_mcp/server.

# Manage subscriptions with the API

Subscriptions, also known as recurring transactions, autopays, or scheduled payments, are a powerful way to automate billing and payment collection. With Payabli's API, you can manage these transactions, including creating, updating, and deleting subscriptions.

This guide covers the key operations for managing subscriptions through the API.

## Considerations

When working with subscriptions, keep the following in mind:

* Payabli automatically tokenizes payment information and assigns stored payment methods to the provided customer.
* Subscriptions are always linked to a customer - if no `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](/developer-guides/pay-in-subscription-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.

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

To skip a payment, update the subscription's `totalAmount` to `0`. To resume payments, update `totalAmount` to a non-zero amount. Note that if `totalAmount` is set to `0`, then `serviceFee` must also be set to `0`.

To pause a subscription, send a PUT request to `/api/Subscription/\{subscriptionId\}` with the `setPause` field set to `true`. When you're ready to resume the subscription, send another PUT request with `setPause` set to `false`.

#### Pause Subscription

### Request

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

**`PauseSubscription`**

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

**`PauseSubscription`**

```python PauseSubscription
import requests

url = "https://api-sandbox.payabli.com/api/Subscription/231"

payload = { "setPause": True }
headers = {
    "requestToken": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.put(url, json=payload, headers=headers)

print(response.json())
```

**`PauseSubscription`**

```javascript PauseSubscription
const url = 'https://api-sandbox.payabli.com/api/Subscription/231';
const options = {
  method: 'PUT',
  headers: {requestToken: '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"setPause":true}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

**`PauseSubscription`**

```go PauseSubscription
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api-sandbox.payabli.com/api/Subscription/231"

	payload := strings.NewReader("{\n  \"setPause\": true\n}")

	req, _ := http.NewRequest("PUT", url, payload)

	req.Header.Add("requestToken", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

**`PauseSubscription`**

```ruby PauseSubscription
require 'uri'
require 'net/http'

url = URI("https://api-sandbox.payabli.com/api/Subscription/231")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Put.new(url)
request["requestToken"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"setPause\": true\n}"

response = http.request(request)
puts response.read_body
```

**`PauseSubscription`**

```java PauseSubscription
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.put("https://api-sandbox.payabli.com/api/Subscription/231")
  .header("requestToken", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"setPause\": true\n}")
  .asString();
```

**`PauseSubscription`**

```php PauseSubscription
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'https://api-sandbox.payabli.com/api/Subscription/231', [
  'body' => '{
  "setPause": true
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'requestToken' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

**`PauseSubscription`**

```csharp PauseSubscription
using RestSharp;

var client = new RestClient("https://api-sandbox.payabli.com/api/Subscription/231");
var request = new RestRequest(Method.PUT);
request.AddHeader("requestToken", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"setPause\": true\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

**`PauseSubscription`**

```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()
```

#### Unpause Subscription

### Request

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

**`UnpauseSubscription`**

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

**`UnpauseSubscription`**

```python UnpauseSubscription
import requests

url = "https://api-sandbox.payabli.com/api/Subscription/231"

payload = { "setPause": False }
headers = {
    "requestToken": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.put(url, json=payload, headers=headers)

print(response.json())
```

**`UnpauseSubscription`**

```javascript UnpauseSubscription
const url = 'https://api-sandbox.payabli.com/api/Subscription/231';
const options = {
  method: 'PUT',
  headers: {requestToken: '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"setPause":false}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

**`UnpauseSubscription`**

```go UnpauseSubscription
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api-sandbox.payabli.com/api/Subscription/231"

	payload := strings.NewReader("{\n  \"setPause\": false\n}")

	req, _ := http.NewRequest("PUT", url, payload)

	req.Header.Add("requestToken", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

**`UnpauseSubscription`**

```ruby UnpauseSubscription
require 'uri'
require 'net/http'

url = URI("https://api-sandbox.payabli.com/api/Subscription/231")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Put.new(url)
request["requestToken"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"setPause\": false\n}"

response = http.request(request)
puts response.read_body
```

**`UnpauseSubscription`**

```java UnpauseSubscription
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.put("https://api-sandbox.payabli.com/api/Subscription/231")
  .header("requestToken", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"setPause\": false\n}")
  .asString();
```

**`UnpauseSubscription`**

```php UnpauseSubscription
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'https://api-sandbox.payabli.com/api/Subscription/231', [
  'body' => '{
  "setPause": false
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'requestToken' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

**`UnpauseSubscription`**

```csharp UnpauseSubscription
using RestSharp;

var client = new RestClient("https://api-sandbox.payabli.com/api/Subscription/231");
var request = new RestRequest(Method.PUT);
request.AddHeader("requestToken", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"setPause\": false\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

**`UnpauseSubscription`**

```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](/api-reference/subscription/create-a-subscription-or-scheduled-payment) for this endpoint for full documentation.

#### Card Subscription

### Request

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

**`CardSubscription`**

```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": "f743aed24a",
  "paymentDetails": {
    "totalAmount": 100,
    "serviceFee": 0
  },
  "paymentMethod": {
    "cardcvv": "123",
    "cardexp": "02/25",
    "cardHolder": "John Cassian",
    "cardnumber": "4111111111111111",
    "cardzip": "37615",
    "initiator": "payor",
    "method": "card"
  },
  "scheduleDetails": {
    "endDate": "03-20-2025",
    "frequency": "weekly",
    "planId": 1,
    "startDate": "09-20-2024"
  }
}'
```

**`CardSubscription`**

```python CardSubscription
import requests

url = "https://api-sandbox.payabli.com/api/Subscription/add"

payload = {
    "customerData": { "customerId": 4440 },
    "entryPoint": "f743aed24a",
    "paymentDetails": {
        "totalAmount": 100,
        "serviceFee": 0
    },
    "paymentMethod": {
        "cardcvv": "123",
        "cardexp": "02/25",
        "cardHolder": "John Cassian",
        "cardnumber": "4111111111111111",
        "cardzip": "37615",
        "initiator": "payor",
        "method": "card"
    },
    "scheduleDetails": {
        "endDate": "03-20-2025",
        "frequency": "weekly",
        "planId": 1,
        "startDate": "09-20-2024"
    }
}
headers = {
    "requestToken": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

**`CardSubscription`**

```javascript CardSubscription
const url = 'https://api-sandbox.payabli.com/api/Subscription/add';
const options = {
  method: 'POST',
  headers: {requestToken: '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"customerData":{"customerId":4440},"entryPoint":"f743aed24a","paymentDetails":{"totalAmount":100,"serviceFee":0},"paymentMethod":{"cardcvv":"123","cardexp":"02/25","cardHolder":"John Cassian","cardnumber":"4111111111111111","cardzip":"37615","initiator":"payor","method":"card"},"scheduleDetails":{"endDate":"03-20-2025","frequency":"weekly","planId":1,"startDate":"09-20-2024"}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

**`CardSubscription`**

```go CardSubscription
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api-sandbox.payabli.com/api/Subscription/add"

	payload := strings.NewReader("{\n  \"customerData\": {\n    \"customerId\": 4440\n  },\n  \"entryPoint\": \"f743aed24a\",\n  \"paymentDetails\": {\n    \"totalAmount\": 100,\n    \"serviceFee\": 0\n  },\n  \"paymentMethod\": {\n    \"cardcvv\": \"123\",\n    \"cardexp\": \"02/25\",\n    \"cardHolder\": \"John Cassian\",\n    \"cardnumber\": \"4111111111111111\",\n    \"cardzip\": \"37615\",\n    \"initiator\": \"payor\",\n    \"method\": \"card\"\n  },\n  \"scheduleDetails\": {\n    \"endDate\": \"03-20-2025\",\n    \"frequency\": \"weekly\",\n    \"planId\": 1,\n    \"startDate\": \"09-20-2024\"\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("requestToken", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

**`CardSubscription`**

```ruby CardSubscription
require 'uri'
require 'net/http'

url = URI("https://api-sandbox.payabli.com/api/Subscription/add")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["requestToken"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"customerData\": {\n    \"customerId\": 4440\n  },\n  \"entryPoint\": \"f743aed24a\",\n  \"paymentDetails\": {\n    \"totalAmount\": 100,\n    \"serviceFee\": 0\n  },\n  \"paymentMethod\": {\n    \"cardcvv\": \"123\",\n    \"cardexp\": \"02/25\",\n    \"cardHolder\": \"John Cassian\",\n    \"cardnumber\": \"4111111111111111\",\n    \"cardzip\": \"37615\",\n    \"initiator\": \"payor\",\n    \"method\": \"card\"\n  },\n  \"scheduleDetails\": {\n    \"endDate\": \"03-20-2025\",\n    \"frequency\": \"weekly\",\n    \"planId\": 1,\n    \"startDate\": \"09-20-2024\"\n  }\n}"

response = http.request(request)
puts response.read_body
```

**`CardSubscription`**

```java CardSubscription
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api-sandbox.payabli.com/api/Subscription/add")
  .header("requestToken", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"customerData\": {\n    \"customerId\": 4440\n  },\n  \"entryPoint\": \"f743aed24a\",\n  \"paymentDetails\": {\n    \"totalAmount\": 100,\n    \"serviceFee\": 0\n  },\n  \"paymentMethod\": {\n    \"cardcvv\": \"123\",\n    \"cardexp\": \"02/25\",\n    \"cardHolder\": \"John Cassian\",\n    \"cardnumber\": \"4111111111111111\",\n    \"cardzip\": \"37615\",\n    \"initiator\": \"payor\",\n    \"method\": \"card\"\n  },\n  \"scheduleDetails\": {\n    \"endDate\": \"03-20-2025\",\n    \"frequency\": \"weekly\",\n    \"planId\": 1,\n    \"startDate\": \"09-20-2024\"\n  }\n}")
  .asString();
```

**`CardSubscription`**

```php CardSubscription
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api-sandbox.payabli.com/api/Subscription/add', [
  'body' => '{
  "customerData": {
    "customerId": 4440
  },
  "entryPoint": "f743aed24a",
  "paymentDetails": {
    "totalAmount": 100,
    "serviceFee": 0
  },
  "paymentMethod": {
    "cardcvv": "123",
    "cardexp": "02/25",
    "cardHolder": "John Cassian",
    "cardnumber": "4111111111111111",
    "cardzip": "37615",
    "initiator": "payor",
    "method": "card"
  },
  "scheduleDetails": {
    "endDate": "03-20-2025",
    "frequency": "weekly",
    "planId": 1,
    "startDate": "09-20-2024"
  }
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'requestToken' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

**`CardSubscription`**

```csharp CardSubscription
using RestSharp;

var client = new RestClient("https://api-sandbox.payabli.com/api/Subscription/add");
var request = new RestRequest(Method.POST);
request.AddHeader("requestToken", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"customerData\": {\n    \"customerId\": 4440\n  },\n  \"entryPoint\": \"f743aed24a\",\n  \"paymentDetails\": {\n    \"totalAmount\": 100,\n    \"serviceFee\": 0\n  },\n  \"paymentMethod\": {\n    \"cardcvv\": \"123\",\n    \"cardexp\": \"02/25\",\n    \"cardHolder\": \"John Cassian\",\n    \"cardnumber\": \"4111111111111111\",\n    \"cardzip\": \"37615\",\n    \"initiator\": \"payor\",\n    \"method\": \"card\"\n  },\n  \"scheduleDetails\": {\n    \"endDate\": \"03-20-2025\",\n    \"frequency\": \"weekly\",\n    \"planId\": 1,\n    \"startDate\": \"09-20-2024\"\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

**`CardSubscription`**

```swift CardSubscription
import Foundation

let headers = [
  "requestToken": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "customerData": ["customerId": 4440],
  "entryPoint": "f743aed24a",
  "paymentDetails": [
    "totalAmount": 100,
    "serviceFee": 0
  ],
  "paymentMethod": [
    "cardcvv": "123",
    "cardexp": "02/25",
    "cardHolder": "John Cassian",
    "cardnumber": "4111111111111111",
    "cardzip": "37615",
    "initiator": "payor",
    "method": "card"
  ],
  "scheduleDetails": [
    "endDate": "03-20-2025",
    "frequency": "weekly",
    "planId": 1,
    "startDate": "09-20-2024"
  ]
] 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()
```

#### ACH Subscription

### Request

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

**`ACHSubscription`**

```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": "f743aed24a",
  "paymentDetails": {
    "totalAmount": 100,
    "serviceFee": 0
  },
  "paymentMethod": {
    "achAccount": "3453445666",
    "achAccountType": "Checking",
    "achCode": "PPD",
    "achHolder": "John Cassian",
    "achHolderType": "personal",
    "achRouting": "021000021",
    "method": "ach"
  },
  "scheduleDetails": {
    "endDate": "03-20-2025",
    "frequency": "weekly",
    "planId": 1,
    "startDate": "09-20-2024"
  }
}'
```

**`ACHSubscription`**

```python ACHSubscription
import requests

url = "https://api-sandbox.payabli.com/api/Subscription/add"

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

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

**`ACHSubscription`**

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

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

**`ACHSubscription`**

```go ACHSubscription
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api-sandbox.payabli.com/api/Subscription/add"

	payload := strings.NewReader("{\n  \"customerData\": {\n    \"customerId\": 4440\n  },\n  \"entryPoint\": \"f743aed24a\",\n  \"paymentDetails\": {\n    \"totalAmount\": 100,\n    \"serviceFee\": 0\n  },\n  \"paymentMethod\": {\n    \"achAccount\": \"3453445666\",\n    \"achAccountType\": \"Checking\",\n    \"achCode\": \"PPD\",\n    \"achHolder\": \"John Cassian\",\n    \"achHolderType\": \"personal\",\n    \"achRouting\": \"021000021\",\n    \"method\": \"ach\"\n  },\n  \"scheduleDetails\": {\n    \"endDate\": \"03-20-2025\",\n    \"frequency\": \"weekly\",\n    \"planId\": 1,\n    \"startDate\": \"09-20-2024\"\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("requestToken", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

**`ACHSubscription`**

```ruby ACHSubscription
require 'uri'
require 'net/http'

url = URI("https://api-sandbox.payabli.com/api/Subscription/add")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["requestToken"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"customerData\": {\n    \"customerId\": 4440\n  },\n  \"entryPoint\": \"f743aed24a\",\n  \"paymentDetails\": {\n    \"totalAmount\": 100,\n    \"serviceFee\": 0\n  },\n  \"paymentMethod\": {\n    \"achAccount\": \"3453445666\",\n    \"achAccountType\": \"Checking\",\n    \"achCode\": \"PPD\",\n    \"achHolder\": \"John Cassian\",\n    \"achHolderType\": \"personal\",\n    \"achRouting\": \"021000021\",\n    \"method\": \"ach\"\n  },\n  \"scheduleDetails\": {\n    \"endDate\": \"03-20-2025\",\n    \"frequency\": \"weekly\",\n    \"planId\": 1,\n    \"startDate\": \"09-20-2024\"\n  }\n}"

response = http.request(request)
puts response.read_body
```

**`ACHSubscription`**

```java ACHSubscription
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api-sandbox.payabli.com/api/Subscription/add")
  .header("requestToken", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"customerData\": {\n    \"customerId\": 4440\n  },\n  \"entryPoint\": \"f743aed24a\",\n  \"paymentDetails\": {\n    \"totalAmount\": 100,\n    \"serviceFee\": 0\n  },\n  \"paymentMethod\": {\n    \"achAccount\": \"3453445666\",\n    \"achAccountType\": \"Checking\",\n    \"achCode\": \"PPD\",\n    \"achHolder\": \"John Cassian\",\n    \"achHolderType\": \"personal\",\n    \"achRouting\": \"021000021\",\n    \"method\": \"ach\"\n  },\n  \"scheduleDetails\": {\n    \"endDate\": \"03-20-2025\",\n    \"frequency\": \"weekly\",\n    \"planId\": 1,\n    \"startDate\": \"09-20-2024\"\n  }\n}")
  .asString();
```

**`ACHSubscription`**

```php ACHSubscription
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api-sandbox.payabli.com/api/Subscription/add', [
  'body' => '{
  "customerData": {
    "customerId": 4440
  },
  "entryPoint": "f743aed24a",
  "paymentDetails": {
    "totalAmount": 100,
    "serviceFee": 0
  },
  "paymentMethod": {
    "achAccount": "3453445666",
    "achAccountType": "Checking",
    "achCode": "PPD",
    "achHolder": "John Cassian",
    "achHolderType": "personal",
    "achRouting": "021000021",
    "method": "ach"
  },
  "scheduleDetails": {
    "endDate": "03-20-2025",
    "frequency": "weekly",
    "planId": 1,
    "startDate": "09-20-2024"
  }
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'requestToken' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

**`ACHSubscription`**

```csharp ACHSubscription
using RestSharp;

var client = new RestClient("https://api-sandbox.payabli.com/api/Subscription/add");
var request = new RestRequest(Method.POST);
request.AddHeader("requestToken", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"customerData\": {\n    \"customerId\": 4440\n  },\n  \"entryPoint\": \"f743aed24a\",\n  \"paymentDetails\": {\n    \"totalAmount\": 100,\n    \"serviceFee\": 0\n  },\n  \"paymentMethod\": {\n    \"achAccount\": \"3453445666\",\n    \"achAccountType\": \"Checking\",\n    \"achCode\": \"PPD\",\n    \"achHolder\": \"John Cassian\",\n    \"achHolderType\": \"personal\",\n    \"achRouting\": \"021000021\",\n    \"method\": \"ach\"\n  },\n  \"scheduleDetails\": {\n    \"endDate\": \"03-20-2025\",\n    \"frequency\": \"weekly\",\n    \"planId\": 1,\n    \"startDate\": \"09-20-2024\"\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

**`ACHSubscription`**

```swift ACHSubscription
import Foundation

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

#### Stored Method Subscription

### Request

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

**`StoredMethodSubscription`**

```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": "f743aed24a",
  "paymentDetails": {
    "totalAmount": 100,
    "serviceFee": 0
  },
  "paymentMethod": {
    "initiator": "merchant",
    "storedMethodId": "4000e8c6-3add-4200-8ac2-9b8a4f8b1639-1323",
    "storedMethodUsageType": "recurring"
  },
  "scheduleDetails": {
    "endDate": "03-20-2025",
    "frequency": "weekly",
    "planId": 1,
    "startDate": "09-20-2024"
  }
}'
```

**`StoredMethodSubscription`**

```python StoredMethodSubscription
import requests

url = "https://api-sandbox.payabli.com/api/Subscription/add"

payload = {
    "customerData": { "customerId": 4440 },
    "entryPoint": "f743aed24a",
    "paymentDetails": {
        "totalAmount": 100,
        "serviceFee": 0
    },
    "paymentMethod": {
        "initiator": "merchant",
        "storedMethodId": "4000e8c6-3add-4200-8ac2-9b8a4f8b1639-1323",
        "storedMethodUsageType": "recurring"
    },
    "scheduleDetails": {
        "endDate": "03-20-2025",
        "frequency": "weekly",
        "planId": 1,
        "startDate": "09-20-2024"
    }
}
headers = {
    "requestToken": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

**`StoredMethodSubscription`**

```javascript StoredMethodSubscription
const url = 'https://api-sandbox.payabli.com/api/Subscription/add';
const options = {
  method: 'POST',
  headers: {requestToken: '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"customerData":{"customerId":4440},"entryPoint":"f743aed24a","paymentDetails":{"totalAmount":100,"serviceFee":0},"paymentMethod":{"initiator":"merchant","storedMethodId":"4000e8c6-3add-4200-8ac2-9b8a4f8b1639-1323","storedMethodUsageType":"recurring"},"scheduleDetails":{"endDate":"03-20-2025","frequency":"weekly","planId":1,"startDate":"09-20-2024"}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

**`StoredMethodSubscription`**

```go StoredMethodSubscription
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api-sandbox.payabli.com/api/Subscription/add"

	payload := strings.NewReader("{\n  \"customerData\": {\n    \"customerId\": 4440\n  },\n  \"entryPoint\": \"f743aed24a\",\n  \"paymentDetails\": {\n    \"totalAmount\": 100,\n    \"serviceFee\": 0\n  },\n  \"paymentMethod\": {\n    \"initiator\": \"merchant\",\n    \"storedMethodId\": \"4000e8c6-3add-4200-8ac2-9b8a4f8b1639-1323\",\n    \"storedMethodUsageType\": \"recurring\"\n  },\n  \"scheduleDetails\": {\n    \"endDate\": \"03-20-2025\",\n    \"frequency\": \"weekly\",\n    \"planId\": 1,\n    \"startDate\": \"09-20-2024\"\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("requestToken", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

**`StoredMethodSubscription`**

```ruby StoredMethodSubscription
require 'uri'
require 'net/http'

url = URI("https://api-sandbox.payabli.com/api/Subscription/add")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["requestToken"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"customerData\": {\n    \"customerId\": 4440\n  },\n  \"entryPoint\": \"f743aed24a\",\n  \"paymentDetails\": {\n    \"totalAmount\": 100,\n    \"serviceFee\": 0\n  },\n  \"paymentMethod\": {\n    \"initiator\": \"merchant\",\n    \"storedMethodId\": \"4000e8c6-3add-4200-8ac2-9b8a4f8b1639-1323\",\n    \"storedMethodUsageType\": \"recurring\"\n  },\n  \"scheduleDetails\": {\n    \"endDate\": \"03-20-2025\",\n    \"frequency\": \"weekly\",\n    \"planId\": 1,\n    \"startDate\": \"09-20-2024\"\n  }\n}"

response = http.request(request)
puts response.read_body
```

**`StoredMethodSubscription`**

```java StoredMethodSubscription
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api-sandbox.payabli.com/api/Subscription/add")
  .header("requestToken", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"customerData\": {\n    \"customerId\": 4440\n  },\n  \"entryPoint\": \"f743aed24a\",\n  \"paymentDetails\": {\n    \"totalAmount\": 100,\n    \"serviceFee\": 0\n  },\n  \"paymentMethod\": {\n    \"initiator\": \"merchant\",\n    \"storedMethodId\": \"4000e8c6-3add-4200-8ac2-9b8a4f8b1639-1323\",\n    \"storedMethodUsageType\": \"recurring\"\n  },\n  \"scheduleDetails\": {\n    \"endDate\": \"03-20-2025\",\n    \"frequency\": \"weekly\",\n    \"planId\": 1,\n    \"startDate\": \"09-20-2024\"\n  }\n}")
  .asString();
```

**`StoredMethodSubscription`**

```php StoredMethodSubscription
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api-sandbox.payabli.com/api/Subscription/add', [
  'body' => '{
  "customerData": {
    "customerId": 4440
  },
  "entryPoint": "f743aed24a",
  "paymentDetails": {
    "totalAmount": 100,
    "serviceFee": 0
  },
  "paymentMethod": {
    "initiator": "merchant",
    "storedMethodId": "4000e8c6-3add-4200-8ac2-9b8a4f8b1639-1323",
    "storedMethodUsageType": "recurring"
  },
  "scheduleDetails": {
    "endDate": "03-20-2025",
    "frequency": "weekly",
    "planId": 1,
    "startDate": "09-20-2024"
  }
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'requestToken' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

**`StoredMethodSubscription`**

```csharp StoredMethodSubscription
using RestSharp;

var client = new RestClient("https://api-sandbox.payabli.com/api/Subscription/add");
var request = new RestRequest(Method.POST);
request.AddHeader("requestToken", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"customerData\": {\n    \"customerId\": 4440\n  },\n  \"entryPoint\": \"f743aed24a\",\n  \"paymentDetails\": {\n    \"totalAmount\": 100,\n    \"serviceFee\": 0\n  },\n  \"paymentMethod\": {\n    \"initiator\": \"merchant\",\n    \"storedMethodId\": \"4000e8c6-3add-4200-8ac2-9b8a4f8b1639-1323\",\n    \"storedMethodUsageType\": \"recurring\"\n  },\n  \"scheduleDetails\": {\n    \"endDate\": \"03-20-2025\",\n    \"frequency\": \"weekly\",\n    \"planId\": 1,\n    \"startDate\": \"09-20-2024\"\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

**`StoredMethodSubscription`**

```swift StoredMethodSubscription
import Foundation

let headers = [
  "requestToken": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "customerData": ["customerId": 4440],
  "entryPoint": "f743aed24a",
  "paymentDetails": [
    "totalAmount": 100,
    "serviceFee": 0
  ],
  "paymentMethod": [
    "initiator": "merchant",
    "storedMethodId": "4000e8c6-3add-4200-8ac2-9b8a4f8b1639-1323",
    "storedMethodUsageType": "recurring"
  ],
  "scheduleDetails": [
    "endDate": "03-20-2025",
    "frequency": "weekly",
    "planId": 1,
    "startDate": "09-20-2024"
  ]
] 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
{
  "CustomerId": 4440,
  "isSuccess": true,
  "responseData": "396",
  "responseText": "Success"
}
```

## 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})

**`GetSubscription`**

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

**`GetSubscription`**

```python GetSubscription
import requests

url = "https://api-sandbox.payabli.com/api/Subscription/263"

headers = {"requestToken": "<apiKey>"}

response = requests.get(url, headers=headers)

print(response.json())
```

**`GetSubscription`**

```javascript GetSubscription
const url = 'https://api-sandbox.payabli.com/api/Subscription/263';
const options = {method: 'GET', headers: {requestToken: '<apiKey>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

**`GetSubscription`**

```go GetSubscription
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api-sandbox.payabli.com/api/Subscription/263"

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("requestToken", "<apiKey>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

**`GetSubscription`**

```ruby GetSubscription
require 'uri'
require 'net/http'

url = URI("https://api-sandbox.payabli.com/api/Subscription/263")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["requestToken"] = '<apiKey>'

response = http.request(request)
puts response.read_body
```

**`GetSubscription`**

```java GetSubscription
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://api-sandbox.payabli.com/api/Subscription/263")
  .header("requestToken", "<apiKey>")
  .asString();
```

**`GetSubscription`**

```php GetSubscription
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api-sandbox.payabli.com/api/Subscription/263', [
  'headers' => [
    'requestToken' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

**`GetSubscription`**

```csharp GetSubscription
using RestSharp;

var client = new RestClient("https://api-sandbox.payabli.com/api/Subscription/263");
var request = new RestRequest(Method.GET);
request.AddHeader("requestToken", "<apiKey>");
IRestResponse response = client.Execute(request);
```

**`GetSubscription`**

```swift GetSubscription
import Foundation

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api-sandbox.payabli.com/api/Subscription/263")! 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. See the [API reference](/api-reference/subscription/get-subscription) for a full response example.

### Response (200)

```json
{
  "CreatedAt": "2022-07-01T15:00:01Z",
  "Customer": {
    "AdditionalData": "AdditionalData",
    "BillingAddress1": "1111 West 1st Street",
    "BillingAddress2": "Suite 200",
    "BillingCity": "Miami",
    "BillingCountry": "US",
    "BillingEmail": "example@email.com",
    "BillingPhone": "5555555555",
    "BillingState": "FL",
    "BillingZip": "45567",
    "CompanyName": "Sunshine LLC",
    "CreatedAt": "2022-07-01T15:00:01Z",
    "customerId": 4440,
    "CustomerId": 4440,
    "CustomerNumber": "3456-7645A",
    "customerStatus": 1,
    "FirstName": "John",
    "Identifiers": [
      "\\\"firstname\\\"",
      "\\\"lastname\\\"",
      "\\\"email\\\"",
      "\\\"customId\\\""
    ],
    "LastName": "Doe",
    "ShippingAddress1": "123 Walnut St",
    "ShippingAddress2": "STE 900",
    "ShippingCity": "Johnson City",
    "ShippingCountry": "US",
    "ShippingState": "TN",
    "ShippingZip": "37619"
  },
  "EndDate": "2025-10-19T00:00:00Z",
  "EntrypageId": 0,
  "ExternalPaypointID": "Paypoint-100",
  "FeeAmount": 3,
  "Frequency": "monthly",
  "IdSub": 396,
  "InvoiceData": {
    "AdditionalData": "AdditionalData",
    "attachments": [
      {}
    ],
    "company": "ACME, INC",
    "discount": 10,
    "dutyAmount": 0,
    "firstName": "Chad",
    "freightAmount": 10,
    "frequency": "one-time",
    "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."
  },
  "LastRun": "2025-10-19T00:00:00Z",
  "LastUpdated": "2022-07-01T15:00:01Z",
  "LeftCycles": 15,
  "Method": "card",
  "NetAmount": 3762.87,
  "NextDate": "2025-10-19T00:00:00Z",
  "ParentOrgName": "PropertyManager Pro",
  "PaymentData": {
    "AccountExp": "11/29",
    "accountId": "accountId",
    "AccountType": "visa",
    "AccountZip": "90210",
    "binData": {
      "binCardBrand": "Visa",
      "binCardCategory": "PLATINUM",
      "binCardIssuer": "Bank of Example",
      "binCardIssuerCountry": "United States",
      "binCardIssuerCountryCodeA2": "US",
      "binCardIssuerCountryNumber": 840,
      "binCardType": "Credit",
      "binMatchedLength": 6
    },
    "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": 255,
  "PaypointLegalname": "Sunshine Services, LLC",
  "PlanId": 0,
  "Source": "api",
  "StartDate": "2025-10-19T00:00:00Z",
  "SubEvents": [
    {
      "description": "TransferCreated",
      "eventTime": "2023-07-05T22:31:06Z",
      "extraData": {
        "key": "value"
      },
      "refData": "refData",
      "source": "api"
    }
  ],
  "SubStatus": 1,
  "TotalAmount": 103,
  "TotalCycles": 24,
  "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](/api-reference/subscription/update-subscription) for this endpoint for full documentation.

### Request

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

**`UpdateSubscription`**

```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": "03-20-2025",
    "frequency": "weekly",
    "planId": 1,
    "startDate": "09-20-2024"
  }
}'
```

**`UpdateSubscription`**

```python UpdateSubscription
import requests

url = "https://api-sandbox.payabli.com/api/Subscription/231"

payload = {
    "paymentDetails": {
        "totalAmount": 100,
        "serviceFee": 0
    },
    "scheduleDetails": {
        "endDate": "03-20-2025",
        "frequency": "weekly",
        "planId": 1,
        "startDate": "09-20-2024"
    }
}
headers = {
    "requestToken": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.put(url, json=payload, headers=headers)

print(response.json())
```

**`UpdateSubscription`**

```javascript UpdateSubscription
const url = 'https://api-sandbox.payabli.com/api/Subscription/231';
const options = {
  method: 'PUT',
  headers: {requestToken: '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"paymentDetails":{"totalAmount":100,"serviceFee":0},"scheduleDetails":{"endDate":"03-20-2025","frequency":"weekly","planId":1,"startDate":"09-20-2024"}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

**`UpdateSubscription`**

```go UpdateSubscription
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api-sandbox.payabli.com/api/Subscription/231"

	payload := strings.NewReader("{\n  \"paymentDetails\": {\n    \"totalAmount\": 100,\n    \"serviceFee\": 0\n  },\n  \"scheduleDetails\": {\n    \"endDate\": \"03-20-2025\",\n    \"frequency\": \"weekly\",\n    \"planId\": 1,\n    \"startDate\": \"09-20-2024\"\n  }\n}")

	req, _ := http.NewRequest("PUT", url, payload)

	req.Header.Add("requestToken", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

**`UpdateSubscription`**

```ruby UpdateSubscription
require 'uri'
require 'net/http'

url = URI("https://api-sandbox.payabli.com/api/Subscription/231")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Put.new(url)
request["requestToken"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"paymentDetails\": {\n    \"totalAmount\": 100,\n    \"serviceFee\": 0\n  },\n  \"scheduleDetails\": {\n    \"endDate\": \"03-20-2025\",\n    \"frequency\": \"weekly\",\n    \"planId\": 1,\n    \"startDate\": \"09-20-2024\"\n  }\n}"

response = http.request(request)
puts response.read_body
```

**`UpdateSubscription`**

```java UpdateSubscription
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.put("https://api-sandbox.payabli.com/api/Subscription/231")
  .header("requestToken", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"paymentDetails\": {\n    \"totalAmount\": 100,\n    \"serviceFee\": 0\n  },\n  \"scheduleDetails\": {\n    \"endDate\": \"03-20-2025\",\n    \"frequency\": \"weekly\",\n    \"planId\": 1,\n    \"startDate\": \"09-20-2024\"\n  }\n}")
  .asString();
```

**`UpdateSubscription`**

```php UpdateSubscription
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PUT', 'https://api-sandbox.payabli.com/api/Subscription/231', [
  'body' => '{
  "paymentDetails": {
    "totalAmount": 100,
    "serviceFee": 0
  },
  "scheduleDetails": {
    "endDate": "03-20-2025",
    "frequency": "weekly",
    "planId": 1,
    "startDate": "09-20-2024"
  }
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'requestToken' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

**`UpdateSubscription`**

```csharp UpdateSubscription
using RestSharp;

var client = new RestClient("https://api-sandbox.payabli.com/api/Subscription/231");
var request = new RestRequest(Method.PUT);
request.AddHeader("requestToken", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"paymentDetails\": {\n    \"totalAmount\": 100,\n    \"serviceFee\": 0\n  },\n  \"scheduleDetails\": {\n    \"endDate\": \"03-20-2025\",\n    \"frequency\": \"weekly\",\n    \"planId\": 1,\n    \"startDate\": \"09-20-2024\"\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

**`UpdateSubscription`**

```swift UpdateSubscription
import Foundation

let headers = [
  "requestToken": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "paymentDetails": [
    "totalAmount": 100,
    "serviceFee": 0
  ],
  "scheduleDetails": [
    "endDate": "03-20-2025",
    "frequency": "weekly",
    "planId": 1,
    "startDate": "09-20-2024"
  ]
] 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
{
  "isSuccess": true,
  "responseData": "396 updated",
  "responseText": "Success"
}
```

## Delete a subscription

Send a DELETE request to `/api/Subscription/{subscriptionId}` to cancel a subscription and stop future payments. See the [API reference](/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})

**`DeleteSubscription`**

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

**`DeleteSubscription`**

```python DeleteSubscription
import requests

url = "https://api-sandbox.payabli.com/api/Subscription/396"

headers = {"requestToken": "<apiKey>"}

response = requests.delete(url, headers=headers)

print(response.json())
```

**`DeleteSubscription`**

```javascript DeleteSubscription
const url = 'https://api-sandbox.payabli.com/api/Subscription/396';
const options = {method: 'DELETE', headers: {requestToken: '<apiKey>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

**`DeleteSubscription`**

```go DeleteSubscription
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api-sandbox.payabli.com/api/Subscription/396"

	req, _ := http.NewRequest("DELETE", url, nil)

	req.Header.Add("requestToken", "<apiKey>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

**`DeleteSubscription`**

```ruby DeleteSubscription
require 'uri'
require 'net/http'

url = URI("https://api-sandbox.payabli.com/api/Subscription/396")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Delete.new(url)
request["requestToken"] = '<apiKey>'

response = http.request(request)
puts response.read_body
```

**`DeleteSubscription`**

```java DeleteSubscription
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.delete("https://api-sandbox.payabli.com/api/Subscription/396")
  .header("requestToken", "<apiKey>")
  .asString();
```

**`DeleteSubscription`**

```php DeleteSubscription
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('DELETE', 'https://api-sandbox.payabli.com/api/Subscription/396', [
  'headers' => [
    'requestToken' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

**`DeleteSubscription`**

```csharp DeleteSubscription
using RestSharp;

var client = new RestClient("https://api-sandbox.payabli.com/api/Subscription/396");
var request = new RestRequest(Method.DELETE);
request.AddHeader("requestToken", "<apiKey>");
IRestResponse response = client.Execute(request);
```

**`DeleteSubscription`**

```swift DeleteSubscription
import Foundation

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api-sandbox.payabli.com/api/Subscription/396")! 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
{
  "isSuccess": true,
  "responseData": "396",
  "responseText": "Success"
}
```

## Next steps

Use the [Subscription Utilities](/developer-guides/pay-in-subscription-utilities) to manage your subscriptions. These utilities provide additional functionality, such as retrying failed payments and managing autopay transactions.