Run a command
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
command: 'npm test',
cwd: '/home/user/app',
env: {},
timeoutSeconds: 4503599627370495,
stdin: true,
detached: true
})
};
fetch('https://vms.dev/api/v1/sandboxes/{id}/commands', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request POST \
--url https://vms.dev/api/v1/sandboxes/{id}/commands \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"command": "npm test",
"cwd": "/home/user/app",
"env": {},
"timeoutSeconds": 4503599627370495,
"stdin": true,
"detached": true
}
'import requests
url = "https://vms.dev/api/v1/sandboxes/{id}/commands"
payload = {
"command": "npm test",
"cwd": "/home/user/app",
"env": {},
"timeoutSeconds": 4503599627370495,
"stdin": True,
"detached": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"type": "started",
"seq": 4503599627370495,
"at": "2023-11-07T05:31:56Z",
"commandId": "<string>",
"pid": 123
}{
"id": "cmd_01jz8x3n9q2v7k4m6p8r0t2w4y",
"sandboxId": "<string>",
"argv": [
"<string>"
],
"cwd": "<string>",
"status": "running",
"pid": 4503599627370495,
"detached": true,
"startedAt": "2023-11-07T05:31:56Z",
"exitedAt": "2023-11-07T05:31:56Z",
"exitCode": 0,
"signal": "SIGTERM",
"oomKilled": true,
"timedOut": true,
"lastSeq": 4503599627370495
}{
"error": {
"code": "no_capacity",
"message": "<string>",
"requestId": "<string>",
"retryAfterSeconds": 4503599627370495,
"sandboxId": "<string>"
}
}{
"error": {
"code": "no_capacity",
"message": "<string>",
"requestId": "<string>",
"retryAfterSeconds": 4503599627370495,
"sandboxId": "<string>"
}
}{
"error": {
"code": "no_capacity",
"message": "<string>",
"requestId": "<string>",
"retryAfterSeconds": 4503599627370495,
"sandboxId": "<string>"
}
}{
"error": {
"code": "no_capacity",
"message": "<string>",
"requestId": "<string>",
"retryAfterSeconds": 4503599627370495,
"sandboxId": "<string>"
}
}{
"error": {
"code": "no_capacity",
"message": "<string>",
"requestId": "<string>",
"retryAfterSeconds": 4503599627370495,
"sandboxId": "<string>"
}
}{
"error": {
"code": "no_capacity",
"message": "<string>",
"requestId": "<string>",
"retryAfterSeconds": 4503599627370495,
"sandboxId": "<string>"
}
}{
"error": {
"code": "no_capacity",
"message": "<string>",
"requestId": "<string>",
"retryAfterSeconds": 4503599627370495,
"sandboxId": "<string>"
}
}Commands
Run a command
Runs a command in a running sandbox and streams its output as NDJSON until the command exits. A command has no time limit unless you send timeoutSeconds. If you disconnect, the command gets SIGKILL. Send detached: true to get the command at once and keep it running after you disconnect. Needs the sandboxes:exec scope.
POST
/
v1
/
sandboxes
/
{id}
/
commands
Run a command
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
command: 'npm test',
cwd: '/home/user/app',
env: {},
timeoutSeconds: 4503599627370495,
stdin: true,
detached: true
})
};
fetch('https://vms.dev/api/v1/sandboxes/{id}/commands', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request POST \
--url https://vms.dev/api/v1/sandboxes/{id}/commands \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"command": "npm test",
"cwd": "/home/user/app",
"env": {},
"timeoutSeconds": 4503599627370495,
"stdin": true,
"detached": true
}
'import requests
url = "https://vms.dev/api/v1/sandboxes/{id}/commands"
payload = {
"command": "npm test",
"cwd": "/home/user/app",
"env": {},
"timeoutSeconds": 4503599627370495,
"stdin": True,
"detached": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"type": "started",
"seq": 4503599627370495,
"at": "2023-11-07T05:31:56Z",
"commandId": "<string>",
"pid": 123
}{
"id": "cmd_01jz8x3n9q2v7k4m6p8r0t2w4y",
"sandboxId": "<string>",
"argv": [
"<string>"
],
"cwd": "<string>",
"status": "running",
"pid": 4503599627370495,
"detached": true,
"startedAt": "2023-11-07T05:31:56Z",
"exitedAt": "2023-11-07T05:31:56Z",
"exitCode": 0,
"signal": "SIGTERM",
"oomKilled": true,
"timedOut": true,
"lastSeq": 4503599627370495
}{
"error": {
"code": "no_capacity",
"message": "<string>",
"requestId": "<string>",
"retryAfterSeconds": 4503599627370495,
"sandboxId": "<string>"
}
}{
"error": {
"code": "no_capacity",
"message": "<string>",
"requestId": "<string>",
"retryAfterSeconds": 4503599627370495,
"sandboxId": "<string>"
}
}{
"error": {
"code": "no_capacity",
"message": "<string>",
"requestId": "<string>",
"retryAfterSeconds": 4503599627370495,
"sandboxId": "<string>"
}
}{
"error": {
"code": "no_capacity",
"message": "<string>",
"requestId": "<string>",
"retryAfterSeconds": 4503599627370495,
"sandboxId": "<string>"
}
}{
"error": {
"code": "no_capacity",
"message": "<string>",
"requestId": "<string>",
"retryAfterSeconds": 4503599627370495,
"sandboxId": "<string>"
}
}{
"error": {
"code": "no_capacity",
"message": "<string>",
"requestId": "<string>",
"retryAfterSeconds": 4503599627370495,
"sandboxId": "<string>"
}
}{
"error": {
"code": "no_capacity",
"message": "<string>",
"requestId": "<string>",
"retryAfterSeconds": 4503599627370495,
"sandboxId": "<string>"
}
}Authorizations
Body
application/json
Response
The output of the command. Each line is one JSON event: started, then stdout and stderr, then exit. Each event has a seq that starts at 0. When no event comes for 15 seconds, the stream sends an empty line. Skip empty lines.
- Option 1
- Option 2
- Option 3
Pattern:
^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|([+-](?:[01]\d|2[0-3]):[0-5]\d)))$