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

# Cancel Case

> Stop a case that is still running

Cancel the execution of a case that is still running. The case ends with status `CANCELLED`, which [Get Case Status](https://developer.opus.com/api-reference/v1-case/get-case-status.md) will return from then on.

> [!NOTE]
>
> Only a case that has been [executed](https://developer.opus.com/api-reference/v1-case/execute-case.md) and has not yet reached a terminal status can be cancelled.

## Path Parameters

**caseId** `string` *required*

The case ID returned by [Initiate Case](https://developer.opus.com/api-reference/v1-case/initiate-case.md)

## Headers

**x-service-key** `string` *required*

Your API authentication key

## Response

**status** `string` *required*

Status of the case after the cancel. Always `CANCELLED`.

## Errors

**400** `Bad Request`

The case was never executed, so there is nothing to cancel.

**401** `Unauthorized`

Missing, invalid, or expired API key.

**404** `Not Found`

The case does not exist.

**409** `Conflict`

The case has already ended (`COMPLETED`, `FAILED`, `CANCELLED` or `TIMED_OUT`).

```bash cURL theme={null}
curl --request POST \
  --url https://operator.opus.com/api/v1/case/{YOUR_CASE_ID}/cancel \
  --header 'x-service-key: {YOUR_SERVICE_KEY}'
```

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

url = "https://operator.opus.com/api/v1/case/{YOUR_CASE_ID}/cancel"
headers = {"x-service-key": "{YOUR_SERVICE_KEY}"}

response = requests.post(url, headers=headers)
print(response.json())
```

```javascript JavaScript theme={null}
const response = await fetch(
  "https://operator.opus.com/api/v1/case/{YOUR_CASE_ID}/cancel",
  {
    method: "POST",
    headers: {
      "x-service-key": "{YOUR_SERVICE_KEY}",
    },
  }
);

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

```json 201 Response theme={null}
{
  "status": "CANCELLED"
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.