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

# Kill Sandbox

> Forcefully terminate a sandbox immediately using the HopX Control Plane API. Immediately stop a sandbox and free all resources without waiting for graceful shutdown. Learn how to use POST /v1/sandboxes/:id/kill endpoint to force-terminate sandboxes. Includes request examples and termination behavior.

Kill a sandbox to forcefully terminate it immediately. This is similar to delete but may be used when a sandbox is unresponsive. The sandbox is destroyed and cannot be recovered.

## Endpoint

```
POST /v1/sandboxes/:id/kill
```

## Request

### Headers

```
Authorization: Bearer $HOPX_API_KEY
```

### Path Parameters

| Parameter | Type   | Description        |
| --------- | ------ | ------------------ |
| `id`      | string | Sandbox ID to kill |

### Example Request

```bash theme={null}
curl -X POST https://api.hopx.dev/v1/sandboxes/sandbox_abc123xyz/kill \
  -H "Authorization: Bearer $HOPX_API_KEY"
```

## Response

### Success (200 OK)

```json theme={null}
{
  "id": "sandbox_abc123xyz",
  "status": "killed",
  "request_id": "req_abc123"
}
```

### Response Fields

| Field        | Type   | Description              |
| ------------ | ------ | ------------------------ |
| `id`         | string | Sandbox ID               |
| `status`     | string | New status (`killed`)    |
| `request_id` | string | Request ID for debugging |

## Status Codes

| Code  | Description                 |
| ----- | --------------------------- |
| `200` | Sandbox killed successfully |
| `401` | Authentication required     |
| `404` | Sandbox not found           |

## Errors

### Sandbox Not Found (404)

```json theme={null}
{
  "error": "Sandbox not found",
  "code": "RESOURCE_NOT_FOUND",
  "request_id": "req_abc123"
}
```

**Cause:** The sandbox ID doesn't exist or belongs to another organization.

**Fix:** Verify the sandbox ID is correct. List your sandboxes using `GET /v1/sandboxes` to find valid IDs.

## Important Notes

<Warning>
  Killing a sandbox is **permanent and irreversible**. All data, files, and state in the sandbox will be lost. This action forcefully terminates the sandbox even if it's unresponsive.
</Warning>

* **Immediate termination** - The sandbox is forcefully terminated immediately
* **No graceful shutdown** - Running processes are killed without cleanup
* **Resource cleanup** - All allocated resources are freed
* **VM Agent API** - The sandbox's VM Agent API endpoint becomes unavailable immediately
* **No recovery** - Killed sandboxes cannot be recovered

## Use Cases

### Kill Unresponsive Sandbox

```bash theme={null}
# Kill a sandbox that's not responding
curl -X POST https://api.hopx.dev/v1/sandboxes/sandbox_abc123xyz/kill \
  -H "Authorization: Bearer $HOPX_API_KEY"
```

### Force Cleanup

```bash theme={null}
# Kill instead of delete when sandbox is stuck
curl -X POST https://api.hopx.dev/v1/sandboxes/sandbox_abc123xyz/kill \
  -H "Authorization: Bearer $HOPX_API_KEY"
```

## Difference from Delete

* **Kill** - Forcefully terminates the sandbox immediately, even if unresponsive
* **Delete** - Gracefully deletes the sandbox (may fail if sandbox is stuck)

Use `kill` when a sandbox is unresponsive and `delete` doesn't work.

## Related

* **[Managing Sandbox State](/core-concepts/sandboxes/managing-state)** - Learn about sandbox lifecycle
* **[Delete Sandbox](/api/control-plane/delete-sandbox)** - Gracefully delete a sandbox
* **[Stop Sandbox](/api/control-plane/stop-sandbox)** - Stop instead of killing
* **SDK**: [sandbox.kill()](/sdk/python/sandbox#kill) - Python SDK method
* [CLI Sandbox Commands](/cli/commands/sandbox) - Manage sandboxes from CLI

## Next Steps

* **[Delete Sandbox](/api/control-plane/delete-sandbox)** - Gracefully delete a sandbox
* **[Stop Sandbox](/api/control-plane/stop-sandbox)** - Stop instead of killing
* **[Get Sandbox](/api/control-plane/get-sandbox)** - Check sandbox status
