Send Stdin
curl --request POST \
--url https://api.declaw.ai/sandboxes/{sandbox_id}/commands/{pid}/stdin \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"data": "<string>"
}
'import requests
url = "https://api.declaw.ai/sandboxes/{sandbox_id}/commands/{pid}/stdin"
payload = { "data": "<string>" }
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({data: '<string>'})
};
fetch('https://api.declaw.ai/sandboxes/{sandbox_id}/commands/{pid}/stdin', 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}/stdin",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'data' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"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"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.declaw.ai/sandboxes/{sandbox_id}/commands/{pid}/stdin"
payload := strings.NewReader("{\n \"data\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.declaw.ai/sandboxes/{sandbox_id}/commands/{pid}/stdin")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"data\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.declaw.ai/sandboxes/{sandbox_id}/commands/{pid}/stdin")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": \"<string>\"\n}"
response = http.request(request)
puts response.read_bodyCommand API
Send Stdin
Write data to the stdin of a running background process.
POST
/
sandboxes
/
{sandbox_id}
/
commands
/
{pid}
/
stdin
Send Stdin
curl --request POST \
--url https://api.declaw.ai/sandboxes/{sandbox_id}/commands/{pid}/stdin \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"data": "<string>"
}
'import requests
url = "https://api.declaw.ai/sandboxes/{sandbox_id}/commands/{pid}/stdin"
payload = { "data": "<string>" }
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({data: '<string>'})
};
fetch('https://api.declaw.ai/sandboxes/{sandbox_id}/commands/{pid}/stdin', 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}/stdin",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'data' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"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"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.declaw.ai/sandboxes/{sandbox_id}/commands/{pid}/stdin"
payload := strings.NewReader("{\n \"data\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.declaw.ai/sandboxes/{sandbox_id}/commands/{pid}/stdin")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"data\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.declaw.ai/sandboxes/{sandbox_id}/commands/{pid}/stdin")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": \"<string>\"\n}"
response = http.request(request)
puts response.read_bodySends a string to the standard input of a background process. The target process
must have been started with
stdin: true in the
run command request so that a stdin pipe was reserved.
Returns an empty {} body.
For full interactive stdin with streaming output, back-pressure, and
separate stdout/stderr callbacks, see the dedicated
stdio API. This command-level endpoint is a simpler
alternative for one-shot stdin writes.
Path Parameters
string
required
The sandbox identifier. Format:
sbx-<8 chars>.integer
required
Process ID of the background command to write to.Example:
42Request Body
string
required
String data to write to the process stdin. Include a newline (
\n) to
simulate pressing Enter.Example: "yes\n"Response
Returns an empty JSON object{}.
Example
curl -X POST https://api.declaw.ai/sandboxes/sbx-a1b2c3d4/commands/42/stdin \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "data": "yes\n" }'
from declaw import Sandbox
sbx = Sandbox.connect("sbx-a1b2c3d4", api_key="YOUR_API_KEY", domain="api.declaw.ai")
# Start an interactive process
handle = sbx.commands.run("cat", background=True, stdin=True)
# Send data to it
sbx.commands.send_stdin(handle.pid, "hello\n")
Response
{}
Error Responses
| Status | Cause |
|---|---|
401 | Missing or invalid API key |
⌘I