Skip to main content
POST
/
v1
/
subscriptions
/
checkout
JavaScript
import Hercules from '@usehercules/sdk';

const client = new Hercules({
  apiVersion: '2025-12-09',
  apiKey: process.env['HERCULES_API_KEY'], // This is the default and can be omitted
});

const response = await client.beta.subscriptions.checkout({ customer_id: 'customer_id', plan_id: 'plan_id' });

console.log(response.id);
{
  "id": "<string>",
  "url": "<string>"
}

Authorizations

Authorization
string
header
required

API key authentication. Include your API key in the Authorization header as: Bearer

Body

application/json

Create a checkout session for a customer to subscribe to a plan. For plan changes on existing subscriptions, customers should use the billing portal.

customer_id
string
required

The customer ID

plan_id
string
required

The plan ID to subscribe to

success_url
string<uri>

URL to redirect on success

cancel_url
string<uri>

URL to redirect on cancel

Response

200 - application/json

The checkout session containing the URL to redirect the customer to

Checkout session response

id
string
required

The checkout session ID

url
string
required

The checkout URL to redirect the customer to