---
title: "Subscriptions"
description: "Create and list subscriptions, create order for subscription, start initial payment, create new order for the same subscription and then start recurring payment."
canonical: "https://docs.cm.com/payments/online-payments-legacy/guides/api-reference/resources/subscriptions"
---

# Subscriptions

> Create and list subscriptions, create order for subscription, start initial payment, create new order for the same subscription and then start recurring payment.

Source: https://docs.cm.com/payments/online-payments-legacy/guides/api-reference/resources/subscriptions

Create and list subscriptions, create order for subscription, start initial payment, create new order for the same subscription and then start recurring payment.

## Create a new subscription

Create a new subscription.

```
POST /ps/api/public/v1/merchants/{merchant_key}/subscriptions
```

**Identifiers**

| Name | Type | Description |
| - | - | - |
| merchant\_key | MerchantKey | The key of the merchant. |

**Parameters**

_Not applicable._

**Request**

| Field | Type | M | Description |
| - | - | :-: | - |
| subscription\_reference | String(1, 255) | M | The subscription reference from the merchant. |

**Response**

_Not applicable._

**HTTP Status**

| Status | Meaning |
| - | - |
| 201 (Created) | The subscription is successfully created. |
| 400 (Bad Request) | The request was not valid. |
| 401 (Unauthorized) | Authorization header missing or invalid. |
| 403 (Forbidden) | The merchant key is not allowed. |

**Create subscription example**

```bash
> curl \
    -X POST \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Basic RG9jZGF0YVBGOkJXazJhZkpV' \
    https://testsecure.docdatapayments.com/ps/api/public/v1/merchants/4ef08825-993a-424d-a769-3ee97116a1b6/subscriptions \
    -d '{
        "subscription_reference"   : "vk20210318a"
    }'
 
< Http 201 Created
```

## Create a new order

Create a new order for a subscription. This is the same as creating a normal order, except the subscription reference needs to given in the url.

It is advisable to supply a [billing address](https://docs.cm.com/payments/online-payments-legacy/guides/api-reference/resources/shoppers) for the shopper to be used on the mandate. See [Create order](https://docs.cm.com/payments/online-payments-legacy/guides/api-reference/resources/orders#create-order) for more details.

```
POST /ps/api/public/v1/merchants/{merchant_key}/subscriptions/{subscription_reference}/orders
```

## Start Initial Payment

Starts a new payment for the given Order of a Subscription. This is the initial payment (first payment for the subscription) in which the shopper authorizes the details using the menu or the via [Start Payment](https://docs.cm.com/payments/online-payments-legacy/guides/api-reference/resources/payments#start-payment) endpoint.

## Get details of subscription

Returns the details of a subscription including the orders.

```
GET /ps/api/public/v1/merchants/{merchant_key}/subscriptions/{subscription_reference}
GET /ps/api/public/v1/merchants/{merchant_key}/subscriptions/{subscription_reference}?page=1
```

**Identifiers**

| Name | Type | Description |
| - | - | - |
| merchant\_key | MerchantKey | The key of the merchant. |
| subscription\_reference | String(1, 255) | The subscription reference from the merchant. |

**Parameters**

| Name | M | Description |
| - | - | - |
| page | O | The page to get the subscription orders. Starts at 1. Each page returns 25 orders. If the page parameter is not given or if the page \<=1 , then the call will return the first 25 orders. |

**Parameters**

_Not applicable._

**Request**

_Not applicable._

**Response**

| Field | Type | M | Description |
| - | - | :-: | - |
| timestamp | DateTime | M | The date and time when the subscription was created. |
| method | PaymentMethod | C | The payment method, e.g. "IDEAL" or "SEPA\_DIRECT\_DEBIT". Only available when a initial-recurring payment was authorized. |
| mandate\_number | String(1, 255) | C | The mandate number. Only available when a initial-recurring payment was authorized. |
| _orders_ | _Block\[]_ | _O_ | _A list of orders on this subscription._ |
| + order\_reference | String(1, 255) | M | The order reference from the merchant. |
| + timestamp | DateTime | M | The date and time when the order was created. |
| + order\_key | OrderKey | M | The key of the order. |
| _+ considered\_safe_ | _Block_ | _C_ | _The considered safe result. Only available when the order is considered safe._ |
| + + level | Enum(16) | M | The considered safe level for the order: "FASTEST", "FAST", "SAFE" or "SAFEST". |
| + + timestamp | DateTime | M | The date and time in seconds when the order was considered safe. Formatted according ISO 8601 with timezone in UTC. |

**HTTP Status**

| Status | Meaning |
| - | - |
| 200 (OK) | Success. |
| 403 (Forbidden) | The merchant key is not correct. |
| 404 (Not Found) | The reference for the subscription was not found. |

**Subscription Details example**

```bash
> curl \
    -X GET \
    --header 'Authorization: Basic RG9jZGF0YVBGOkJXazJhZkpV' \
    https://testsecure.docdatapayments.com/ps/api/public/v1/merchants/4ef08825-993a-424d-a769-3ee97116a1b6/subscriptions/vk20170224p
 
< Http 200 Ok
<   '{
        "timestamp"     : "2017-02-24T17:08:13Z",
        "method"        : "SEPA_DIRECT_DEBIT",
        "mandate_number": "ddps-148795461791824269",
        "orders"        : [
            {
                "order_reference"   : "vk20170224p",
                "timestamp"         : "2017-02-24T17:08:31Z",
                "order_key"         : "F1499C097FFA533D46FB05D52680AB9A",
                "considered_safe"   : {
                    "level" : "SAFE",
                    "timestamp" : "2017-02-24T17:09:58Z"
                }
            },
            {
                "order_reference"   : "vk20170320b",
                "timestamp"         : "2017-02-25T09:31:22Z""
                "order_key"         : "29FF5671F59846D2E0F432A6E450B6AE"
            }
        ]
    }'
```

## Create a new Order for each recurring payment

Create a new order for a subscription. This step is same as [Create a new Order](https://docs.cm.com/payments/online-payments-legacy/guides/api-reference/resources/subscriptions#create-a-new-order) but now this order is for recurring payment.

It is advisable to supply a [billing address](https://docs.cm.com/payments/online-payments-legacy/guides/api-reference/resources/shoppers) for the shopper to be used on the mandate. See [Create order](https://docs.cm.com/payments/online-payments-legacy/guides/api-reference/resources/orders#create-order) for more details.

```
POST /ps/api/public/v1/merchants/{merchant_key}/subscriptions/{subscription_reference}/orders
```

## Start Recurring Payment

Starts a new subsequent/recurring payment for the given Order of a Subscription.

The payment details of the initial-recurring payment are used, which the shopper should have authorized previously using the menu or the via [Start Payment](https://docs.cm.com/payments/online-payments-legacy/guides/api-reference/resources/payments#start-payment) endpoint.

```
POST /ps/api/public/v1/merchants/{merchant_key}/subscriptions/{subscription_reference}/orders/{order_key}/payments
```

**Identifiers**

| Name | Type | Description |
| - | - | - |
| merchant\_key | MerchantKey | The key of the merchant. |
| subscription\_reference | String(1, 255) | The subscription reference from the merchant. |
| order\_key | OrderKey | The key of the order. |

**Parameters**

_Not applicable._

**Request**

| Field | Type | M | Description |
| - | - | :-: | - |
| sca\_exemption | Enum(32) | O | The requested exemption type. Default value is 'RECURRING'. |
| + _three\_ri\_authentication_ | _Block_ | _O_ | _The 3RI authentication details._ |

Details about the 3RI authentication block and process can be found on [3RI Authentication](https://docs.cm.com/payments/online-payments-legacy/guides/api-reference/card-authentication/3ri-authentication).

For the field `sca_exemption` the following values are possible:

| Status | Description |
| - | - |
| RECURRING | The payment is part of a scheduled subsequent transaction. |
| UNSCHEDULED | The payment is part of an unscheduled subsequent transaction. For example a top-up payment. Must be enabled on the merchant account. |

**Response**

| Field | Type | M | Description |
| - | - | :-: | - |
| id | PaymentIdentifier | M | The payment identifier. |
| status | Enum(32) | M | The authorization status of the payment. |

For the field `status` the following values are possible:

| Status | Description |
| - | - |
| CANCELED | The payment is canceled, due to an error. |
| AUTHENTICATION\_REQUESTED | The shopper needs to complete the authentication request that is pushed to its device. |
| AUTHORIZED | The payment is authorized. |

**HTTP Status**

| Status | Meaning |
| - | - |
| 201 (Created) | The payment is created. |
| 202 (Accepted) | The payment is created and ended in canceled due to an error. |
| 400 (Bad Request) | The request was not valid. |
| 403 (Forbidden) | The merchant key is not correct. |
| 404 (Not Found) | The reference for the subscription or the order key was not found. |

**Start recurring payment example**

```bash
> curl \
    -X POST \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Basic RG9jZGF0YVBGOkJXazJhZkpV' \
    https://testsecure.docdatapayments.com/ps/api/public/v1/merchants/4ef08825-993a-424d-a769-3ee97116a1b6/subscriptions/vk20210318a/orders/B72AD93F3CBFC47BB2173361D5DE573D/payments \
    -d '{
    "sca_exemption" : "RECURRING"
    }'
 
< Http 201 Created 
<    '{
        "id"        : "pid2163180628t",
        "status"    : "AUTHORIZED"
     }'
```
