Update a subscription
Update a subscription
curl --request PATCH \
--url https://sandbox-api.paynext.com/subscriptions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-API-Version: <x-api-version>' \
--data '
{
"plan": {
"id": "price_63e6b401-3803-4f95-aae9-262a0490dafd"
},
"subscription": {
"change_mode": "next_billing_date",
"id": "sub_887934f2-de1a-4b28-a288-ba8f70c71bd3",
"status": "<unknown>"
}
}
'const options = {
method: 'PATCH',
headers: {
'X-API-Version': '<x-api-version>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
plan: {id: 'price_63e6b401-3803-4f95-aae9-262a0490dafd'},
subscription: {
change_mode: 'next_billing_date',
id: 'sub_887934f2-de1a-4b28-a288-ba8f70c71bd3',
status: '<unknown>'
}
})
};
fetch('https://sandbox-api.paynext.com/subscriptions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://sandbox-api.paynext.com/subscriptions"
payload := strings.NewReader("{\n \"plan\": {\n \"id\": \"price_63e6b401-3803-4f95-aae9-262a0490dafd\"\n },\n \"subscription\": {\n \"change_mode\": \"next_billing_date\",\n \"id\": \"sub_887934f2-de1a-4b28-a288-ba8f70c71bd3\",\n \"status\": \"<unknown>\"\n }\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("X-API-Version", "<x-api-version>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://sandbox-api.paynext.com/subscriptions")
.header("X-API-Version", "<x-api-version>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"plan\": {\n \"id\": \"price_63e6b401-3803-4f95-aae9-262a0490dafd\"\n },\n \"subscription\": {\n \"change_mode\": \"next_billing_date\",\n \"id\": \"sub_887934f2-de1a-4b28-a288-ba8f70c71bd3\",\n \"status\": \"<unknown>\"\n }\n}")
.asString();import requests
url = "https://sandbox-api.paynext.com/subscriptions"
payload = {
"plan": { "id": "price_63e6b401-3803-4f95-aae9-262a0490dafd" },
"subscription": {
"change_mode": "next_billing_date",
"id": "sub_887934f2-de1a-4b28-a288-ba8f70c71bd3",
"status": "<unknown>"
}
}
headers = {
"X-API-Version": "<x-api-version>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://sandbox-api.paynext.com/subscriptions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'plan' => [
'id' => 'price_63e6b401-3803-4f95-aae9-262a0490dafd'
],
'subscription' => [
'change_mode' => 'next_billing_date',
'id' => 'sub_887934f2-de1a-4b28-a288-ba8f70c71bd3',
'status' => '<unknown>'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"X-API-Version: <x-api-version>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}{
"created_at": "2025-05-26T10:00:00Z",
"current_period_end": "<string>",
"cancelled_at": "2026-06-10T14:32:08Z",
"cancellation_details": {
"reason": "fraud_prevention",
"trigger_payment_id": "pay_e8a1b2c3-1d2e-3f4a-5b6c-7d8e9f0a1b2c"
},
"current_period_start": "<string>",
"id": "sub_123e4567-e89b-12d3-a456-426614174000",
"metadata": {
"key": "value"
},
"next_billing_date": "2025-06-26T12:00:00Z",
"past_due": {
"attempt_count": 2,
"max_attempts_count": 7
},
"plan": {
"id": "price_1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d",
"interval": "days",
"interval_count": 1,
"name": "Pro Plan",
"price": {
"amount": 1999,
"currency": "AED"
},
"tax": {
"collect_tax": "<unknown>"
},
"trial_interval": "days",
"trial_interval_count": 14,
"trial_price": {
"amount": 1999,
"currency": "AED"
},
"type": "recurring"
},
"status": "trial",
"updated_at": "2025-05-27T10:00:00Z"
}{
"error": {
"message": "some error message"
}
}{
"error": {
"message": "some error message"
}
}{
"error": {
"message": "some error message"
}
}Authorizations
Authentication header of the form api key, where api key is your organization api key.
Headers
Specifies the version of the API to use
1.0.0 Body
Update subscription
Response
OK
The date and time at which the subscription was created in UTC format
"2025-05-26T10:00:00Z"
UTC timestamp of when the subscription became cancelled; null unless the subscription is cancelled
"2026-06-10T14:32:08Z"
Server-attested cancellation attribution. Always present; sub-fields are null unless the subscription is cancelled (or scheduled for cancellation).
Show child attributes
Show child attributes
Unique identifier for the subscription
"sub_123e4567-e89b-12d3-a456-426614174000"
Custom metadata associated with the subscription A dictionary of key-value pairs.
Show child attributes
Show child attributes
{ "key": "value" }
Next scheduled billing date for the subscription
"2025-06-26T12:00:00Z"
Information about past due attempts
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Current status of the subscription
trial, active, past_due, cancelled, scheduled_for_cancellation The date and time of the last subscription update in UTC format
"2025-05-27T10:00:00Z"
Was this page helpful?
curl --request PATCH \
--url https://sandbox-api.paynext.com/subscriptions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'X-API-Version: <x-api-version>' \
--data '
{
"plan": {
"id": "price_63e6b401-3803-4f95-aae9-262a0490dafd"
},
"subscription": {
"change_mode": "next_billing_date",
"id": "sub_887934f2-de1a-4b28-a288-ba8f70c71bd3",
"status": "<unknown>"
}
}
'const options = {
method: 'PATCH',
headers: {
'X-API-Version': '<x-api-version>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
plan: {id: 'price_63e6b401-3803-4f95-aae9-262a0490dafd'},
subscription: {
change_mode: 'next_billing_date',
id: 'sub_887934f2-de1a-4b28-a288-ba8f70c71bd3',
status: '<unknown>'
}
})
};
fetch('https://sandbox-api.paynext.com/subscriptions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://sandbox-api.paynext.com/subscriptions"
payload := strings.NewReader("{\n \"plan\": {\n \"id\": \"price_63e6b401-3803-4f95-aae9-262a0490dafd\"\n },\n \"subscription\": {\n \"change_mode\": \"next_billing_date\",\n \"id\": \"sub_887934f2-de1a-4b28-a288-ba8f70c71bd3\",\n \"status\": \"<unknown>\"\n }\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("X-API-Version", "<x-api-version>")
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://sandbox-api.paynext.com/subscriptions")
.header("X-API-Version", "<x-api-version>")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"plan\": {\n \"id\": \"price_63e6b401-3803-4f95-aae9-262a0490dafd\"\n },\n \"subscription\": {\n \"change_mode\": \"next_billing_date\",\n \"id\": \"sub_887934f2-de1a-4b28-a288-ba8f70c71bd3\",\n \"status\": \"<unknown>\"\n }\n}")
.asString();import requests
url = "https://sandbox-api.paynext.com/subscriptions"
payload = {
"plan": { "id": "price_63e6b401-3803-4f95-aae9-262a0490dafd" },
"subscription": {
"change_mode": "next_billing_date",
"id": "sub_887934f2-de1a-4b28-a288-ba8f70c71bd3",
"status": "<unknown>"
}
}
headers = {
"X-API-Version": "<x-api-version>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://sandbox-api.paynext.com/subscriptions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'plan' => [
'id' => 'price_63e6b401-3803-4f95-aae9-262a0490dafd'
],
'subscription' => [
'change_mode' => 'next_billing_date',
'id' => 'sub_887934f2-de1a-4b28-a288-ba8f70c71bd3',
'status' => '<unknown>'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json",
"X-API-Version: <x-api-version>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}{
"created_at": "2025-05-26T10:00:00Z",
"current_period_end": "<string>",
"cancelled_at": "2026-06-10T14:32:08Z",
"cancellation_details": {
"reason": "fraud_prevention",
"trigger_payment_id": "pay_e8a1b2c3-1d2e-3f4a-5b6c-7d8e9f0a1b2c"
},
"current_period_start": "<string>",
"id": "sub_123e4567-e89b-12d3-a456-426614174000",
"metadata": {
"key": "value"
},
"next_billing_date": "2025-06-26T12:00:00Z",
"past_due": {
"attempt_count": 2,
"max_attempts_count": 7
},
"plan": {
"id": "price_1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d",
"interval": "days",
"interval_count": 1,
"name": "Pro Plan",
"price": {
"amount": 1999,
"currency": "AED"
},
"tax": {
"collect_tax": "<unknown>"
},
"trial_interval": "days",
"trial_interval_count": 14,
"trial_price": {
"amount": 1999,
"currency": "AED"
},
"type": "recurring"
},
"status": "trial",
"updated_at": "2025-05-27T10:00:00Z"
}{
"error": {
"message": "some error message"
}
}{
"error": {
"message": "some error message"
}
}{
"error": {
"message": "some error message"
}
}