Skip to main content
Delete a sandbox to permanently destroy it and free all allocated resources. This action cannot be undone.

Endpoint

DELETE /v1/sandboxes/:id

Request

Headers

Authorization: Bearer $HOPX_API_KEY

Path Parameters

ParameterTypeDescription
idstringSandbox ID to delete

Example Request

curl -X DELETE https://api.hopx.dev/v1/sandboxes/sandbox_abc123xyz \
  -H "Authorization: Bearer $HOPX_API_KEY"

Response

Success (200 OK)

{
  "status": "deleted",
  "id": "sandbox_abc123xyz",
  "request_id": "req_abc123"
}

Response Fields

FieldTypeDescription
statusstringAlways "deleted"
idstringDeleted sandbox ID
request_idstringRequest ID for debugging

Status Codes

CodeDescription
200Sandbox deleted successfully
401Authentication required
404Sandbox not found

Errors

Sandbox Not Found (404)

{
  "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

Deleting a sandbox is permanent and irreversible. All data, files, and state in the sandbox will be lost. Make sure to save any important data before deleting.
  • Immediate deletion - The sandbox is destroyed immediately upon successful deletion
  • Resource cleanup - All allocated resources (vCPU, memory, disk) are freed
  • VM Agent API - The sandbox’s VM Agent API endpoint becomes unavailable immediately
  • No recovery - Deleted sandboxes cannot be recovered

Use Cases

Clean Up After Task Completion

# Execute your task
# ... code execution ...

# Delete when done
curl -X DELETE https://api.hopx.dev/v1/sandboxes/sandbox_abc123xyz \
  -H "Authorization: Bearer $HOPX_API_KEY"

Delete All Stopped Sandboxes

#!/bin/bash
# Get all stopped sandboxes
STOPPED=$(curl -s "https://api.hopx.dev/v1/sandboxes?status=stopped" \
  -H "Authorization: Bearer $HOPX_API_KEY" | \
  jq -r '.data[].id')

# Delete each one
for ID in $STOPPED; do
  curl -X DELETE "https://api.hopx.dev/v1/sandboxes/$ID" \
    -H "Authorization: Bearer $HOPX_API_KEY"
  echo "Deleted $ID"
done

Delete Sandbox with Verification

#!/bin/bash
SANDBOX_ID="sandbox_abc123xyz"

# Verify sandbox exists
STATUS=$(curl -s "https://api.hopx.dev/v1/sandboxes/$SANDBOX_ID" \
  -H "Authorization: Bearer $HOPX_API_KEY" | jq -r '.status')

if [ "$STATUS" != "null" ]; then
  # Delete it
  curl -X DELETE "https://api.hopx.dev/v1/sandboxes/$SANDBOX_ID" \
    -H "Authorization: Bearer $HOPX_API_KEY"
  echo "Sandbox $SANDBOX_ID deleted"
else
  echo "Sandbox not found"
fi

Next Steps