Exec
curl --request POST \
--url https://api.cwsandbox.com/v1/sandboxes/{sandboxId}:exec \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"sandboxId": "<string>",
"command": [
"<string>"
],
"env": {},
"maxOutputBytes": 123,
"container": "<string>"
}
'import requests
url = "https://api.cwsandbox.com/v1/sandboxes/{sandboxId}:exec"
payload = {
"sandboxId": "<string>",
"command": ["<string>"],
"env": {},
"maxOutputBytes": 123,
"container": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
sandboxId: '<string>',
command: ['<string>'],
env: {},
maxOutputBytes: 123,
container: '<string>'
})
};
fetch('https://api.cwsandbox.com/v1/sandboxes/{sandboxId}:exec', 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.cwsandbox.com/v1/sandboxes/{sandboxId}:exec",
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([
'sandboxId' => '<string>',
'command' => [
'<string>'
],
'env' => [
],
'maxOutputBytes' => 123,
'container' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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.cwsandbox.com/v1/sandboxes/{sandboxId}:exec"
payload := strings.NewReader("{\n \"sandboxId\": \"<string>\",\n \"command\": [\n \"<string>\"\n ],\n \"env\": {},\n \"maxOutputBytes\": 123,\n \"container\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.cwsandbox.com/v1/sandboxes/{sandboxId}:exec")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"sandboxId\": \"<string>\",\n \"command\": [\n \"<string>\"\n ],\n \"env\": {},\n \"maxOutputBytes\": 123,\n \"container\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cwsandbox.com/v1/sandboxes/{sandboxId}:exec")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"sandboxId\": \"<string>\",\n \"command\": [\n \"<string>\"\n ],\n \"env\": {},\n \"maxOutputBytes\": 123,\n \"container\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"stdout": "<string>",
"stderr": "<string>",
"exitCode": 123,
"stdoutTruncated": true,
"stderrTruncated": true,
"stdoutBytesProduced": "<string>",
"stderrBytesProduced": "<string>"
}{
"code": 123,
"message": "<string>",
"details": [
{
"@type": "<string>"
}
]
}Exec
Run a command to completion in a sandbox container and return its buffered output.
POST
/
v1
/
sandboxes
/
{sandboxId}
:exec
Exec
curl --request POST \
--url https://api.cwsandbox.com/v1/sandboxes/{sandboxId}:exec \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"sandboxId": "<string>",
"command": [
"<string>"
],
"env": {},
"maxOutputBytes": 123,
"container": "<string>"
}
'import requests
url = "https://api.cwsandbox.com/v1/sandboxes/{sandboxId}:exec"
payload = {
"sandboxId": "<string>",
"command": ["<string>"],
"env": {},
"maxOutputBytes": 123,
"container": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
sandboxId: '<string>',
command: ['<string>'],
env: {},
maxOutputBytes: 123,
container: '<string>'
})
};
fetch('https://api.cwsandbox.com/v1/sandboxes/{sandboxId}:exec', 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.cwsandbox.com/v1/sandboxes/{sandboxId}:exec",
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([
'sandboxId' => '<string>',
'command' => [
'<string>'
],
'env' => [
],
'maxOutputBytes' => 123,
'container' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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.cwsandbox.com/v1/sandboxes/{sandboxId}:exec"
payload := strings.NewReader("{\n \"sandboxId\": \"<string>\",\n \"command\": [\n \"<string>\"\n ],\n \"env\": {},\n \"maxOutputBytes\": 123,\n \"container\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.cwsandbox.com/v1/sandboxes/{sandboxId}:exec")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"sandboxId\": \"<string>\",\n \"command\": [\n \"<string>\"\n ],\n \"env\": {},\n \"maxOutputBytes\": 123,\n \"container\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cwsandbox.com/v1/sandboxes/{sandboxId}:exec")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"sandboxId\": \"<string>\",\n \"command\": [\n \"<string>\"\n ],\n \"env\": {},\n \"maxOutputBytes\": 123,\n \"container\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"stdout": "<string>",
"stderr": "<string>",
"exitCode": 123,
"stdoutTruncated": true,
"stderrTruncated": true,
"stdoutBytesProduced": "<string>",
"stderrBytesProduced": "<string>"
}{
"code": 123,
"message": "<string>",
"details": [
{
"@type": "<string>"
}
]
}Authorizations
CoreWeave API access token sent as a bearer token.
Path Parameters
Body
application/json
Show child attributes
Show child attributes
Cap on buffered output per stream; output beyond this is truncated (see ExecResponse.*_truncated). 0 = platform default.
Target container name. Empty = the primary. Unknown names and platform sidecar names are INVALID_ARGUMENT (CWSANDBOX_INVALID_REQUEST). In a CONTROL_CONTAINER_ENGINE sandbox, cws-engine is the only container and the primary.
Response
OK
Total bytes the process wrote to stdout, even when stdout was truncated.
Total bytes the process wrote to stderr, even when stderr was truncated.
Was this page helpful?