Skip to content
Hardcount
Run it locally
Pre-1.0 · one maintainer · Stripe and cards only · no SDKs (client libraries) yet · no production users yet. Docs describe v0.12.0 (30 Nov 2026) · What’s new →

Cancel a scheduled plan change

DELETE
/v1/subscriptions/{id}/scheduled-plan-change
curl --request DELETE \
--url http://localhost:8080/v1/subscriptions/hc_sub_dauq502q3gpgqfoq5c2g/scheduled-plan-change \
--header 'Authorization: Bearer <token>'

Cancels the scheduled plan change, sends the subscription.pending_change.canceled webhook event and writes an audit log entry. Calling it on a subscription with no scheduled change returns the subscription unchanged, sends no event and records nothing.

If the period has already ended, or the change took effect while the request ran, the request answers 409.

id
required
string

The subscription’s ID (hc_sub_…).

Example

hc_sub_dauq502q3gpgqfoq5c2g

The subscription with no scheduled plan change.

Media typeapplication/json

A customer’s subscription: the plan it bills, a plan change scheduled for the end of the current period, its status and its current billing period. Every route under /v1/subscriptions that returns a subscription returns this object.

A subscription bills in one currency, the currency of its plan. A customer who needs two plans has two subscriptions. A customer has at most one active subscription on a plan, and two may not bill the same meter. Usage, and a base fee billed in arrears, are invoiced when a period ends. A base fee billed in advance is invoiced when its period starts: the first one in the same transaction that creates the subscription, each later one on the invoice that closes the period before.

object
id
required

The subscription’s ID (hc_sub_…).

string
tenant_id

The account the subscription belongs to.

string
code
required

Your code for the subscription: letters, digits, hyphens and underscores. Unique in your account and mode (live or test).

string
display_name
required

The subscription’s name, as shown in the dashboard.

string
customer_id
required

The customer the subscription bills (hc_cus_…).

string
plan_id

The plan the subscription bills now (hc_pln_…): its base fee and its usage prices. A scheduled plan change shows in pending_plan_id until it takes effect. Absent only on a canceled subscription that an earlier release left with no plan.

string
pending_plan_id

The plan the subscription moves to at pending_plan_effective_at (hc_pln_…). Absent when no change is scheduled.

string
pending_plan_effective_at

When the scheduled plan change takes effect: the end of the period in which it was scheduled. Absent when no change is scheduled.

string format: date-time
status
required

Where the subscription is in its life.

  • active: billing, from the start of the day it is created (in the account’s time zone). Usage and base fees billed in arrears are invoiced when each period ends; a base fee billed in advance when its period starts.
  • canceled: ended at canceled_at. It bills nothing more, and no route makes it active again. A subscription canceled before it started has no started_at and no billing period.
string
Allowed values: active canceled
billing_time
required

How monthly periods line up. The first period starts on the day the subscription is created. calendar: every period ends on the 1st of a month, in your account’s billing time zone, so the first period runs from that day to the next 1st. anniversary: each period starts on the same day of the month as the first one (the last day of a shorter month). A plan billed yearly always bills a year from that first day, whatever this says.

string
Allowed values: calendar anniversary
started_at

The moment the subscription was created. Its first period, and the usage it bills, start at the beginning of that day in the account’s time zone. A subscription that an earlier release activated from a draft has the moment of that activation instead.

string format: date-time
canceled_at

When the subscription was canceled. Absent until then.

string format: date-time
cancel_at_period_end
required

True when the subscription cancels at the end of the current period. False after the subscription is canceled.

boolean
cancel_effective_at

When a scheduled cancel takes effect: with cancel_at_period_end, current_billing_period_end. Absent when no cancel is scheduled.

string format: date-time
current_billing_period_start

Start of the current billing period, the beginning of a day in your account’s billing time zone. On a canceled subscription it keeps its last value.

string format: date-time
current_billing_period_end

End of the current period (exclusive): the start of the next one. On a canceled subscription it keeps its last value.

string format: date-time
current_billing_period_display

The current period as text, with the last day included, in your account’s billing time zone, for example “Oct 1, 2026 – Oct 31, 2026”. Absent when the subscription has no current period, or when the time zone could not be read.

string
next_billing_at

When the current period’s invoice is due to be built: the end of the current period. The billing run builds it once the invoice grace after that time has passed. A canceled subscription keeps its last value, and nothing is billed at that time.

string format: date-time
billing_anchor_day

Day of the month the subscription bills on (1-31): the day its first period started, or the day an earlier release switched it to a plan with another billing interval. Absent for calendar-monthly subscriptions.

integer
billing_failure

Present on a subscription while the billing run is failing on the work that subscription has due now: the close of its current period, which also cancels it when a cancel is scheduled. Absent otherwise: a subscription that bills cleanly, or whose due work changed, carries no billing_failure.

After each failed attempt the billing run waits before the next one: 15 minutes, 1 hour, 4 hours, 12 hours, then 24 hours three times. The eighth failure parks the subscription (parked: true, no next_attempt_at). A parked subscription is not attempted again until POST /v1/subscriptions/{id}/retry-billing is called.

object
attempts
required

Failed attempts on the work that is due now. At least 1.

integer
max_attempts
required

The attempt at which the subscription parks (8).

integer
last_error
required

Why the latest attempt failed: a sentence an operator can act on, or a generic line carrying the subscription id as the reference to search the server log for. Never raw error text.

string
failed_at
required

When the latest attempt failed.

string format: date-time
next_attempt_at

The billing run does not attempt the subscription before this instant. The attempt happens on the first run at or after it, so on an hourly schedule it can be up to an hour later. Absent when parked.

string format: date-time
parked
required

True when automatic attempts have stopped.

boolean
created_at
required

When the subscription was created.

string format: date-time
updated_at
required

When the subscription last changed.

string format: date-time

Example

{
"id": "hc_sub_dauq502q3gpgqfoq5c2g",
"tenant_id": "hc_ten_dajqj02q3gpgqfoq5c00",
"code": "acme-pro",
"display_name": "Acme Pro",
"customer_id": "hc_cus_dakhnk2q3gpgqfoq5c0g",
"plan_id": "hc_pln_dajr5o2q3gpgqfoq5c1g",
"status": "active",
"billing_time": "calendar",
"started_at": "2026-10-01T09:12:44Z",
"cancel_at_period_end": false,
"current_billing_period_start": "2026-10-01T00:00:00Z",
"current_billing_period_end": "2026-11-01T00:00:00Z",
"current_billing_period_display": "Oct 1, 2026 – Oct 31, 2026",
"next_billing_at": "2026-11-01T00:00:00Z",
"created_at": "2026-10-01T09:12:44Z",
"updated_at": "2026-10-18T13:05:00Z"
}

The body is not one valid JSON value, it is not a JSON object, it is empty where the operation needs one, or a field has the wrong JSON type (such as a string where a number belongs). This answer is not kept for an Idempotency-Key: send the corrected request with the same key.

Media typeapplication/json

The body of an error answer. error.type is the broad class, error.code is the exact reason for your code to branch on, and error.message is a sentence for a person. Quote error.request_id when you ask for help.

object
error

What went wrong.

object
type
required

One of invalid_request_error, authentication_error, rate_limit_error or api_error. Every error the API answers has this shape, including an unknown path (404, code route_not_found) and a method the path does not take (405, code method_not_allowed, with an Allow header). The few exceptions are listed in Errors.

string
code
required

The exact reason, such as validation_error, not_found, already_exists, invalid_state or a more specific code the operation lists. Branch on this, not on message.

string
message
required

What went wrong, written for a person to read.

string
request_id
required

The id of the request that produced this answer (req_…). It is normally the same value as the Hardcount-Request-Id response header. On an answer replayed for a repeated Idempotency-Key, the body is the first request’s, so this is the first request’s id, while the Hardcount-Request-Id header holds the new request’s id.

string
param

The request field or query parameter the error is about. Sent only when the error names one.

A request body may hold only the fields its operation lists, spelled and cased as listed. Any other field, or one the server sets (such as id), is refused with 422 and param naming it. An operation with no request body lists no fields: send no body, {} or null. The Stripe and Postmark webhooks and the LiteLLM callback take their sender’s body as it comes.

string

Example

{
"error": {
"type": "invalid_request_error",
"code": "invalid_request",
"message": "invalid JSON body",
"request_id": "req_dbjg652q3gpgqfoq5cd0"
}
}

No valid credential: the API key or session is missing, wrong, expired or revoked. With no API key and no valid session cookie, the message starts with missing credentials. A wrong, expired and revoked key all get the same message, invalid or expired API key.

Media typeapplication/json

The body of an error answer. error.type is the broad class, error.code is the exact reason for your code to branch on, and error.message is a sentence for a person. Quote error.request_id when you ask for help.

object
error

What went wrong.

object
type
required

One of invalid_request_error, authentication_error, rate_limit_error or api_error. Every error the API answers has this shape, including an unknown path (404, code route_not_found) and a method the path does not take (405, code method_not_allowed, with an Allow header). The few exceptions are listed in Errors.

string
code
required

The exact reason, such as validation_error, not_found, already_exists, invalid_state or a more specific code the operation lists. Branch on this, not on message.

string
message
required

What went wrong, written for a person to read.

string
request_id
required

The id of the request that produced this answer (req_…). It is normally the same value as the Hardcount-Request-Id response header. On an answer replayed for a repeated Idempotency-Key, the body is the first request’s, so this is the first request’s id, while the Hardcount-Request-Id header holds the new request’s id.

string
param

The request field or query parameter the error is about. Sent only when the error names one.

A request body may hold only the fields its operation lists, spelled and cased as listed. Any other field, or one the server sets (such as id), is refused with 422 and param naming it. An operation with no request body lists no fields: send no body, {} or null. The Stripe and Postmark webhooks and the LiteLLM callback take their sender’s body as it comes.

string

Example

{
"error": {
"type": "authentication_error",
"code": "unauthorized",
"message": "invalid or expired API key",
"request_id": "req_dbjg652q3gpgqfoq5cd0"
}
}

The credential is valid but may not call this route. A usage-only key (hc_ingest_…) can only send usage, read a customer’s live credit balance and call GET /v1/whoami; use a secret key. The message names the permission the key lacks. A browser request that would change data (POST, PUT, PATCH or DELETE) from a page on another site gets this 403 too, with the message cross-site request blocked.

Media typeapplication/json

The body of an error answer. error.type is the broad class, error.code is the exact reason for your code to branch on, and error.message is a sentence for a person. Quote error.request_id when you ask for help.

object
error

What went wrong.

object
type
required

One of invalid_request_error, authentication_error, rate_limit_error or api_error. Every error the API answers has this shape, including an unknown path (404, code route_not_found) and a method the path does not take (405, code method_not_allowed, with an Allow header). The few exceptions are listed in Errors.

string
code
required

The exact reason, such as validation_error, not_found, already_exists, invalid_state or a more specific code the operation lists. Branch on this, not on message.

string
message
required

What went wrong, written for a person to read.

string
request_id
required

The id of the request that produced this answer (req_…). It is normally the same value as the Hardcount-Request-Id response header. On an answer replayed for a repeated Idempotency-Key, the body is the first request’s, so this is the first request’s id, while the Hardcount-Request-Id header holds the new request’s id.

string
param

The request field or query parameter the error is about. Sent only when the error names one.

A request body may hold only the fields its operation lists, spelled and cased as listed. Any other field, or one the server sets (such as id), is refused with 422 and param naming it. An operation with no request body lists no fields: send no body, {} or null. The Stripe and Postmark webhooks and the LiteLLM callback take their sender’s body as it comes.

string

Example

{
"error": {
"type": "authentication_error",
"code": "forbidden",
"message": "insufficient permissions: this key type does not have customer:read access",
"request_id": "req_dbjg652q3gpgqfoq5cd0"
}
}

No subscription with this ID in this account and mode.

Media typeapplication/json

The body of an error answer. error.type is the broad class, error.code is the exact reason for your code to branch on, and error.message is a sentence for a person. Quote error.request_id when you ask for help.

object
error

What went wrong.

object
type
required

One of invalid_request_error, authentication_error, rate_limit_error or api_error. Every error the API answers has this shape, including an unknown path (404, code route_not_found) and a method the path does not take (405, code method_not_allowed, with an Allow header). The few exceptions are listed in Errors.

string
code
required

The exact reason, such as validation_error, not_found, already_exists, invalid_state or a more specific code the operation lists. Branch on this, not on message.

string
message
required

What went wrong, written for a person to read.

string
request_id
required

The id of the request that produced this answer (req_…). It is normally the same value as the Hardcount-Request-Id response header. On an answer replayed for a repeated Idempotency-Key, the body is the first request’s, so this is the first request’s id, while the Hardcount-Request-Id header holds the new request’s id.

string
param

The request field or query parameter the error is about. Sent only when the error names one.

A request body may hold only the fields its operation lists, spelled and cased as listed. Any other field, or one the server sets (such as id), is refused with 422 and param naming it. An operation with no request body lists no fields: send no body, {} or null. The Stripe and Postmark webhooks and the LiteLLM callback take their sender’s body as it comes.

string

Example

{
"error": {
"type": "invalid_request_error",
"code": "not_found",
"message": "subscription not found",
"request_id": "req_dbjg652q3gpgqfoq5cd0"
}
}

Code invalid_state: the change already took effect when the billing period ended. Code unbilled_period: a billing period ended and could not be invoiced; retry billing first.

Media typeapplication/json

The body of an error answer. error.type is the broad class, error.code is the exact reason for your code to branch on, and error.message is a sentence for a person. Quote error.request_id when you ask for help.

object
error

What went wrong.

object
type
required

One of invalid_request_error, authentication_error, rate_limit_error or api_error. Every error the API answers has this shape, including an unknown path (404, code route_not_found) and a method the path does not take (405, code method_not_allowed, with an Allow header). The few exceptions are listed in Errors.

string
code
required

The exact reason, such as validation_error, not_found, already_exists, invalid_state or a more specific code the operation lists. Branch on this, not on message.

string
message
required

What went wrong, written for a person to read.

string
request_id
required

The id of the request that produced this answer (req_…). It is normally the same value as the Hardcount-Request-Id response header. On an answer replayed for a repeated Idempotency-Key, the body is the first request’s, so this is the first request’s id, while the Hardcount-Request-Id header holds the new request’s id.

string
param

The request field or query parameter the error is about. Sent only when the error names one.

A request body may hold only the fields its operation lists, spelled and cased as listed. Any other field, or one the server sets (such as id), is refused with 422 and param naming it. An operation with no request body lists no fields: send no body, {} or null. The Stripe and Postmark webhooks and the LiteLLM callback take their sender’s body as it comes.

string

Example

{
"error": {
"type": "invalid_request_error",
"code": "invalid_state",
"message": "the pending plan change already took effect when the billing period ended",
"request_id": "req_dbjg652q3gpgqfoq5cd0"
}
}

The body is over the 1 MB limit. Send a smaller body. The answer is the same with or without an Idempotency-Key, and it is not kept for the key: the same key works for the smaller request.

Media typeapplication/json

The body of an error answer. error.type is the broad class, error.code is the exact reason for your code to branch on, and error.message is a sentence for a person. Quote error.request_id when you ask for help.

object
error

What went wrong.

object
type
required

One of invalid_request_error, authentication_error, rate_limit_error or api_error. Every error the API answers has this shape, including an unknown path (404, code route_not_found) and a method the path does not take (405, code method_not_allowed, with an Allow header). The few exceptions are listed in Errors.

string
code
required

The exact reason, such as validation_error, not_found, already_exists, invalid_state or a more specific code the operation lists. Branch on this, not on message.

string
message
required

What went wrong, written for a person to read.

string
request_id
required

The id of the request that produced this answer (req_…). It is normally the same value as the Hardcount-Request-Id response header. On an answer replayed for a repeated Idempotency-Key, the body is the first request’s, so this is the first request’s id, while the Hardcount-Request-Id header holds the new request’s id.

string
param

The request field or query parameter the error is about. Sent only when the error names one.

A request body may hold only the fields its operation lists, spelled and cased as listed. Any other field, or one the server sets (such as id), is refused with 422 and param naming it. An operation with no request body lists no fields: send no body, {} or null. The Stripe and Postmark webhooks and the LiteLLM callback take their sender’s body as it comes.

string

Example

{
"error": {
"type": "invalid_request_error",
"code": "payload_too_large",
"message": "The request body is larger than the 1 MB limit. Send a smaller body.",
"request_id": "req_dbjg652q3gpgqfoq5cd0"
}
}

The request has a body with a field (param names it). This route takes no body: send none, {} or null.

Media typeapplication/json

The body of an error answer. error.type is the broad class, error.code is the exact reason for your code to branch on, and error.message is a sentence for a person. Quote error.request_id when you ask for help.

object
error

What went wrong.

object
type
required

One of invalid_request_error, authentication_error, rate_limit_error or api_error. Every error the API answers has this shape, including an unknown path (404, code route_not_found) and a method the path does not take (405, code method_not_allowed, with an Allow header). The few exceptions are listed in Errors.

string
code
required

The exact reason, such as validation_error, not_found, already_exists, invalid_state or a more specific code the operation lists. Branch on this, not on message.

string
message
required

What went wrong, written for a person to read.

string
request_id
required

The id of the request that produced this answer (req_…). It is normally the same value as the Hardcount-Request-Id response header. On an answer replayed for a repeated Idempotency-Key, the body is the first request’s, so this is the first request’s id, while the Hardcount-Request-Id header holds the new request’s id.

string
param

The request field or query parameter the error is about. Sent only when the error names one.

A request body may hold only the fields its operation lists, spelled and cased as listed. Any other field, or one the server sets (such as id), is refused with 422 and param naming it. An operation with no request body lists no fields: send no body, {} or null. The Stripe and Postmark webhooks and the LiteLLM callback take their sender’s body as it comes.

string

Example

{
"error": {
"type": "invalid_request_error",
"code": "validation_error",
"message": "unknown field \"plan_id\"",
"request_id": "req_dbjg652q3gpgqfoq5cd0",
"param": "plan_id"
}
}

Too many requests. Wait for the number of seconds in Retry-After, then retry. The answers that pass the limit carry the X-RateLimit-* headers too.

Each API key has its own limit, by default 1,000 requests a minute (HARDCOUNT_RATE_LIMIT_GENERAL_PER_MIN), and 1,000 a second on the usage routes (HARDCOUNT_RATE_LIMIT_INGEST_PER_SEC). The dashboard sessions of one account share one limit per mode. The routes under /v1/auth and /v1/bootstrap (sign-in, password reset, invite accept, setup) count per client address, by default 100 a minute (HARDCOUNT_RATE_LIMIT_AUTH_PER_MIN). The public invoice, payment-update and cost-dashboard pages allow 60 a minute per client address.

Media typeapplication/json

The body of an error answer. error.type is the broad class, error.code is the exact reason for your code to branch on, and error.message is a sentence for a person. Quote error.request_id when you ask for help.

object
error

What went wrong.

object
type
required

One of invalid_request_error, authentication_error, rate_limit_error or api_error. Every error the API answers has this shape, including an unknown path (404, code route_not_found) and a method the path does not take (405, code method_not_allowed, with an Allow header). The few exceptions are listed in Errors.

string
code
required

The exact reason, such as validation_error, not_found, already_exists, invalid_state or a more specific code the operation lists. Branch on this, not on message.

string
message
required

What went wrong, written for a person to read.

string
request_id
required

The id of the request that produced this answer (req_…). It is normally the same value as the Hardcount-Request-Id response header. On an answer replayed for a repeated Idempotency-Key, the body is the first request’s, so this is the first request’s id, while the Hardcount-Request-Id header holds the new request’s id.

string
param

The request field or query parameter the error is about. Sent only when the error names one.

A request body may hold only the fields its operation lists, spelled and cased as listed. Any other field, or one the server sets (such as id), is refused with 422 and param naming it. An operation with no request body lists no fields: send no body, {} or null. The Stripe and Postmark webhooks and the LiteLLM callback take their sender’s body as it comes.

string

Example

{
"error": {
"type": "rate_limit_error",
"code": "rate_limited",
"message": "too many requests — please retry after the rate limit resets",
"request_id": "req_dbjg652q3gpgqfoq5cd0"
}
}
Retry-After
integer
Example
12

Seconds to wait before the next request can pass, rounded up to a whole second and at least 1.

X-RateLimit-Limit
integer
Example
1000

How many requests the limit allows in its period (a minute, or a second on the usage routes).

X-RateLimit-Remaining
integer
Example
0

How many requests are left in the current period.

X-RateLimit-Reset
integer format: int64
Example
1793870460

When the whole limit is available again, as Unix seconds. One request may pass sooner; Retry-After says when.

Stuck, or found a bug? Ask in Discussions · Open an issue