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 →

Subscriptions

A subscription puts a customer on a plan and bills it period after period. This page covers its statuses, what changes them, how billing periods are dated, and what happens when the plan changes or the subscription is canceled.

A subscription holds one plan, set when it is created (plan_id). The plan’s base fee is charged once each period, and usage is billed by the plan’s prices. To bill a customer for two plans, create two subscriptions. A customer has at most one active subscription on a plan, and two may not bill the same meter.

Status What it means What you do
active Billing, period after period. Nothing.
canceled Ended. It never bills again, and it cannot be restarted. Create a new subscription to bill the customer again.

A subscription starts when it is created, so there is no status for one that is set up now and billed later. Create the subscription when it should bill. A plan billed in advance is invoiced when the subscription is created.

All the routes are under /v1/subscriptions. Each change sends a webhook.

From Caused by Webhook To
(new) POST / subscription.created active
active POST /{id}/cancel subscription.canceled canceled
active POST /{id}/schedule-cancel subscription.cancel_scheduled no change yet
active Hardcount, when the period a cancel is scheduled for ends subscription.canceled canceled
active DELETE /{id}/scheduled-cancel subscription.cancel_cleared no change
active Hardcount, when the payment retries for an unpaid invoice (dunning) run out and the dunning policy says cancel subscription.canceled canceled

A subscription bills whether or not the customer has saved a card. Its first invoice is collected like any other. Once email is set up, a customer with no card gets an email:

  • with a link to add a card, when Stripe is connected and PAYMENT_UPDATE_URL and PAYMENT_UPDATE_RETURN_URL are set;
  • with the invoice itself, when Stripe is not connected.

With Stripe connected and either address unset, the first email is the reminder of the first payment retry, which asks the customer to pay the invoice.

A billing period is the stretch of time one invoice covers. It includes its start and not its end. Periods start and end at midnight in your account’s billing timezone (a setting, UTC unless you change it).

A plan bills monthly or yearly. billing_time on the subscription sets the day monthly periods start on:

  • calendar, the default: the 1st of each month. A subscription that starts on June 18 has a short first period, June 18 to July 1, then July 1 to August 1, and so on.
  • anniversary: the day the subscription started. A subscription that starts on June 18 bills June 18 to July 18, then July 18 to August 18.

Yearly plans always bill on the anniversary.

When the start day does not exist in a month, the period starts on that month’s last day, and goes back to the start day when it can. A subscription that starts on January 31, on anniversary billing, bills:

Period Start End
1 January 31 February 28 (February 29 in a leap year)
2 February 28 March 31
3 March 31 April 30
4 April 30 May 31

To move a subscription to another plan, send POST /v1/subscriptions/{id}/schedule-plan-change with {"plan_id": "hc_pln_…"}. The change applies at the end of the current period:

  • Hardcount sends subscription.pending_change.scheduled, and the subscription shows the new plan in pending_plan_id and when it applies in pending_plan_effective_at.
  • When the period ends, Hardcount bills it on the current plan, then moves the subscription and sends subscription.pending_change.applied. The next period is billed on the new plan.
  • Cancel the change before then with DELETE /v1/subscriptions/{id}/scheduled-plan-change.

Nothing is charged or credited when you schedule the change, so no money moves in the middle of a period.

To move a customer to another plan now, cancel the subscription now (see Cancel), which bills the usage so far, and create a new subscription on the other plan.

  • Now: POST /v1/subscriptions/{id}/cancel. Hardcount makes a final invoice for the part of the period so far: usage, and a base fee billed in arrears for those days. It collects that invoice like any other.
    • A base fee billed in advance is kept, paid or not. The cancel changes no invoice that already exists: an unpaid one stays owed and its payment retries go on, and a draft stays a draft until it is finalized.
    • To give money back, issue a credit note on the invoice, or grant credit with POST /v1/credits/grant.
  • At the end of the period: POST /v1/subscriptions/{id}/schedule-cancel, with no body. Until then the subscription bills as usual. The period’s invoice is its last: it bills the period as usual, and a base fee billed in advance is not billed for the next period. The customer gave notice, and what they paid for the period is used up.
    • DELETE /v1/subscriptions/{id}/scheduled-cancel undoes it, until the period ends.
    • A body is refused with 422.

Before a change: the ended period is billed first

Section titled “Before a change: the ended period is billed first”

Each change above first bills any period that has already ended, then applies the change. If that period cannot be billed, the change is refused with 409 unbilled_period, and nothing changes.

A cancel now that finds an ended period not billed yet bills it first, as the billing run would have. With plans that bill a base fee in advance, that bills the fee for the period the cancel lands in, and the fee is kept. To end a subscription without it, cancel before the period ends, or schedule the cancel at the period’s end.

Next: the invoice a period becomes: Invoices. More: every route and field is in the API reference.

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