# Cancel a plan or end the trial

> Cancel a plan at the end of its period or keep it again, and end the free trial early, from the console or the API.

Owners and Billing members change plans and the trial from the console's **Billing** page or the API below (an API key needs the `full_access` preset). Every member sees the outcome on the Billing page.

## Cancel a plan

Cancelling never ends a plan early. The plan keeps its allowance and limits until the end of the current period (`plan.period_end`), then ends and doesn't renew. After that, usage is paid from credits at pay-as-you-go limits.

```sh
curl -X POST "$VMYARD_API_URL/v1/billing/subscription/cancel" \
  -H "Authorization: Bearer $VMYARD_API_KEY"
```

The answer is the updated billing document: `plan.cancel_at_period_end` is `true` and `plan.renews` is `false`. The console asks for confirmation, then shows a banner with the date the plan ends.

To **keep the plan**, resume it before the period ends:

```sh
curl -X POST "$VMYARD_API_URL/v1/billing/subscription/resume" \
  -H "Authorization: Bearer $VMYARD_API_KEY"
```

Both change the subscription at the payment provider first and record the change only once the provider confirms it.

| Status | Code | Meaning |
| --- | --- | --- |
| 409 | `subscription_missing` | No renewing subscription is linked: none was bought, the plan was granted by an operator, or it already ended. |
| 502 | `payment_provider_error` | The payment provider didn't answer. Nothing changed; try again in a minute. |
| 503 | `billing_unavailable` | Online payments aren't configured on this deployment. |

Cancelling in the payment portal has the same effect.

## End the trial early

The trial's balance is spent before a plan's allowance. If you've just bought a plan, ending the trial lets you use the plan's allowance right away.

```sh
curl -X POST "$VMYARD_API_URL/v1/billing/trial/end" \
  -H "Authorization: Bearer $VMYARD_API_KEY"
```

> [!WARNING]
> The remaining trial balance is forfeited and can't be restored.

The answer is the billing document with `trial.ended_at` set and no trial balance left. Ending an ended trial changes nothing. The trial's **rules** (two machines, `small` and `default` sizes only) still apply until the first payment, so ending a trial without paying leaves nothing to spend and creates and starts answer `402 billing_required`.

You can also end the trial as part of buying a plan: send `end_trial: true` with a plan checkout, and the trial ends once the plan's first payment is confirmed. In the console, tick **End the trial when the plan starts** before choosing a plan. `end_trial` applies to plan checkouts only; with `credit_packs` it answers `422`.

```sh
curl -X POST "$VMYARD_API_URL/v1/billing/checkout" \
  -H "Authorization: Bearer $VMYARD_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"plan": "pro", "end_trial": true}'
```
