---
title: "Cancel the subscription at the end of the paid period"
method: POST
path: "/v2/workspaces/{id}/billing/cancel"
tags: ["Billing"]
---

# Cancel the subscription at the end of the paid period

`POST /v2/workspaces/{id}/billing/cancel`

## Request

- Base URL: `https://api.infolang.ai`
- URL: `https://api.infolang.ai/v2/workspaces/{id}/billing/cancel`
- Auth: one of:
  - HTTP bearer
  - HTTP bearer
  - HTTP bearer

Schedules the workspace owner's subscription to end when the period they have already paid for does — `cancel_at_period_end`, never an immediate deletion.

The account STAYS ON ITS PAID PLAN until `current_period_end`: the billing summary keeps reporting that plan with `cancel_at_period_end: true`, and only drops to `free` when Stripe's `customer.subscription.deleted` arrives at the boundary. Render it as “your <plan> ends on <date>”, not as “you are on free”.

To reverse a pending cancellation, send the customer to the billing portal. `enterprise` is contracted and cannot be cancelled here.

The response reports what STRIPE accepted. `plan` on the billing summary is written by the `customer.subscription.*` webhook a moment later, so a summary fetched in the same breath may still report the old plan — render the value returned here and re-fetch the summary shortly after, rather than treating the lag as a failure.

Requires the `billing:write` scope. Accepts all three lanes: a session JWT (bounded by the caller's role on this workspace) or an `il_*` machine credential whose own scope set, workspace set and validity window cover it — both ceilings apply and neither can raise the other, so a credential carrying `billing:write` is still refused where the role does not permit it.

A credential with no scope record resolves to `LEGACY_DEFAULT`, which does NOT include `billing:write` — mint a key with it explicitly (`POST /v2/workspaces/{id}/keys`).

## Path parameters

- `id` string, required

## Response `200`

The subscription after the cancel

- object
  - `plan` string, required
  - `cancel_at_period_end` boolean, required
  - `current_period_end` string, nullable, required

## Other responses

- `401`: Missing/invalid credential, or `credential_expired` — the credential is outside its `[not_before, expires_at)` window and must be replaced
- `403`: `insufficient_scope` — the credential's own scope set, or the caller's role on this workspace, does not cover the scope this route requires (the missing scope is named in the message). Or `forbidden` — the credential is not scoped to this workspace, or holds no grant on it
- `409`: no_subscription — this account holds no live Stripe subscription, so there is nothing to switch or cancel. Start one with the checkout route.
- `422`: invalid_request — this account is on `enterprise`, which is contracted and not cancellable through the self-serve path.
- `500`: internal_error — unexpected failure (e.g. billing backend misconfigured or unreachable)
- `503`: not_configured — self-serve billing is not available on this deployment: either no payment processor is wired, or its prices do not reconcile with the published catalog. Returned INSTEAD of a checkout URL, because the alternatives were a link to a domain that does not resolve and a checkout that charges an amount the page never showed. Mirrors `self_serve_checkout` on both summaries exactly — same evaluation, same cache.

---

[API](https://skmtc.dev/infolang/apis/infolang-api.md) · [All operations](https://skmtc.dev/infolang/apis/infolang-api/llms.txt) · [OpenAPI document](https://skmtc.dev/infolang/apis/infolang-api/revisions/d04bf6de72c8?raw)
