Kill Command
curl --request DELETE \
--url https://api.declaw.ai/sandboxes/{sandbox_id}/commands/{pid} \
--header 'X-API-Key: <api-key>'import requests
url = "https://api.declaw.ai/sandboxes/{sandbox_id}/commands/{pid}"
headers = {"X-API-Key": "<api-key>"}
response = requests.delete(url, headers=headers)
print(response.text)const options = {method: 'DELETE', headers: {'X-API-Key': '<api-key>'}};
fetch('https://api.declaw.ai/sandboxes/{sandbox_id}/commands/{pid}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.declaw.ai/sandboxes/{sandbox_id}/commands/{pid}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => [
"X-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.declaw.ai/sandboxes/{sandbox_id}/commands/{pid}"
req, _ := http.NewRequest("DELETE", url, nil)
req.Header.Add("X-API-Key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.delete("https://api.declaw.ai/sandboxes/{sandbox_id}/commands/{pid}")
.header("X-API-Key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.declaw.ai/sandboxes/{sandbox_id}/commands/{pid}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["X-API-Key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"killed": true
}Command API
Kill Command
Kill a background process by its PID.
DELETE
/
sandboxes
/
{sandbox_id}
/
commands
/
{pid}
Kill Command
curl --request DELETE \
--url https://api.declaw.ai/sandboxes/{sandbox_id}/commands/{pid} \
--header 'X-API-Key: <api-key>'import requests
url = "https://api.declaw.ai/sandboxes/{sandbox_id}/commands/{pid}"
headers = {"X-API-Key": "<api-key>"}
response = requests.delete(url, headers=headers)
print(response.text)const options = {method: 'DELETE', headers: {'X-API-Key': '<api-key>'}};
fetch('https://api.declaw.ai/sandboxes/{sandbox_id}/commands/{pid}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.declaw.ai/sandboxes/{sandbox_id}/commands/{pid}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_HTTPHEADER => [
"X-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.declaw.ai/sandboxes/{sandbox_id}/commands/{pid}"
req, _ := http.NewRequest("DELETE", url, nil)
req.Header.Add("X-API-Key", "<api-key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.delete("https://api.declaw.ai/sandboxes/{sandbox_id}/commands/{pid}")
.header("X-API-Key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.declaw.ai/sandboxes/{sandbox_id}/commands/{pid}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["X-API-Key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"killed": true
}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.
This endpoint removes the process from the API’s tracking list. The underlying VM
process termination is handled by the envd daemon.
Path Parameters
string
required
The sandbox identifier. Format:
sbx-<8 chars>.integer
required
Process ID of the background command to kill.Example:
42Response
boolean
true if the process was found and removed. false if no process with that
PID was tracked.Example
curl -X DELETE https://api.declaw.ai/sandboxes/sbx-a1b2c3d4/commands/42 \
-H "X-API-Key: YOUR_API_KEY"
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)
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);
Response
{
"killed": true
}
Error Responses
| Status | Cause |
|---|---|
400 | pid path parameter is not a valid integer |
401 | Missing or invalid API key |
⌘I