Skip to main content
PATCH
/
v2
/
subscriptions
/
{id}
Patch Subscriptions By ID
curl --request PATCH \
  --url https://api.pagou.ai/v2/subscriptions/{id} \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "metadata": {},
  "retry_offsets_days": [
    15
  ]
}
'
import requests

url = "https://api.pagou.ai/v2/subscriptions/{id}"

payload = {
"metadata": {},
"retry_offsets_days": [15]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

response = requests.patch(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({metadata: {}, retry_offsets_days: [15]})
};

fetch('https://api.pagou.ai/v2/subscriptions/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.pagou.ai/v2/subscriptions/{id}",
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([
'metadata' => [

],
'retry_offsets_days' => [
15
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.pagou.ai/v2/subscriptions/{id}"

payload := strings.NewReader("{\n \"metadata\": {},\n \"retry_offsets_days\": [\n 15\n ]\n}")

req, _ := http.NewRequest("PATCH", url, payload)

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://api.pagou.ai/v2/subscriptions/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"metadata\": {},\n \"retry_offsets_days\": [\n 15\n ]\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.pagou.ai/v2/subscriptions/{id}")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"metadata\": {},\n \"retry_offsets_days\": [\n 15\n ]\n}"

response = http.request(request)
puts response.read_body
{
  "success": true,
  "requestId": "<string>",
  "data": {
    "id": "<string>",
    "customerId": "<string>",
    "intervalCount": 183,
    "amount": 50000000,
    "trialEnd": "2023-11-07T05:31:56Z",
    "currentPeriodStart": "2023-11-07T05:31:56Z",
    "currentPeriodEnd": "2023-11-07T05:31:56Z",
    "cancelAtPeriodEnd": true,
    "canceledAt": "2023-11-07T05:31:56Z",
    "retryOffsetsDays": [
      15
    ],
    "customerEmail": "<string>",
    "cardLast4": "<string>",
    "metadata": {},
    "products": [
      {
        "name": "<string>",
        "price": 50000000,
        "quantity": 500000,
        "tangible": true,
        "sku": "<string>"
      }
    ],
    "createdAt": "2023-11-07T05:31:56Z",
    "updatedAt": "2023-11-07T05:31:56Z",
    "transactions": [
      {
        "id": "<string>",
        "status": "<string>",
        "amount": 50000000,
        "paidAmount": 50000000,
        "refundedAmount": 50000000,
        "externalRef": "<string>",
        "createdAt": "2023-11-07T05:31:56Z",
        "paidAt": "2023-11-07T05:31:56Z"
      }
    ]
  }
}
{
"error": "<string>",
"message": "<string>",
"status": 404
}
{
"type": "<string>",
"title": "<string>",
"status": 123,
"detail": "<string>",
"instance": "<string>",
"errors": [
{
"field": "<string>",
"message": "<string>",
"code": "<string>"
}
]
}
{
"type": "<string>",
"title": "<string>",
"status": 123,
"detail": "<string>",
"instance": "<string>"
}
Only metadata, failure_policy, and retry_offsets_days are editable. Other fields (interval, amount, currency, card) are immutable — create a new subscription to change them. A subscription.updated webhook is dispatched when the subscription changes.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

id
string<uuid>
required

Public subscription id (UUID).

Pattern: ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$

Body

application/json
metadata
object | null
failure_policy
enum<string>
Available options:
immediate_cancel,
retry_then_cancel
retry_offsets_days
integer[]
Required array length: 1 - 10 elements
Required range: 1 <= x <= 30

Response

Success

success
boolean
required
requestId
string
required
data
object
required