# Subscriptions

> Customers' subscriptions (D29): read, paused and cancelled as the subscription page does.

| Operation | Method and path | Scope |
|---|---|---|
| [List subscriptions](https://docs.kaizenaflow.com/reference/admin-api/subscriptions#subscriptions-list) | `GET /subscriptions` | [`orders:read`](https://docs.kaizenaflow.com/reference/scopes#orders-read) |
| [Get a subscription](https://docs.kaizenaflow.com/reference/admin-api/subscriptions#subscriptions-get) | `GET /subscriptions/{id}` | [`orders:read`](https://docs.kaizenaflow.com/reference/scopes#orders-read) |
| [Pause a subscription](https://docs.kaizenaflow.com/reference/admin-api/subscriptions#subscriptions-pause) | `POST /subscriptions/{id}/pause` | [`orders:send`](https://docs.kaizenaflow.com/reference/scopes#orders-send) |
| [Cancel a subscription](https://docs.kaizenaflow.com/reference/admin-api/subscriptions#subscriptions-cancel) | `POST /subscriptions/{id}/cancel` | [`orders:send`](https://docs.kaizenaflow.com/reference/scopes#orders-send) |

## List subscriptions {#subscriptions-list}

`GET https://kaizenaflow.com/api/admin/v1/subscriptions`

Customers' subscriptions (D29), newest first, each with what renews and when.

- **Operation:** `subscriptions.list`
- **Scope:** [`orders:read`](https://docs.kaizenaflow.com/reference/scopes#orders-read), or [`orders:write`](https://docs.kaizenaflow.com/reference/scopes#orders-write), which reads too
- **Answers:** `200`, a page: the rows under `data`, and `next` for the page after.
- **Pages:** at most 100 rows, 50 when `limit` is left out; give an answer's `next` as `?after=` for the page after.

### Query parameters {#subscriptions-list-query}

| Name | Type | Required | Description |
|---|---|---|---|
| `limit` | integer, 1 to 100 | no | Rows a page holds, at most 100; 50 when left out. A larger number gives 100. |
| `after` | string, at most 200 characters | no | The `next` cursor of the page before; the first page when left out. |
| `updated_after` | string (date-time) | no | Only what was made or changed after this time (ISO 8601 with its offset), for incremental sync. |
| `status` | one of `pending`, `active`, `past_due`, `paused`, `cancelled`, `expired` | no | Only subscriptions in this state. |

### Answer {#subscriptions-list-answer}

| Field | Type | Description |
|---|---|---|
| `data` | list of objects |   |
| `data[].id` | string (uuid) |   |
| `data[].number` | string |   |
| `data[].status` | one of `pending`, `active`, `past_due`, `paused`, `cancelled`, `expired` |   |
| `data[].market` | string | A market, by its code (the country's ISO 3166-1 code, such as NO). |
| `data[].currency` | string, matching `^[A-Z]{3}$` | An ISO 4217 code, such as NOK or EUR. |
| `data[].email` | string |   |
| `data[].customer_id` | string (uuid) or null |   |
| `data[].every` | object | How often it renews: every `count` `interval`s. |
| `data[].every.interval` | string |   |
| `data[].every.count` | integer |   |
| `data[].total_per_renewal_minor` | integer | An amount in minor units of the currency (øre, cents), VAT included where the store's prices are. |
| `data[].current_period_end` | string (date-time) or null |   |
| `data[].next_charge_at` | string (date-time) or null |   |
| `data[].paused_until` | string (date-time) or null |   |
| `data[].ends_at` | string (date-time) or null | When it ends, if a cancellation waits. |
| `data[].cancelled_at` | string (date-time) or null |   |
| `data[].lines` | list of objects |   |
| `data[].lines[].sku` | string |   |
| `data[].lines[].title` | string |   |
| `data[].lines[].quantity` | integer |   |
| `data[].lines[].unit_price_minor` | integer | An amount in minor units of the currency (øre, cents), VAT included where the store's prices are. |
| `data[].created_at` | string (date-time) |   |
| `data[].updated_at` | string (date-time) |   |
| `next` | string or null | The cursor of the next page, given as `?after=`; null on the last page. |

### Errors {#subscriptions-list-errors}

| Status | Code | When |
|---|---|---|
| 401 | [`unauthorized`](https://docs.kaizenaflow.com/reference/errors#unauthorized) | No valid token in `Authorization: Bearer kf_…`, or one that was revoked. |
| 403 | [`feature_off`](https://docs.kaizenaflow.com/reference/errors#feature-off) | The store has switched off the feature the operation stands behind (Settings, Store features); the message names it. |
| 403 | [`forbidden`](https://docs.kaizenaflow.com/reference/errors#forbidden) | The token does not hold the scope the operation needs, or its owner does not hold the staff permission it needs in the store now (a store that is not open, as in the admin, keeps open only its orders, customers, reports and the owner's own pages such as its webhooks; its products, discounts, website and settings, read or changed, are refused); the message names which. |
| 422 | [`invalid`](https://docs.kaizenaflow.com/reference/errors#invalid) | Nothing was done: a body, query or cursor that is not as described, or a check of the screen it goes through; the message says what. |
| 429 | [`rate_limited`](https://docs.kaizenaflow.com/reference/errors#rate-limited) | More calls than the budget allows; `Retry-After` says how many seconds to wait. |
| 500 | [`failed`](https://docs.kaizenaflow.com/reference/errors#failed) | Something went wrong on our side; nothing more was done. It is safe to try again. |

### Example request {#subscriptions-list-example}

**curl**

```shell
curl 'https://kaizenaflow.com/api/admin/v1/subscriptions' \
  -H "Authorization: Bearer $KAIZENA_TOKEN"
```

**JavaScript**

```javascript
const response = await fetch("https://kaizenaflow.com/api/admin/v1/subscriptions", {
  headers: {
    Authorization: `Bearer ${process.env.KAIZENA_TOKEN}`,
  },
});
const answer = await response.json();
```

**Python**

```python
import json
import os
import urllib.request

request = urllib.request.Request(
    "https://kaizenaflow.com/api/admin/v1/subscriptions",
    headers={
        "Authorization": "Bearer " + os.environ["KAIZENA_TOKEN"],
    },
)
with urllib.request.urlopen(request) as response:
    answer = json.load(response)
```

## Get a subscription {#subscriptions-get}

`GET https://kaizenaflow.com/api/admin/v1/subscriptions/{id}`

One subscription with its lines and its next charge.

- **Operation:** `subscriptions.get`
- **Scope:** [`orders:read`](https://docs.kaizenaflow.com/reference/scopes#orders-read), or [`orders:write`](https://docs.kaizenaflow.com/reference/scopes#orders-write), which reads too
- **Answers:** `200`, the answer under `data`.

### Path parameters {#subscriptions-get-path}

| Name | Type | Required | Description |
|---|---|---|---|
| `id` | string (uuid) | yes | The thing's id in this store. |

### Answer {#subscriptions-get-answer}

| Field | Type | Description |
|---|---|---|
| `data` | object |   |
| `data.id` | string (uuid) |   |
| `data.number` | string |   |
| `data.status` | one of `pending`, `active`, `past_due`, `paused`, `cancelled`, `expired` |   |
| `data.market` | string | A market, by its code (the country's ISO 3166-1 code, such as NO). |
| `data.currency` | string, matching `^[A-Z]{3}$` | An ISO 4217 code, such as NOK or EUR. |
| `data.email` | string |   |
| `data.customer_id` | string (uuid) or null |   |
| `data.every` | object | How often it renews: every `count` `interval`s. |
| `data.every.interval` | string |   |
| `data.every.count` | integer |   |
| `data.total_per_renewal_minor` | integer | An amount in minor units of the currency (øre, cents), VAT included where the store's prices are. |
| `data.current_period_end` | string (date-time) or null |   |
| `data.next_charge_at` | string (date-time) or null |   |
| `data.paused_until` | string (date-time) or null |   |
| `data.ends_at` | string (date-time) or null | When it ends, if a cancellation waits. |
| `data.cancelled_at` | string (date-time) or null |   |
| `data.lines` | list of objects |   |
| `data.lines[].sku` | string |   |
| `data.lines[].title` | string |   |
| `data.lines[].quantity` | integer |   |
| `data.lines[].unit_price_minor` | integer | An amount in minor units of the currency (øre, cents), VAT included where the store's prices are. |
| `data.created_at` | string (date-time) |   |
| `data.updated_at` | string (date-time) |   |

### Errors {#subscriptions-get-errors}

| Status | Code | When |
|---|---|---|
| 401 | [`unauthorized`](https://docs.kaizenaflow.com/reference/errors#unauthorized) | No valid token in `Authorization: Bearer kf_…`, or one that was revoked. |
| 403 | [`feature_off`](https://docs.kaizenaflow.com/reference/errors#feature-off) | The store has switched off the feature the operation stands behind (Settings, Store features); the message names it. |
| 403 | [`forbidden`](https://docs.kaizenaflow.com/reference/errors#forbidden) | The token does not hold the scope the operation needs, or its owner does not hold the staff permission it needs in the store now (a store that is not open, as in the admin, keeps open only its orders, customers, reports and the owner's own pages such as its webhooks; its products, discounts, website and settings, read or changed, are refused); the message names which. |
| 404 | [`not_found`](https://docs.kaizenaflow.com/reference/errors#not-found) | No such route, or nothing with that id in the token's store (another store's ids are simply not found). |
| 429 | [`rate_limited`](https://docs.kaizenaflow.com/reference/errors#rate-limited) | More calls than the budget allows; `Retry-After` says how many seconds to wait. |
| 500 | [`failed`](https://docs.kaizenaflow.com/reference/errors#failed) | Something went wrong on our side; nothing more was done. It is safe to try again. |

### Example request {#subscriptions-get-example}

**curl**

```shell
curl 'https://kaizenaflow.com/api/admin/v1/subscriptions/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f' \
  -H "Authorization: Bearer $KAIZENA_TOKEN"
```

**JavaScript**

```javascript
const response = await fetch("https://kaizenaflow.com/api/admin/v1/subscriptions/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f", {
  headers: {
    Authorization: `Bearer ${process.env.KAIZENA_TOKEN}`,
  },
});
const answer = await response.json();
```

**Python**

```python
import json
import os
import urllib.request

request = urllib.request.Request(
    "https://kaizenaflow.com/api/admin/v1/subscriptions/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f",
    headers={
        "Authorization": "Bearer " + os.environ["KAIZENA_TOKEN"],
    },
)
with urllib.request.urlopen(request) as response:
    answer = json.load(response)
```

## Pause a subscription {#subscriptions-pause}

`POST https://kaizenaflow.com/api/admin/v1/subscriptions/{id}/pause`

Pauses charges and deliveries for some periods, as the subscription page does (never in a free trial or while a payment is failing); the subscriber is emailed.

- **Operation:** `subscriptions.pause`
- **Scope:** [`orders:send`](https://docs.kaizenaflow.com/reference/scopes#orders-send)
- **Answers:** `200`, the answer under `data`.
- **Once only:** with an [`Idempotency-Key`](https://docs.kaizenaflow.com/reference/admin-api#idempotency) header.

### Path parameters {#subscriptions-pause-path}

| Name | Type | Required | Description |
|---|---|---|---|
| `id` | string (uuid) | yes | The thing's id in this store. |

### Body {#subscriptions-pause-body}

JSON, with `Content-Type: application/json`.

| Field | Type | Required | Description |
|---|---|---|---|
| `periods` | integer, 1 to 12 | no, default `1` | Deliveries to pause for (the store's limit applies). |

### Answer {#subscriptions-pause-answer}

| Field | Type | Description |
|---|---|---|
| `data` | object |   |
| `data.id` | string (uuid) |   |
| `data.number` | string |   |
| `data.status` | one of `pending`, `active`, `past_due`, `paused`, `cancelled`, `expired` |   |
| `data.market` | string | A market, by its code (the country's ISO 3166-1 code, such as NO). |
| `data.currency` | string, matching `^[A-Z]{3}$` | An ISO 4217 code, such as NOK or EUR. |
| `data.email` | string |   |
| `data.customer_id` | string (uuid) or null |   |
| `data.every` | object | How often it renews: every `count` `interval`s. |
| `data.every.interval` | string |   |
| `data.every.count` | integer |   |
| `data.total_per_renewal_minor` | integer | An amount in minor units of the currency (øre, cents), VAT included where the store's prices are. |
| `data.current_period_end` | string (date-time) or null |   |
| `data.next_charge_at` | string (date-time) or null |   |
| `data.paused_until` | string (date-time) or null |   |
| `data.ends_at` | string (date-time) or null | When it ends, if a cancellation waits. |
| `data.cancelled_at` | string (date-time) or null |   |
| `data.lines` | list of objects |   |
| `data.lines[].sku` | string |   |
| `data.lines[].title` | string |   |
| `data.lines[].quantity` | integer |   |
| `data.lines[].unit_price_minor` | integer | An amount in minor units of the currency (øre, cents), VAT included where the store's prices are. |
| `data.created_at` | string (date-time) |   |
| `data.updated_at` | string (date-time) |   |

### Errors {#subscriptions-pause-errors}

| Status | Code | When |
|---|---|---|
| 401 | [`unauthorized`](https://docs.kaizenaflow.com/reference/errors#unauthorized) | No valid token in `Authorization: Bearer kf_…`, or one that was revoked. |
| 403 | [`feature_off`](https://docs.kaizenaflow.com/reference/errors#feature-off) | The store has switched off the feature the operation stands behind (Settings, Store features); the message names it. |
| 403 | [`forbidden`](https://docs.kaizenaflow.com/reference/errors#forbidden) | The token does not hold the scope the operation needs, or its owner does not hold the staff permission it needs in the store now (a store that is not open, as in the admin, keeps open only its orders, customers, reports and the owner's own pages such as its webhooks; its products, discounts, website and settings, read or changed, are refused); the message names which. |
| 404 | [`not_found`](https://docs.kaizenaflow.com/reference/errors#not-found) | No such route, or nothing with that id in the token's store (another store's ids are simply not found). |
| 409 | [`conflict`](https://docs.kaizenaflow.com/reference/errors#conflict) | Nothing was done: it clashes with how things are now (nothing left to send), or an `Idempotency-Key` is in use or was used for another request. |
| 422 | [`invalid`](https://docs.kaizenaflow.com/reference/errors#invalid) | Nothing was done: a body, query or cursor that is not as described, or a check of the screen it goes through; the message says what. |
| 429 | [`rate_limited`](https://docs.kaizenaflow.com/reference/errors#rate-limited) | More calls than the budget allows; `Retry-After` says how many seconds to wait. |
| 500 | [`failed`](https://docs.kaizenaflow.com/reference/errors#failed) | Something went wrong on our side; nothing more was done. It is safe to try again. |

### Example request {#subscriptions-pause-example}

**curl**

```shell
curl -X POST 'https://kaizenaflow.com/api/admin/v1/subscriptions/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f/pause' \
  -H "Authorization: Bearer $KAIZENA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"periods":1}'
```

**JavaScript**

```javascript
const response = await fetch("https://kaizenaflow.com/api/admin/v1/subscriptions/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f/pause", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.KAIZENA_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "periods": 1
  }),
});
const answer = await response.json();
```

**Python**

```python
import json
import os
import urllib.request

request = urllib.request.Request(
    "https://kaizenaflow.com/api/admin/v1/subscriptions/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f/pause",
    method="POST",
    headers={
        "Authorization": "Bearer " + os.environ["KAIZENA_TOKEN"],
        "Content-Type": "application/json",
    },
    data=json.dumps({
        "periods": 1,
    }).encode(),
)
with urllib.request.urlopen(request) as response:
    answer = json.load(response)
```

## Cancel a subscription {#subscriptions-cancel}

`POST https://kaizenaflow.com/api/admin/v1/subscriptions/{id}/cancel`

Cancels at the end of the paid period (or of a commitment), or at once with `now`, as staff may; the subscriber is emailed.

- **Operation:** `subscriptions.cancel`
- **Scope:** [`orders:send`](https://docs.kaizenaflow.com/reference/scopes#orders-send)
- **Answers:** `200`, the answer under `data`.
- **Once only:** with an [`Idempotency-Key`](https://docs.kaizenaflow.com/reference/admin-api#idempotency) header.

### Path parameters {#subscriptions-cancel-path}

| Name | Type | Required | Description |
|---|---|---|---|
| `id` | string (uuid) | yes | The thing's id in this store. |

### Body {#subscriptions-cancel-body}

JSON, with `Content-Type: application/json`.

| Field | Type | Required | Description |
|---|---|---|---|
| `at` | one of `period_end`, `now` | no, default `"period_end"` | period_end: at the end of the paid period or of a commitment. now: at once, with no refund. |

### Answer {#subscriptions-cancel-answer}

| Field | Type | Description |
|---|---|---|
| `data` | object |   |
| `data.id` | string (uuid) |   |
| `data.number` | string |   |
| `data.status` | one of `pending`, `active`, `past_due`, `paused`, `cancelled`, `expired` |   |
| `data.market` | string | A market, by its code (the country's ISO 3166-1 code, such as NO). |
| `data.currency` | string, matching `^[A-Z]{3}$` | An ISO 4217 code, such as NOK or EUR. |
| `data.email` | string |   |
| `data.customer_id` | string (uuid) or null |   |
| `data.every` | object | How often it renews: every `count` `interval`s. |
| `data.every.interval` | string |   |
| `data.every.count` | integer |   |
| `data.total_per_renewal_minor` | integer | An amount in minor units of the currency (øre, cents), VAT included where the store's prices are. |
| `data.current_period_end` | string (date-time) or null |   |
| `data.next_charge_at` | string (date-time) or null |   |
| `data.paused_until` | string (date-time) or null |   |
| `data.ends_at` | string (date-time) or null | When it ends, if a cancellation waits. |
| `data.cancelled_at` | string (date-time) or null |   |
| `data.lines` | list of objects |   |
| `data.lines[].sku` | string |   |
| `data.lines[].title` | string |   |
| `data.lines[].quantity` | integer |   |
| `data.lines[].unit_price_minor` | integer | An amount in minor units of the currency (øre, cents), VAT included where the store's prices are. |
| `data.created_at` | string (date-time) |   |
| `data.updated_at` | string (date-time) |   |

### Errors {#subscriptions-cancel-errors}

| Status | Code | When |
|---|---|---|
| 401 | [`unauthorized`](https://docs.kaizenaflow.com/reference/errors#unauthorized) | No valid token in `Authorization: Bearer kf_…`, or one that was revoked. |
| 403 | [`feature_off`](https://docs.kaizenaflow.com/reference/errors#feature-off) | The store has switched off the feature the operation stands behind (Settings, Store features); the message names it. |
| 403 | [`forbidden`](https://docs.kaizenaflow.com/reference/errors#forbidden) | The token does not hold the scope the operation needs, or its owner does not hold the staff permission it needs in the store now (a store that is not open, as in the admin, keeps open only its orders, customers, reports and the owner's own pages such as its webhooks; its products, discounts, website and settings, read or changed, are refused); the message names which. |
| 404 | [`not_found`](https://docs.kaizenaflow.com/reference/errors#not-found) | No such route, or nothing with that id in the token's store (another store's ids are simply not found). |
| 409 | [`conflict`](https://docs.kaizenaflow.com/reference/errors#conflict) | Nothing was done: it clashes with how things are now (nothing left to send), or an `Idempotency-Key` is in use or was used for another request. |
| 422 | [`invalid`](https://docs.kaizenaflow.com/reference/errors#invalid) | Nothing was done: a body, query or cursor that is not as described, or a check of the screen it goes through; the message says what. |
| 429 | [`rate_limited`](https://docs.kaizenaflow.com/reference/errors#rate-limited) | More calls than the budget allows; `Retry-After` says how many seconds to wait. |
| 500 | [`failed`](https://docs.kaizenaflow.com/reference/errors#failed) | Something went wrong on our side; nothing more was done. It is safe to try again. |

### Example request {#subscriptions-cancel-example}

**curl**

```shell
curl -X POST 'https://kaizenaflow.com/api/admin/v1/subscriptions/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f/cancel' \
  -H "Authorization: Bearer $KAIZENA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"at":"period_end"}'
```

**JavaScript**

```javascript
const response = await fetch("https://kaizenaflow.com/api/admin/v1/subscriptions/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f/cancel", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.KAIZENA_TOKEN}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "at": "period_end"
  }),
});
const answer = await response.json();
```

**Python**

```python
import json
import os
import urllib.request

request = urllib.request.Request(
    "https://kaizenaflow.com/api/admin/v1/subscriptions/3f2b8c1e-6d4a-4b9e-8c7f-1a2b3c4d5e6f/cancel",
    method="POST",
    headers={
        "Authorization": "Bearer " + os.environ["KAIZENA_TOKEN"],
        "Content-Type": "application/json",
    },
    data=json.dumps({
        "at": "period_end",
    }).encode(),
)
with urllib.request.urlopen(request) as response:
    answer = json.load(response)
```

---

https://docs.kaizenaflow.com/reference/admin-api/subscriptions · made from the API contract 1.57
