Cancel Run
Cancel an in-flight run.
Idempotent: a run already in a terminal state (completed / failed /
cancelled) is returned as-is. Once cancelled, the gateway refuses
every subsequent chat_completions call from the worker — so the
project cannot be billed further regardless of whether the worker
subprocess notices the cancel itself.
The worker keeps running for at most one more bcode step (consuming no LLM tokens because CP 409s them) and then exits when bcode realizes the next tool call has no model behind it.
POST
/
runs
/
{run_id}
/
cancel
Cancel Run
const options = {method: 'POST', headers: {'X-Browser-Use-API-Key': '<api-key>'}};
fetch('https://api.browser-use.com/api/v4/runs/{run_id}/cancel', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request POST \
--url https://api.browser-use.com/api/v4/runs/{run_id}/cancel \
--header 'X-Browser-Use-API-Key: <api-key>'import requests
url = "https://api.browser-use.com/api/v4/runs/{run_id}/cancel"
headers = {"X-Browser-Use-API-Key": "<api-key>"}
response = requests.post(url, headers=headers)
print(response.text){
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"task": "<string>",
"title": "<string>",
"model": "<string>",
"contextLimit": 123,
"status": "queued",
"result": "<string>",
"error": "<string>",
"sessionId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"workspaceId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"totalInputTokens": 123,
"totalOutputTokens": 123,
"totalCostUsd": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"modelParams": {},
"output": null,
"outputSchema": {},
"attachedFileIds": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
],
"judgement": {}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Authorizations
Path Parameters
Response
Successful Response
Available options:
queued, dispatching, running, completed, failed, cancelled Was this page helpful?
⌘I
Cancel Run
const options = {method: 'POST', headers: {'X-Browser-Use-API-Key': '<api-key>'}};
fetch('https://api.browser-use.com/api/v4/runs/{run_id}/cancel', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request POST \
--url https://api.browser-use.com/api/v4/runs/{run_id}/cancel \
--header 'X-Browser-Use-API-Key: <api-key>'import requests
url = "https://api.browser-use.com/api/v4/runs/{run_id}/cancel"
headers = {"X-Browser-Use-API-Key": "<api-key>"}
response = requests.post(url, headers=headers)
print(response.text){
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"task": "<string>",
"title": "<string>",
"model": "<string>",
"contextLimit": 123,
"status": "queued",
"result": "<string>",
"error": "<string>",
"sessionId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"workspaceId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"totalInputTokens": 123,
"totalOutputTokens": 123,
"totalCostUsd": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"modelParams": {},
"output": null,
"outputSchema": {},
"attachedFileIds": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
],
"judgement": {}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}