---
title: "Cancel a command"
description: "Explicitly stops the complete process tree owned by one execution identity, then waits up to 30 seconds for it to end and returns how it ended."
canonical: "https://www.cool.computer/docs/api-reference/execution/cancel-a-command"
---
# Cancel a command

> Explicitly stops the complete process tree owned by one execution identity, then waits up to 30 seconds for it to end and returns how it ended.

```http
POST https://api.cool.computer/api/computers/{id}/exec/cancel
```

Explicitly stops the complete process tree owned by one execution identity, then waits up to 30 seconds for it to end and returns how it ended. already_finished is true when it had ended before the stop, which then changed nothing. Losing an HTTP connection does not cancel the execution.

## Authorization

- A Cool Computers API key, user access token, or claimed agent access token in the Authorization header. Follow https://www.cool.computer/auth.md for agent registration and https://www.cool.computer/authentication.md for direct user credentials.

## Parameters

- `id` (path, string, at least 1 characters, required): The computer's name, such as agent-atlas, or its id (cmp_…). Every caller may use either, the computer's own runtime token included.

## Request body

Required.

- `application/json` (object)
  - `execution_id` (string, pattern `^cmp_[0-9a-f]{24}\.exec\.[0-9a-f]{32}$`, required)

## Responses

- `200`: How the execution ended.
  - `application/json` (object)
    - `status` ("succeeded" or "failed" or "cancelled" or "owner_lost", required)
    - `exit_code` (integer, required)
    - `signal` (string)
    - `already_finished` (boolean, required): The execution had ended before the stop, which changed nothing.
- `400`: Bad Request.
- `401`: Unauthorized.
- `402`: Payment Required. `pro_required`: VMs need Pro; start Pro with cool billing upgrade, or fix a lapsed subscription with cool billing portal, or use the Account page.
- `403`: Forbidden.
- `404`: Not Found. `computer_not_found`: the computer does not exist or is not yours.
- `409`: Conflict.
- `429`: Too Many Requests. If the problem code is api_request_rate_exceeded, wait for Retry-After seconds; other problem codes describe a separate limit.
- `500`: Internal Server Error.
- `503`: Service Unavailable. `computer_starting` means the computer is starting, or stopped and being started again; wait for Retry-After seconds, then retry. Otherwise inspect the problem code and resolution.
- `504`: Gateway Timeout. `execution_stop_timeout`: the stop was sent but the execution did not end within 30 seconds; check it with POST /exec/attach.
- `default`: A machine-readable API error with a stable code and recovery instruction.

An error is an `application/problem+json` document with a stable `code`; [API errors](/docs/api-reference/errors) says how to handle one.

## Example

```sh
curl -X POST "https://api.cool.computer/api/computers/$PARAM_ID/exec/cancel" \
  -H "authorization: Bearer $TOKEN" \
  -H "content-type: application/json" \
  --data '{"execution_id":"cmp_0123456789abcdef01234567.exec.0123456789abcdef0123456789abcdef"}'
```
