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

# Kill Command

> Kill a background process by its PID.

Kills a background process tracked in the sandbox process list and removes it from
the list. Returns `{ "killed": true }` if the process was found and removed, or
`{ "killed": false }` if it was not in the tracked list.

<Note>
  This endpoint removes the process from the API's tracking list. The underlying VM
  process termination is handled by the envd daemon.
</Note>

## Path Parameters

<ParamField path="sandbox_id" type="string" required>
  The sandbox identifier. Format: `sbx-<8 chars>`.
</ParamField>

<ParamField path="pid" type="integer" required>
  Process ID of the background command to kill.

  Example: `42`
</ParamField>

## Response

<ResponseField name="killed" type="boolean">
  `true` if the process was found and removed. `false` if no process with that
  PID was tracked.
</ResponseField>

## Example

<CodeGroup>
  ```bash cURL theme={null}
  curl -X DELETE https://api.declaw.ai/sandboxes/sbx-a1b2c3d4/commands/42 \
    -H "X-API-Key: YOUR_API_KEY"
  ```

  ```python Python theme={null}
  from declaw import Sandbox

  sbx = Sandbox.connect("sbx-a1b2c3d4", api_key="YOUR_API_KEY", domain="api.declaw.ai")

  # Start a background process
  handle = sbx.commands.run("sleep 60", background=True)
  print(handle.pid)  # 42

  # Kill it
  sbx.commands.kill(handle.pid)
  ```

  ```typescript TypeScript theme={null}
  import { Sandbox } from "@declaw/sdk";

  const sbx = await Sandbox.connect("sbx-a1b2c3d4", {
    apiKey: "YOUR_API_KEY",
    domain: "api.declaw.ai",
  });

  const handle = await sbx.commands.run("sleep 60", { background: true });
  await sbx.commands.kill(handle.pid);
  ```
</CodeGroup>

```json Response theme={null}
{
  "killed": true
}
```

## Error Responses

| Status | Cause                                       |
| ------ | ------------------------------------------- |
| `400`  | `pid` path parameter is not a valid integer |
| `401`  | Missing or invalid API key                  |
