Cancel subscription

Subscriptions API v2
DELETEhttps://api.mollie.com/v2/customers/*customerId*/subscriptions/*id*

A subscription can be canceled any time by calling DELETE on the resource endpoint.

Parameters

Replace customerId in the endpoint URL by the customer’s ID, and replace id by the subscription’s ID. For example: /v2/customers/cst_stTC2WHAuS/subscriptions/sub_rVKGtNd6s3.

Access token parameters

If you are using organization access tokens or are creating an OAuth app, you can enable test mode through the testmode parameter.

testmodebooleanoptional

Response

200 application/hal+json

A subscription object is returned, as described in Get subscription.

Example

cURLPHPPythonRubyNode.js
1
2
curl -X DELETE https://api.mollie.com/v2/customers/cst_stTC2WHAuS/subscriptions/sub_rVKGtNd6s3 \
   -H "Authorization: Bearer test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"
1
2
3
4
5
6
<?php
$mollie = new \Mollie\Api\MollieApiClient();
$mollie->setApiKey("test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM");

$customer = $mollie->customers->get("cst_stTC2WHAuS");
$subscription = $customer->cancelSubscription("sub_rVKGtNd6s3");
1
2
3
4
5
6
from mollie.api.client import Client

mollie_client = Client()
mollie_client.set_api_key('test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM')

mollie_client.customer_subscriptions.with_parent_id('cst_stTC2WHAuS').delete('sub_rVKGtNd6s3')
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
require 'mollie-api-ruby'

Mollie::Client.configure do |config|
  config.api_key = 'test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM'
end

Mollie::Customer::Subscription.cancel(
  'sub_rVKGtNd6s3',
  customer_id: 'cst_stTC2WHAuS'
)
1
2
3
4
5
6
const { createMollieClient } = require('@mollie/api-client');
const mollieClient = createMollieClient({ apiKey: 'test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM' });

(async () => {
  const subscription = await mollieClient.customers_subscriptions.cancel('sub_rVKGtNd6s3', { customerId: 'cst_stTC2WHAuS' });
})();

Response

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
HTTP/1.1 200 OK
Content-Type: application/hal+json

{
    "resource": "subscription",
    "id": "sub_rVKGtNd6s3",
    "mode": "live",
    "createdAt": "2018-06-01T12:23:34+00:00",
    "status": "canceled",
    "amount": {
        "value": "25.00",
        "currency": "EUR"
    },
    "times": 4,
    "interval": "3 months",
    "nextPaymentDate": null,
    "description": "Quarterly payment",
    "method": null,
    "startDate": "2016-06-01",
    "webhookUrl": "https://webshop.example.org/payments/webhook",
    "canceledAt": "2018-08-01T11:04:21+00:00",
    "_links": {
        "self": {
            "href": "https://api.mollie.com/v2/customers/cst_stTC2WHAuS/subscriptions/sub_rVKGtNd6s3",
            "type": "application/hal+json"
        },
        "customer": {
            "href": "https://api.mollie.com/v2/customers/cst_stTC2WHAuS",
            "type": "application/hal+json"
        },
        "documentation": {
            "href": "https://docs.mollie.com/reference/v2/subscriptions-api/cancel-subscription",
            "type": "text/html"
        }
    }
}