> For the complete documentation index, see [llms.txt](https://docs.8pay.network/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.8pay.network/api/variable-recurring/subscriptions.md).

# Subscriptions

Subscriptions allow you to charge customers on a recurring basis. Customers can subscribe through 8Pay’s hosted checkout pages that can be reached by embedded buttons, short urls and QR codes.

Subscriptions can be in three different statuses:

* **`ACTIVE`**: a cycle is in progress, no payment is due
* **`EXPIRED`**: the latest cycle is over and billing can be triggered
* **`CANCELLATION_REQUESTED`**: user has requested cancellation and he’s waiting for vendor’s action
* **`CANCELLED`**: the subscription was cancelled by the user
* **`TERMINATED`**: the subscription was terminated by the vendor

## Get a list of subscriptions

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/variable-recurring/subscriptions`

#### Path Parameters

| Name  | Type   | Description                                 |
| ----- | ------ | ------------------------------------------- |
| chain | string | [chain identifier](/api/overview.md#chains) |

#### Query Parameters

| Name   | Type   | Description                                                                                   |
| ------ | ------ | --------------------------------------------------------------------------------------------- |
| user   | string | filter by user                                                                                |
| status | string | filter by status (`ACTIVE`, `EXPIRED`, `CANCELLATION_REQUESTED`, `CANCELLED` or `TERMINATED`) |
| from   | number | filter by `subscribedAt` (default 0)                                                          |
| to     | number | filter by `subscribedAt` (default current timestamp)                                          |
| sortBy | string | order by `subscribedAt`, `cycleStart` or `cycleEnd` (default `subscribedAt`)                  |
| sort   | string | `asc` or `desc` (default `desc`), sort based on `sortBy` query parameter                      |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

{% tabs %}
{% tab title="200 " %}

```
{
    "data": [
        {
            "id": "0xe63ba761797e289076f80a7c0916a31740684806aaf507da85f81ee785fec6ba",
            "user": "0x16F37b6c96C7038f3E4CDd7aAF9c9A8EC49c4EE7",
            "planId": "0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7",
            "status": "ACTIVE",
            "subscribedAt": 1571646052,
            "cycleStart": 1571646052,
            "cycleEnd": 1574238052,
            "transactionHash": "0xbb97a142aed61a7027b0a030f3c0ab7e1b39bb776201752829d96d562ed49782",
            "transactionStatus": "confirmed"
        }
    ],
    "limit": 100,
    "offset": 0,
    "total": 1
}
```

{% endtab %}
{% endtabs %}

## Get subscriptions of a plan

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/variable-recurring/plans/:planId/subscriptions`

#### Path Parameters

| Name   | Type   | Description                                 |
| ------ | ------ | ------------------------------------------- |
| planId | string | ID of the plan                              |
| chain  | string | [chain identifier](/api/overview.md#chains) |

#### Query Parameters

| Name   | Type   | Description                                                                                   |
| ------ | ------ | --------------------------------------------------------------------------------------------- |
| user   | string | filter by user                                                                                |
| status | string | filter by status (`ACTIVE`, `EXPIRED`, `CANCELLATION_REQUESTED`, `CANCELLED` or `TERMINATED`) |
| from   | number | filter by `subscribedAt` (default 0)                                                          |
| to     | number | filter by `subscribedAt` (default current timestamp)                                          |
| sortBy | string | order by `subscribedAt`, `cycleStart` or `cycleEnd` (default `subscribedAt`)                  |
| sort   | string | `asc` or `desc` (default `desc`), sort based on `sortBy` query parameter                      |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

{% tabs %}
{% tab title="200 " %}

```
{
    "data": [
        {
            "id": "0xe63ba761797e289076f80a7c0916a31740684806aaf507da85f81ee785fec6ba",
            "user": "0x16F37b6c96C7038f3E4CDd7aAF9c9A8EC49c4EE7",
            "planId": "0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7",
            "status": "ACTIVE",
            "subscribedAt": 1571646052,
            "cycleStart": 1571646052,
            "cycleEnd": 1574238052,
            "transactionHash": "0xbb97a142aed61a7027b0a030f3c0ab7e1b39bb776201752829d96d562ed49782",
            "transactionStatus": "confirmed"
        }
    ],
    "limit": 100,
    "offset": 0,
    "total": 1
}
```

{% endtab %}
{% endtabs %}

## Get a subscription

<mark style="color:blue;">`GET`</mark> `https://api.8pay.network/v1/:chain/variable-recurring/subscriptions/:subscriptionId`

#### Path Parameters

| Name           | Type   | Description                                 |
| -------------- | ------ | ------------------------------------------- |
| subscriptionId | string | ID of the subscription                      |
| chain          | string | [chain identifier](/api/overview.md#chains) |

#### Headers

| Name          | Type   | Description       |
| ------------- | ------ | ----------------- |
| Authorization | string | Bearer \<api-key> |

{% tabs %}
{% tab title="200 " %}

```
{
    "id": "0xe63ba761797e289076f80a7c0916a31740684806aaf507da85f81ee785fec6ba",
    "user": "0x16F37b6c96C7038f3E4CDd7aAF9c9A8EC49c4EE7",
    "planId": "0x57b2059e526841b3dfd964144513359c9fcfd6d91040b6c47f589c1e032b6bf7",
    "status": "ACTIVE",
    "subscribedAt": 1571646052,
    "cycleStart": 1571646052,
    "cycleEnd": 1574238052,
    "transactionHash": "0xbb97a142aed61a7027b0a030f3c0ab7e1b39bb776201752829d96d562ed49782",
    "transactionStatus": "confirmed"
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.8pay.network/api/variable-recurring/subscriptions.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
