Skip to main content

Billing Portal

API Reference

The Billing Portal enables you to offer your customers a comprehensive billing experience, providing them with visibility into their balances, usage and top-up history. From here they can top up their accounts directly and manage their billing settings. More information on the billing portal can be found here.

Start a billing portal session

Your customers do not need to register for Credyt in order to use the billing portal. Instead, you manage their access by generating a billing portal session, once you have authenticated and validated the user within your service.

Let's open up the billing portal for the customer we've been working with:

POST https://api.credyt.ai/billing-portal/sessions
{
"customer_id": "{{customerId}}",
"return_url": "https://glitch.ai/account",
"failure_url": "https://glitch.ai/callbacks/credyt/failure"
}

Response

{
"redirect_url": "https://billing.credyt.ai/api/sign-in?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwdXJwb3NlIjoicG9ydGFsLXNlc3Npb24tcmVkaXJlY3QiLCJpc3N1ZWQiOiIyMDI1LTEwLTE4VDA3OjEzOjQzLjg0MDU3NjlaIiwicGxhdGZvcm1faWQiOiJhY2NfNHk3ZHh4cXQ4ZHp6cGY0dzU4dGUwMDF6eGIiLCJjdXN0b21lcl9pZCI6ImN1c3RfNG44YzRwZ2VuaDM0dmNtbmdkNzE2cWd2ZDUiLCJsaXZlX21vZGUiOiJmYWxzZSIsInJldHVybl91cmwiOiJodHRwczovL2dsaXRjaC5haS9hY2NvdW50IiwiZmFpbHVyZV91cmwiOiJodHRwczovL2dsaXRjaC5haS9jYWxsYmFja3MvY3JlZHl0L2ZhaWx1cmUiLCJleHAiOjE3NjA3NzIyMjMsImlzcyI6IkNyZWR5dC5BcGkiLCJhdWQiOiJDdXN0b21lclBvcnRhbCJ9.HgSOGKlZCbO4XgNXxLVkAmz44crjIF1V_wg195VkWs4",
"expires_at": "2025-10-18T07:23:43Z"
}

The redirect_url is a pre-authenticated URL where you send your customer. This link is valid for 10 minutes.

Return and Failure URLs

When creating a billing portal session you specify both the URL the customer should return to when exiting the portal (return_url) and the failure URL (failure_url) we will redirect them to if their session expires or there are any issues. You can find more about failure handling here.

If you navigate to this URL you should see their recently updated balance and usage.

Credyt's Billing Portal