# Cancel subscription
Source: https://docs.lomi.africa/api/subscriptions/SubscriptionsController_cancel

Cancel subscription

***

title: "Cancel subscription"
description: "Cancel subscription"
full: true
method: post
path: /subscriptions/{id}/cancel
operationId: SubscriptionsController\_cancel
--------------------------------------------

## Overview

Cancel subscription

Cancels an active subscription; optional reason is stored for analytics and chargeback context.

### When to use this

Use when the customer ends service or you enforce policy cancellations.

### See also

[Retrieve subscription](/api/subscriptions/SubscriptionsController_findOne)

## Authentication

Merchant routes require an API key in the `X-API-KEY` header (see [Integration overview](/api)). Use a **test** key against `https://sandbox.api.lomi.africa` and a **live** key against `https://api.lomi.africa`.

## Endpoint

`POST /subscriptions/{id}/cancel`

Base URLs:

* `https://sandbox.api.lomi.africa`
* `https://api.lomi.africa`

## Request

### Path parameters

| Name | Required | Schema | Description          |
| ---- | -------- | ------ | -------------------- |
| `id` | Yes      | -      | UUID de l’abonnement |

### Query parameters

*No query parameters.*

### Request body

JSON request payload.

Schema: `object`

| Field                  | Required | Type      | Description |
| ---------------------- | -------- | --------- | ----------- |
| `cancel_at_period_end` | No       | `boolean` | -           |
| `cancellation_reason`  | No       | `string`  | -           |

Example body:

```json
{
  "cancel_at_period_end": true,
  "cancellation_reason": "string"
}
```

## Responses

| Status | Description                |
| ------ | -------------------------- |
| `200`  | Success                    |
| `401`  | Invalid or missing API key |
| `404`  | Resource not found         |

## Errors

Errors follow the standard JSON error format (status code and machine-readable message). Validate inputs before calling; **401** indicates a missing/invalid key, **404** a missing resource for this organization, **429** rate limiting. For safe retries on create-style calls, send an idempotency key when your flow supports it.

## Example

```bash
curl -sS -X POST "https://sandbox.api.lomi.africa/subscriptions/value/cancel" \
  -H "X-API-KEY: $LOMI_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{"cancel_at_period_end":true,"cancellation_reason":"string"}'
```

## OpenAPI

* **operationId**: `SubscriptionsController_cancel`
* **Operation**: `POST /subscriptions/{id}/cancel`

Full schemas and **Try it**: [API reference](/api). Machine-readable contract: repo `apps/docs/openapi.json`.
