curl --request PATCH \
--url https://api.sandbox.cheqpay.mx/pos/v1/subscriptions/{id} \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--header 'x-merchant-id: <api-key>' \
--data '
{
"paymentMethodId": "123e4567-e89b-12d3-a456-426614174003",
"cancelAtPeriodEnd": true,
"metadata": {}
}
'import requests
url = "https://api.sandbox.cheqpay.mx/pos/v1/subscriptions/{id}"
payload = {
"paymentMethodId": "123e4567-e89b-12d3-a456-426614174003",
"cancelAtPeriodEnd": True,
"metadata": {}
}
headers = {
"x-api-key": "<api-key>",
"x-merchant-id": "<api-key>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {
'x-api-key': '<api-key>',
'x-merchant-id': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
paymentMethodId: '123e4567-e89b-12d3-a456-426614174003',
cancelAtPeriodEnd: true,
metadata: {}
})
};
fetch('https://api.sandbox.cheqpay.mx/pos/v1/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.sandbox.cheqpay.mx/pos/v1/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([
'paymentMethodId' => '123e4567-e89b-12d3-a456-426614174003',
'cancelAtPeriodEnd' => true,
'metadata' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>",
"x-merchant-id: <api-key>"
],
]);
$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.sandbox.cheqpay.mx/pos/v1/subscriptions/{id}"
payload := strings.NewReader("{\n \"paymentMethodId\": \"123e4567-e89b-12d3-a456-426614174003\",\n \"cancelAtPeriodEnd\": true,\n \"metadata\": {}\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("x-merchant-id", "<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://api.sandbox.cheqpay.mx/pos/v1/subscriptions/{id}")
.header("x-api-key", "<api-key>")
.header("x-merchant-id", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"paymentMethodId\": \"123e4567-e89b-12d3-a456-426614174003\",\n \"cancelAtPeriodEnd\": true,\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sandbox.cheqpay.mx/pos/v1/subscriptions/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["x-api-key"] = '<api-key>'
request["x-merchant-id"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"paymentMethodId\": \"123e4567-e89b-12d3-a456-426614174003\",\n \"cancelAtPeriodEnd\": true,\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": "123e4567-e89b-12d3-a456-426614174000",
"merchantId": "merchant_123",
"customerId": "123e4567-e89b-12d3-a456-426614174001",
"planId": "123e4567-e89b-12d3-a456-426614174002",
"paymentMethodId": "123e4567-e89b-12d3-a456-426614174003",
"status": "ACTIVE",
"currentPeriodStart": "2025-01-01T00:00:00.000Z",
"currentPeriodEnd": "2025-02-01T00:00:00.000Z",
"cancelAtPeriodEnd": false,
"nextBillingDate": "2025-02-01T00:00:00.000Z",
"createdAt": "2025-01-01T00:00:00.000Z",
"updatedAt": "2025-01-15T10:00:00.000Z",
"trialStart": "2025-01-01T00:00:00.000Z",
"trialEnd": "2025-01-15T00:00:00.000Z",
"canceledAt": null,
"endedAt": null,
"metadata": {},
"plan": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"amount": "<string>",
"currency": "<string>",
"interval": "DAY",
"intervalCount": 123
}
}{
"message": "Validation failed",
"errors": [
{
"field": "name",
"message": "Required"
}
]
}{
"message": "Invalid api key"
}{
"message": "Merchant not found"
}{
"message": "Error message"
}Update a subscription
Updates an existing subscription. Only payment method, cancel at period end flag, and metadata can be updated.
curl --request PATCH \
--url https://api.sandbox.cheqpay.mx/pos/v1/subscriptions/{id} \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--header 'x-merchant-id: <api-key>' \
--data '
{
"paymentMethodId": "123e4567-e89b-12d3-a456-426614174003",
"cancelAtPeriodEnd": true,
"metadata": {}
}
'import requests
url = "https://api.sandbox.cheqpay.mx/pos/v1/subscriptions/{id}"
payload = {
"paymentMethodId": "123e4567-e89b-12d3-a456-426614174003",
"cancelAtPeriodEnd": True,
"metadata": {}
}
headers = {
"x-api-key": "<api-key>",
"x-merchant-id": "<api-key>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {
'x-api-key': '<api-key>',
'x-merchant-id': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
paymentMethodId: '123e4567-e89b-12d3-a456-426614174003',
cancelAtPeriodEnd: true,
metadata: {}
})
};
fetch('https://api.sandbox.cheqpay.mx/pos/v1/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.sandbox.cheqpay.mx/pos/v1/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([
'paymentMethodId' => '123e4567-e89b-12d3-a456-426614174003',
'cancelAtPeriodEnd' => true,
'metadata' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>",
"x-merchant-id: <api-key>"
],
]);
$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.sandbox.cheqpay.mx/pos/v1/subscriptions/{id}"
payload := strings.NewReader("{\n \"paymentMethodId\": \"123e4567-e89b-12d3-a456-426614174003\",\n \"cancelAtPeriodEnd\": true,\n \"metadata\": {}\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("x-merchant-id", "<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://api.sandbox.cheqpay.mx/pos/v1/subscriptions/{id}")
.header("x-api-key", "<api-key>")
.header("x-merchant-id", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"paymentMethodId\": \"123e4567-e89b-12d3-a456-426614174003\",\n \"cancelAtPeriodEnd\": true,\n \"metadata\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.sandbox.cheqpay.mx/pos/v1/subscriptions/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["x-api-key"] = '<api-key>'
request["x-merchant-id"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"paymentMethodId\": \"123e4567-e89b-12d3-a456-426614174003\",\n \"cancelAtPeriodEnd\": true,\n \"metadata\": {}\n}"
response = http.request(request)
puts response.read_body{
"id": "123e4567-e89b-12d3-a456-426614174000",
"merchantId": "merchant_123",
"customerId": "123e4567-e89b-12d3-a456-426614174001",
"planId": "123e4567-e89b-12d3-a456-426614174002",
"paymentMethodId": "123e4567-e89b-12d3-a456-426614174003",
"status": "ACTIVE",
"currentPeriodStart": "2025-01-01T00:00:00.000Z",
"currentPeriodEnd": "2025-02-01T00:00:00.000Z",
"cancelAtPeriodEnd": false,
"nextBillingDate": "2025-02-01T00:00:00.000Z",
"createdAt": "2025-01-01T00:00:00.000Z",
"updatedAt": "2025-01-15T10:00:00.000Z",
"trialStart": "2025-01-01T00:00:00.000Z",
"trialEnd": "2025-01-15T00:00:00.000Z",
"canceledAt": null,
"endedAt": null,
"metadata": {},
"plan": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"amount": "<string>",
"currency": "<string>",
"interval": "DAY",
"intervalCount": 123
}
}{
"message": "Validation failed",
"errors": [
{
"field": "name",
"message": "Required"
}
]
}{
"message": "Invalid api key"
}{
"message": "Merchant not found"
}{
"message": "Error message"
}Authorizations
API key for authentication (required)
Merchant ID for identifying the merchant (required)
Path Parameters
Subscription unique identifier
Body
At least one field must be provided for update
Response
Subscription updated successfully
Unique subscription identifier
"123e4567-e89b-12d3-a456-426614174000"
Merchant identifier
"merchant_123"
Customer identifier
"123e4567-e89b-12d3-a456-426614174001"
Plan identifier
"123e4567-e89b-12d3-a456-426614174002"
Payment method identifier
"123e4567-e89b-12d3-a456-426614174003"
Subscription status
TRIALING, ACTIVE, PAST_DUE, CANCELED, UNPAID "ACTIVE"
Start of the current billing period
"2025-01-01T00:00:00.000Z"
End of the current billing period
"2025-02-01T00:00:00.000Z"
Whether the subscription will cancel at period end
false
Date of the next billing charge (trial end date while trialing, otherwise the current period end date)
"2025-02-01T00:00:00.000Z"
Creation timestamp
"2025-01-01T00:00:00.000Z"
Last update timestamp
"2025-01-15T10:00:00.000Z"
Trial period start date
"2025-01-01T00:00:00.000Z"
Trial period end date
"2025-01-15T00:00:00.000Z"
When the subscription was canceled
null
When the subscription ended
null
Additional metadata
Associated plan details
Show child attributes
Show child attributes