Skip to main content
POST
/
v1
/
subscriptions
/
cancel
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.cancel({
  customer_id: 'customer_id',
  subscription_id: 'subscription_id',
});

console.log(response.id);
{
  "id": "<string>",
  "status": "<string>",
  "cancellation_timing": "immediate",
  "canceled_at": "2023-11-07T05:31:56Z"
}

Authorizations

Authorization
string
header
required

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

Body

application/json

Cancel a customer subscription

customer_id
string
required

The customer ID

subscription_id
string
required

The subscription ID to cancel

cancellation_timing
enum<string>
default:at_billing_period_end

When to cancel the subscription. Defaults to 'at_billing_period_end' to allow customers to use remaining time.

Available options:
immediate,
at_billing_period_end

Response

200 - application/json

The canceled subscription object with updated status

Cancel subscription response

id
string
required

The subscription ID

status
string
required

The subscription status

cancellation_timing
enum<string>
required

When the cancellation takes effect

Available options:
immediate,
at_billing_period_end
canceled_at
string<date-time> | null

When the subscription was canceled