> ## Documentation Index
> Fetch the complete documentation index at: https://docs.khaime.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Cancel Installment Plan

> Stop collecting an installment plan.

# Cancel Installment Plan

## Intro

Cancels a plan: no more installments are collected. Paid installments are untouched.

## Context

Unpaid installments become `cancelled`, automatic collection stops, and `installment_plan.cancelled` is sent. To give money back for paid installments, refund them one by one with [Refunds](/payments/refunds) and `installment: { plan_id, position }`.

## Hows

`PATCH /installment-plans/{plan_id}/cancel`

### Response

The cancelled plan, in the same shape as [Get Installment Plan](/api-reference/installments/get):

```json theme={null}
{
  "status": true,
  "message": "Installment plan cancelled",
  "data": { "id": 812, "status": "cancelled", "installments": [ { "position": 1, "status": "paid" }, { "position": 2, "status": "cancelled" }, { "position": 3, "status": "cancelled" } ] }
}
```

Cancelling an already-cancelled plan returns it unchanged.

### Errors

| Status | `error_code`                 | Cause                         |
| ------ | ---------------------------- | ----------------------------- |
| 400    | `INSTALLMENT_NOT_ALLOWED`    | The plan is already completed |
| 404    | `INSTALLMENT_PLAN_NOT_FOUND` | No such plan for your key     |

<RequestExample>
  ```bash cURL theme={null}
  curl -X PATCH https://api.khaime.com/api/v1/installment-plans/812/cancel \
    -H "X-API-Key: pk_sandbox_your_key"
  ```
</RequestExample>

## Whys

Cancelling and refunding are separate so a business can stop future charges without deciding, in the same call, how much of what was already paid to return.

## Why nots

* It isn't reversible; start a new installment checkout if the customer wants to resume.
* It doesn't revoke the customer's access to the product.
