# Cancel a contract

`POST https://app.shuttleglobal.com/c/api/instances/{instance_key}/contracts/{contract_id}/cancel`

Cancelling a contract will prevent future charges being created on a contract and stop all
automated payments. A contract may still have an outstanding balance at time of cancellation.

## Authentication

- basicAuth: Basic Authentication using secret key
- bearerAuth: OAuth 2.0 Bearer Token Authentication

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `contract_id` | path | string | yes | The contract's ID (`co_...`), or the `alt_key` you gave it. |

## Request body (`application/json`), required

- `write_off` (boolean): If any outstanding amount should be written off. If not and there's an outstanding amount, the contract will transition to CANCELLING status
- `cancel_retries` (boolean): If automatic retries should be stopped for any outstanding amount. This will set next_payment to blank
- `strict` (boolean): If true, reject the cancellation when a transaction is in progress on the contract. Use when you need certainty that no further payment will be allocated after cancellation. Defaults to false, in which case the cancellation proceeds and any in-progress transaction resolves independently.

## Responses

### 200: Updated contract

```json
{
  "contract": {
    "account": "string",
    "alt_key": "string",
    "amount": "string",
    "channel": "string",
    "completed": "2026-01-01T12:00:00Z",
    "created": "2026-01-01T12:00:00Z",
    "currency": "string",
    "description": "string",
    "designation": "string",
    "frequency": "WEEKLY",
    "gateway": "string",
    "id": "string",
    "initiated": "2026-01-01T12:00:00Z",
    "initiative": "string",
    "keep_active_until": "2026-01-01T12:00:00Z",
    "last_charge": "string",
    "last_transaction": "string",
    "legal_entity": "string",
    "metadata": {
      "order_id": "12345",
      "customer_reference": "CUS-001"
    },
    "next_contract": "string",
    "next_payment": "2026-01-01T12:00:00Z",
    "nonce": "string",
    "account_alt_key": "string",
    "charge_count": 0,
    "event_date": "2026-01-01T12:00:00Z",
    "outstanding_amount": "string",
    "payment_method": "string",
    "recurring": true,
    "retry_complete": true,
    "retry_count": 0,
    "status": "SETUP",
    "updated": "2026-01-01T12:00:00Z"
  }
}
```

### 400: Bad request

```json
{
  "code": "string",
  "message": "string"
}
```

### 401: Unauthorised: the API key is missing or not valid

```json
{
  "code": "UNAUTHORIZED",
  "message": "Unauthorised"
}
```

## Example request

```sh
curl --request POST \
  --url https://app.shuttleglobal.com/c/api/instances/YOUR_INSTANCE_KEY/contracts/CONTRACT_ID/cancel \
  --header 'Authorization: Basic <base64 of SECRET_KEY:>' \
  --header 'Content-Type: application/json' \
  --data '{}'
```

Reference page: https://docs.shuttleglobal.com/merchants/reference/operations/cancelcontract/