curl --request POST \
--url https://api.devic.ai/v1/environments/{environmentId}/sandbox/exec \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"sandboxId": "<string>",
"command": "cd /workspace && ./daily-report.sh",
"args": [
"install",
"express"
],
"cwd": "/workspace",
"sudo": true
}
'import requests
url = "https://api.devic.ai/v1/environments/{environmentId}/sandbox/exec"
payload = {
"sandboxId": "<string>",
"command": "cd /workspace && ./daily-report.sh",
"args": ["install", "express"],
"cwd": "/workspace",
"sudo": True
}
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: 'cd /workspace && ./daily-report.sh',
args: ['install', 'express'],
cwd: '/workspace',
sudo: true
})
};
fetch('https://api.devic.ai/v1/environments/{environmentId}/sandbox/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.devic.ai/v1/environments/{environmentId}/sandbox/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' => 'cd /workspace && ./daily-report.sh',
'args' => [
'install',
'express'
],
'cwd' => '/workspace',
'sudo' => true
]),
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.devic.ai/v1/environments/{environmentId}/sandbox/exec"
payload := strings.NewReader("{\n \"sandboxId\": \"<string>\",\n \"command\": \"cd /workspace && ./daily-report.sh\",\n \"args\": [\n \"install\",\n \"express\"\n ],\n \"cwd\": \"/workspace\",\n \"sudo\": true\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.devic.ai/v1/environments/{environmentId}/sandbox/exec")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"sandboxId\": \"<string>\",\n \"command\": \"cd /workspace && ./daily-report.sh\",\n \"args\": [\n \"install\",\n \"express\"\n ],\n \"cwd\": \"/workspace\",\n \"sudo\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.devic.ai/v1/environments/{environmentId}/sandbox/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\": \"cd /workspace && ./daily-report.sh\",\n \"args\": [\n \"install\",\n \"express\"\n ],\n \"cwd\": \"/workspace\",\n \"sudo\": true\n}"
response = http.request(request)
puts response.read_bodyRun a command in the sandbox
The environment variables are injected, so a command can read them the way the init script does. Returns exit code, stdout, stderr and how long it took; a non-zero exit is a result, not an HTTP error.
curl --request POST \
--url https://api.devic.ai/v1/environments/{environmentId}/sandbox/exec \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"sandboxId": "<string>",
"command": "cd /workspace && ./daily-report.sh",
"args": [
"install",
"express"
],
"cwd": "/workspace",
"sudo": true
}
'import requests
url = "https://api.devic.ai/v1/environments/{environmentId}/sandbox/exec"
payload = {
"sandboxId": "<string>",
"command": "cd /workspace && ./daily-report.sh",
"args": ["install", "express"],
"cwd": "/workspace",
"sudo": True
}
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: 'cd /workspace && ./daily-report.sh',
args: ['install', 'express'],
cwd: '/workspace',
sudo: true
})
};
fetch('https://api.devic.ai/v1/environments/{environmentId}/sandbox/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.devic.ai/v1/environments/{environmentId}/sandbox/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' => 'cd /workspace && ./daily-report.sh',
'args' => [
'install',
'express'
],
'cwd' => '/workspace',
'sudo' => true
]),
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.devic.ai/v1/environments/{environmentId}/sandbox/exec"
payload := strings.NewReader("{\n \"sandboxId\": \"<string>\",\n \"command\": \"cd /workspace && ./daily-report.sh\",\n \"args\": [\n \"install\",\n \"express\"\n ],\n \"cwd\": \"/workspace\",\n \"sudo\": true\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.devic.ai/v1/environments/{environmentId}/sandbox/exec")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"sandboxId\": \"<string>\",\n \"command\": \"cd /workspace && ./daily-report.sh\",\n \"args\": [\n \"install\",\n \"express\"\n ],\n \"cwd\": \"/workspace\",\n \"sudo\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.devic.ai/v1/environments/{environmentId}/sandbox/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\": \"cd /workspace && ./daily-report.sh\",\n \"args\": [\n \"install\",\n \"express\"\n ],\n \"cwd\": \"/workspace\",\n \"sudo\": true\n}"
response = http.request(request)
puts response.read_bodyAuthorizations
Use JWT token for authentication
Path Parameters
Environment id
Body
Sandbox returned by POST /sandbox/start
A line of shell, not an argv[0]. It runs through bash -c, so pipes, redirection, && and cd all work and belong here: cd /workspace && ./report.sh | tail -5.
"cd /workspace && ./daily-report.sh"
Appended to command space-separated, as text. This is NOT argv: nothing is quoted or escaped for you, so an argument containing spaces or shell metacharacters must arrive already quoted — or, more simply, be written into command instead.
["install", "express"]
Working directory
"/workspace"
Run as root
Response
Success