Box work and access
Execute Box command
POST
/
boxes
/
{boxId}
/
commands
Execute a command in a Box
curl --request POST \
--url https://ascii.dev/api/box/v1/boxes/{boxId}/commands \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"command": "<string>",
"cwd": "<string>",
"timeoutSeconds": 30
}
'import requests
url = "https://ascii.dev/api/box/v1/boxes/{boxId}/commands"
payload = {
"command": "<string>",
"cwd": "<string>",
"timeoutSeconds": 30
}
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({command: '<string>', cwd: '<string>', timeoutSeconds: 30})
};
fetch('https://ascii.dev/api/box/v1/boxes/{boxId}/commands', 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://ascii.dev/api/box/v1/boxes/{boxId}/commands",
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([
'command' => '<string>',
'cwd' => '<string>',
'timeoutSeconds' => 30
]),
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://ascii.dev/api/box/v1/boxes/{boxId}/commands"
payload := strings.NewReader("{\n \"command\": \"<string>\",\n \"cwd\": \"<string>\",\n \"timeoutSeconds\": 30\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://ascii.dev/api/box/v1/boxes/{boxId}/commands")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"command\": \"<string>\",\n \"cwd\": \"<string>\",\n \"timeoutSeconds\": 30\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://ascii.dev/api/box/v1/boxes/{boxId}/commands")
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 \"command\": \"<string>\",\n \"cwd\": \"<string>\",\n \"timeoutSeconds\": 30\n}"
response = http.request(request)
puts response.read_body{
"ok": true,
"type": "<string>",
"success": true,
"exitCode": 123,
"stdout": "<string>",
"stderr": "<string>",
"timedOut": true,
"signal": "<string>",
"stdoutTruncated": true,
"stderrTruncated": true,
"cwd": "<string>",
"startedAt": "2023-11-07T05:31:56Z",
"finishedAt": "2023-11-07T05:31:56Z"
}Authorizations
Box bearer token in the form box_.... Service API keys authenticate Box operations.
Path Parameters
Public Box id returned by create/list/get box calls.
Pattern:
^bx_[23456789abcdefghjkmnpqrstuvwxyz]{8}$Body
application/json
Response
200 - application/json
Command result.
Example:
true
Stable success envelope discriminator added by v1.
Allowed value:
"command.finished"⌘I
Execute a command in a Box
curl --request POST \
--url https://ascii.dev/api/box/v1/boxes/{boxId}/commands \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"command": "<string>",
"cwd": "<string>",
"timeoutSeconds": 30
}
'import requests
url = "https://ascii.dev/api/box/v1/boxes/{boxId}/commands"
payload = {
"command": "<string>",
"cwd": "<string>",
"timeoutSeconds": 30
}
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({command: '<string>', cwd: '<string>', timeoutSeconds: 30})
};
fetch('https://ascii.dev/api/box/v1/boxes/{boxId}/commands', 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://ascii.dev/api/box/v1/boxes/{boxId}/commands",
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([
'command' => '<string>',
'cwd' => '<string>',
'timeoutSeconds' => 30
]),
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://ascii.dev/api/box/v1/boxes/{boxId}/commands"
payload := strings.NewReader("{\n \"command\": \"<string>\",\n \"cwd\": \"<string>\",\n \"timeoutSeconds\": 30\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://ascii.dev/api/box/v1/boxes/{boxId}/commands")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"command\": \"<string>\",\n \"cwd\": \"<string>\",\n \"timeoutSeconds\": 30\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://ascii.dev/api/box/v1/boxes/{boxId}/commands")
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 \"command\": \"<string>\",\n \"cwd\": \"<string>\",\n \"timeoutSeconds\": 30\n}"
response = http.request(request)
puts response.read_body{
"ok": true,
"type": "<string>",
"success": true,
"exitCode": 123,
"stdout": "<string>",
"stderr": "<string>",
"timedOut": true,
"signal": "<string>",
"stdoutTruncated": true,
"stderrTruncated": true,
"cwd": "<string>",
"startedAt": "2023-11-07T05:31:56Z",
"finishedAt": "2023-11-07T05:31:56Z"
}