curl --request POST \
--url https://uat-api.clinkbill.com/api/billing/session \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--header 'X-Timestamp: <x-timestamp>' \
--data '
{
"customerId": "cus_xxxxx"
}
'{
"code": 200,
"msg": "success",
"data": {
"url": "https://uat-portal.clinkbill.com/session/eyJ0eXAiOffsssxxxxxx",
"expiresAt": 1755152165726
}
}Customer Portal
Customer Portal Session
Create a new customer portal session for billing management
POST
/
billing
/
session
curl --request POST \
--url https://uat-api.clinkbill.com/api/billing/session \
--header 'Content-Type: application/json' \
--header 'X-API-KEY: <api-key>' \
--header 'X-Timestamp: <x-timestamp>' \
--data '
{
"customerId": "cus_xxxxx"
}
'{
"code": 200,
"msg": "success",
"data": {
"url": "https://uat-portal.clinkbill.com/session/eyJ0eXAiOffsssxxxxxx",
"expiresAt": 1755152165726
}
}By default, the portal link in
data.url opens the portal home page. To send the customer straight to a specific page, append a redirectUrl query parameter to data.url before redirecting. Its value is the URL-encoded path of the target page. Examples of common paths (not a complete list):| Target page | redirectUrl path |
|---|---|
| Update a specific subscription | /subscription/{subscriptionId}/update |
| Add a payment method | /payment-methods/new |
| Update customer information | /customer/update |
// Server side: after calling POST /billing/session
const { url } = response.data;
const subscriptionId = 'sub_xxxxx';
const portalUrl = new URL(url);
// searchParams encodes the value automatically; no need to call encodeURIComponent
portalUrl.searchParams.set('redirectUrl', `/subscription/${subscriptionId}/update`);
// Return portalUrl.toString() to your frontend for redirection, or respond with a 302 redirect
// https://uat-portal.clinkbill.com/session/eyJ0eXAi...?redirectUrl=%2Fsubscription%2Fsub_xxxxx%2Fupdate
Always URL-encode the
redirectUrl value and make sure the resulting link is correct. An incorrect link leads to a 404 page.The example above is JavaScript, where searchParams encodes the value automatically. If you use another language (or don’t use searchParams), you need to encode the value yourself, for example with URLEncoder.encode(path, StandardCharsets.UTF_8) in Java or urllib.parse.quote(path, safe='') in Python. The encoded value should look like %2Fsubscription%2Fsub_xxxxx%2Fupdate. Encode it only once.Authorizations
Headers
Body
application/json
Parameters required to initialize a customer portal session
Response
200 - application/json
Customer portal session created successfully
Response object returned when creating a new checkout session