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

# Cancel Accounts

> Cancel the subscription for a customer, cancelling all accounts associated with it at the end of the billing period

## Request Body

<ParamField body="stripeSubscriptionId" type="string" required>
  The Stripe subscription ID to cancel. Since a subscription covers multiple accounts, this cancels all accounts associated with it. Retrieve the subscription ID from the [Get Accounts](/partners/accounts/list) endpoint.
</ParamField>

## Response

<ResponseField name="success" type="boolean">
  Returns `true` if the subscription was successfully queued for cancellation.
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://api.infinipost.co/v1/partners/cancelAccounts \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "stripeSubscriptionId": "sub_1234567890"
    }'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.infinipost.co/v1/partners/cancelAccounts', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      stripeSubscriptionId: 'sub_1234567890'
    })
  });

  const data = await response.json();
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      'https://api.infinipost.co/v1/partners/cancelAccounts',
      headers={
          'Authorization': 'Bearer YOUR_API_KEY',
          'Content-Type': 'application/json'
      },
      json={
          'stripeSubscriptionId': 'sub_1234567890'
      }
  )

  print(response.json())
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "success": true
  }
  ```
</ResponseExample>

## Cancellation Details

* The subscription is set to cancel at the end of the current billing period — the customer keeps access until then
* All accounts under the subscription are updated to `pending_cancellation`
* When the billing period ends, accounts are automatically moved to `cancelled` and removed from Infinipost
* Cancelled accounts cannot be reactivated — a new checkout session must be created to purchase replacement accounts

<Warning>
  **This action is irreversible.** Once a subscription is cancelled it cannot be reactivated. Make sure to confirm with your user before calling this endpoint.
</Warning>

## Error Responses

```json Invalid API Key theme={null}
{
  "error": "This API key does not have partner access"
}
```

```json Missing Required Fields theme={null}
{
  "error": "stripeSubscriptionId is required"
}
```
