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

# Cancel an agent run

Requests cancellation of a running agent run. Cancellation is asynchronous — poll GET /v1/agent-runs/{id} to observe the terminal "cancelled" phase.

` POST /v1/agent-runs/{id}/cancel `

Cancel an agent run

Requests cancellation of a running agent run. Cancellation is
asynchronous — poll GET /v1/agent-runs/{id} to observe the
terminal "cancelled" phase.

## Authentication

The operation accepts these alternatives. Schemes within one alternative are required together.

### Alternative 1

- ` BearerAuth `: ` apiKey `

  - Credential: ` Authorization ` in ` header `

  - JWT or API key, sent as: Bearer <token>

## Parameters

### ` id ` (path, required)

Run ID

- ` value `: type ` string `

## Responses

### ` 200 ` — OK

Content type: ` application/json `

- ` value `: type ` object `

  - ` code `: type ` integer `

    - example: ` 200 `

  - ` data `: type ` object `

    - ` ok `: type ` boolean `

      - example: ` true `

  - ` message `: type ` string `

    - example: ` "success" `

  - ` requestId `: type ` string `

    - example: ` "abc-123" `

## Request examples

### cURL

```curl
curl -X POST 'https://api.example.com/v1/agent-runs/string/cancel' \
  -H 'Authorization: Bearer YOUR_API_TOKEN'
```

### JavaScript

```javascript
const response = await fetch('https://api.example.com/v1/agent-runs/string/cancel', {
  method: 'POST',
  headers: {
      "Authorization": "Bearer YOUR_API_TOKEN"
  }
});

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

### Python

```python
import requests

headers = {
    'Authorization': 'Bearer YOUR_API_TOKEN'
}

response = requests.post('https://api.example.com/v1/agent-runs/string/cancel', headers=headers)
print(response.json())
```

### Go

```go
package main

import (
	"fmt"
	"io"
	"net/http"
)

func main() {
	req, _ := http.NewRequest("POST", "https://api.example.com/v1/agent-runs/string/cancel", nil)
	req.Header.Set("Authorization", "Bearer YOUR_API_TOKEN")

	resp, _ := http.DefaultClient.Do(req)
	defer resp.Body.Close()
	result, _ := io.ReadAll(resp.Body)
	fmt.Println(string(result))
}
```