Update subscription

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

Some fields of a subscription can be updated by calling PATCH on the resource endpoint. Each field is optional.

You cannot update a canceled subscription.

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_5a2pPrwaWy/subscriptions/sub_8EjeBVgtEn.

amount

amount object
optional

The amount that you want to charge, e.g. {"currency":"EUR", "value":"100.00"} if you would want to change the charge to €100.00.

currency

string
required
An ISO 4217 currency code. The currencies supported depend on the payment methods that are enabled on your account.

value

string
required
A string containing the exact amount you want to charge in the given currency. Make sure to send the right amount of decimals. Non-string values are not accepted.

times

integer
optional

Total number of charges for the subscription to complete. Can not be less than number of times that subscription has been charged.

Note

Subscriptions in test mode will be canceled automatically after 10 charges.

startDate

date
optional
The start date of the subscription in YYYY-MM-DD format. This is the first day on which your customer will be charged. Should always be in the future.

description

string
optional
A description unique per subscription . This will be included in the payment description along with the charge date.

mandateId

string
optional
Use this parameter to set a specific mandate for all subscription payments. If you set a method before, it will be changed to null when setting this parameter.

webhookUrl

string
optional
Use this parameter to set a webhook URL for all subscription payments.

metadata

mixed
optional
Provide any data you like, and we will save the data alongside the subscription. Whenever you fetch the subscription with our API, we’ll also include the metadata. You can use up to 1kB of JSON.

Access token parameters

If you are using organization access tokens or are creating an OAuth app, the testmode parameter is also available.

testmode

boolean
optional
Set this to true to update a test mode subscription.

Response

200 application/hal+json

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

Example

cURLPHPPythonRubyNode.js
1
2
3
4
5
6
7
8
curl -X PATCH https://api.mollie.com/v2/customers/cst_5a2pPrwaWy/subscriptions/sub_8EjeBVgtEn \
   -H "Authorization: Bearer test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM" \
   -d "amount[currency]=EUR" \
   -d "amount[value]=10.00" \
   -d "times=42" \
   -d "startDate=2018-12-12" \
   -d "description=Mollie Recurring subscription" \
   -d "webhookUrl=https://example.org/webhook"
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
<?php
$mollie = new \Mollie\Api\MollieApiClient();
$mollie->setApiKey("test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM");
$customer = $mollie->customers->get("cst_8wmqcHMN4U");

$subscription = $customer->getSubscription("sub_8EjeBVgtEn");
$subscription->amount = (object) [
"currency" => "EUR",
"value" => "10.00",
];
$subscription->times = 42;
$subscription->startDate = "2018-12-12";
$subscription->description = "Mollie recurring subscription";
$subscription->webhookUrl = "https://example.org/webhook";
$updatedSubscription = $subscription->update();
1
2
3
4
We don't have a Python code example for this API call yet.

If you have some time to spare, feel free to open a pull request at:
https://github.com/mollie/api-documentation
1
2
3
4
We don't have a Ruby code example for this API call yet.

If you have some time to spare, feel free to open a pull request at:
https://github.com/mollie/api-documentation
1
2
3
4
We don't have a Node.js code example for this API call yet.

If you have some time to spare, feel free to open a pull request at:
https://github.com/mollie/api-documentation

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
37
38
 HTTP/1.1 200 OK
 Content-Type: application/hal+json

 {
     "resource": "subscription",
     "id": "sub_8EjeBVgtEn",
     "customerId": "cst_5a2pPrwaWy",
     "mode": "live",
     "createdAt": "2018-07-10T11:22:53+00:00",
     "status": "active",
     "amount": {
         "value": "10.00",
         "currency": "EUR"
     },
     "description": "Mollie Recurring subscription",
     "method": null,
     "times": 42,
     "timesRemaining": 38,
     "interval": "15 days",
     "startDate": "2018-12-12",
     "nextPaymentDate": "2018-12-12",
     "mandateId": "mdt_84HdeDr5",
     "webhookUrl": "https://example.org/webhook",
     "_links": {
         "self": {
             "href": "https://api.mollie.com/v2/customers/cst_5a2pPrwaWy/subscriptions/sub_8EjeBVgtEn",
             "type": "application/hal+json"
         },
         "customer": {
             "href": "https://api.mollie.com/v2/customers/cst_5a2pPrwaWy",
             "type": "application/hal+json"
         },
         "documentation": {
             "href": "https://docs.mollie.com/reference/v2/subscriptions-api/update-subscription",
             "type": "text/html"
         }
     }
 }