Update auto top-up
curl --request PATCH \
--url https://commet.co/api/v1/subscriptions/{id}/auto-top-up \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"enabled": true,
"threshold": 1073741823,
"quantity": 1073741824,
"amount": 1073741824,
"maxPerPeriod": 50
}
'const options = {
method: 'PATCH',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
enabled: true,
threshold: 1073741823,
quantity: 1073741824,
amount: 1073741824,
maxPerPeriod: 50
})
};
fetch('https://commet.co/api/v1/subscriptions/{id}/auto-top-up', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://commet.co/api/v1/subscriptions/{id}/auto-top-up"
payload = {
"enabled": True,
"threshold": 1073741823,
"quantity": 1073741824,
"amount": 1073741824,
"maxPerPeriod": 50
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://commet.co/api/v1/subscriptions/{id}/auto-top-up"
payload := strings.NewReader("{\n \"enabled\": true,\n \"threshold\": 1073741823,\n \"quantity\": 1073741824,\n \"amount\": 1073741824,\n \"maxPerPeriod\": 50\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("x-api-key", "<api-key>")
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://commet.co/api/v1/subscriptions/{id}/auto-top-up")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"enabled\": true,\n \"threshold\": 1073741823,\n \"quantity\": 1073741824,\n \"amount\": 1073741824,\n \"maxPerPeriod\": 50\n}")
.asString();<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://commet.co/api/v1/subscriptions/{id}/auto-top-up",
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([
'enabled' => true,
'threshold' => 1073741823,
'quantity' => 1073741824,
'amount' => 1073741824,
'maxPerPeriod' => 50
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}{
"success": true,
"data": {
"enabled": true,
"threshold": 0,
"quantity": 0,
"amount": 0,
"maxPerPeriod": 0,
"status": "active",
"topUpsThisPeriod": 0,
"periodResetsAt": "2023-11-07T05:31:56Z",
"lastFailure": {
"reason": "payment_declined",
"at": "2023-11-07T05:31:56Z"
},
"object": "subscription",
"livemode": true
}
}{
"success": false,
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"param": "<string>",
"details": "<unknown>"
}
}{
"success": false,
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"param": "<string>",
"details": "<unknown>"
}
}{
"success": false,
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"param": "<string>",
"details": "<unknown>"
}
}{
"success": false,
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"param": "<string>",
"details": "<unknown>"
}
}{
"success": false,
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"param": "<string>",
"details": "<unknown>"
}
}Subscriptions
Update auto top-up
Turn automatic top-ups on or off and set the threshold, the size of each top-up and the maximum top-ups per period. Send only the fields that change. On a credits plan each top-up buys quantity credits; on a balance plan it adds amount in minor units of the subscription currency, plus tax, and threshold is in the same minor units. Enabling requires a plan that sells credits or has balance top-ups on. The size must be at least the plan’s minimum when auto top-up is enabled or when the size changes, so turning it off keeps working after the minimum rises. Saving it enabled resumes a paused auto top-up.
PATCH
/
subscriptions
/
{id}
/
auto-top-up
Update auto top-up
curl --request PATCH \
--url https://commet.co/api/v1/subscriptions/{id}/auto-top-up \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"enabled": true,
"threshold": 1073741823,
"quantity": 1073741824,
"amount": 1073741824,
"maxPerPeriod": 50
}
'const options = {
method: 'PATCH',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
enabled: true,
threshold: 1073741823,
quantity: 1073741824,
amount: 1073741824,
maxPerPeriod: 50
})
};
fetch('https://commet.co/api/v1/subscriptions/{id}/auto-top-up', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://commet.co/api/v1/subscriptions/{id}/auto-top-up"
payload = {
"enabled": True,
"threshold": 1073741823,
"quantity": 1073741824,
"amount": 1073741824,
"maxPerPeriod": 50
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://commet.co/api/v1/subscriptions/{id}/auto-top-up"
payload := strings.NewReader("{\n \"enabled\": true,\n \"threshold\": 1073741823,\n \"quantity\": 1073741824,\n \"amount\": 1073741824,\n \"maxPerPeriod\": 50\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("x-api-key", "<api-key>")
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://commet.co/api/v1/subscriptions/{id}/auto-top-up")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"enabled\": true,\n \"threshold\": 1073741823,\n \"quantity\": 1073741824,\n \"amount\": 1073741824,\n \"maxPerPeriod\": 50\n}")
.asString();<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://commet.co/api/v1/subscriptions/{id}/auto-top-up",
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([
'enabled' => true,
'threshold' => 1073741823,
'quantity' => 1073741824,
'amount' => 1073741824,
'maxPerPeriod' => 50
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}{
"success": true,
"data": {
"enabled": true,
"threshold": 0,
"quantity": 0,
"amount": 0,
"maxPerPeriod": 0,
"status": "active",
"topUpsThisPeriod": 0,
"periodResetsAt": "2023-11-07T05:31:56Z",
"lastFailure": {
"reason": "payment_declined",
"at": "2023-11-07T05:31:56Z"
},
"object": "subscription",
"livemode": true
}
}{
"success": false,
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"param": "<string>",
"details": "<unknown>"
}
}{
"success": false,
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"param": "<string>",
"details": "<unknown>"
}
}{
"success": false,
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"param": "<string>",
"details": "<unknown>"
}
}{
"success": false,
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"param": "<string>",
"details": "<unknown>"
}
}{
"success": false,
"error": {
"type": "<string>",
"code": "<string>",
"message": "<string>",
"doc_url": "<string>",
"param": "<string>",
"details": "<unknown>"
}
}This reference describes API version
2026-05-25. Send Commet-Version: 2026-05-25 with your request.Headers
Body
application/json
Was this page helpful?