curl --request POST \
--url https://api.instabox.sh/v1/machines/{id}/ssh-tokens \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"ttlSeconds": 1296000,
"noExpiry": true
}
'import requests
url = "https://api.instabox.sh/v1/machines/{id}/ssh-tokens"
payload = {
"name": "<string>",
"ttlSeconds": 1296000,
"noExpiry": 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({name: '<string>', ttlSeconds: 1296000, noExpiry: true})
};
fetch('https://api.instabox.sh/v1/machines/{id}/ssh-tokens', 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.instabox.sh/v1/machines/{id}/ssh-tokens",
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([
'name' => '<string>',
'ttlSeconds' => 1296000,
'noExpiry' => 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.instabox.sh/v1/machines/{id}/ssh-tokens"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"ttlSeconds\": 1296000,\n \"noExpiry\": 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.instabox.sh/v1/machines/{id}/ssh-tokens")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"ttlSeconds\": 1296000,\n \"noExpiry\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.instabox.sh/v1/machines/{id}/ssh-tokens")
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 \"name\": \"<string>\",\n \"ttlSeconds\": 1296000,\n \"noExpiry\": true\n}"
response = http.request(request)
puts response.read_body{
"name": "<string>",
"id": "<string>",
"machineId": "<string>",
"host": "<string>",
"port": 123,
"token": "<string>",
"command": "<string>",
"hostKeyFingerprint": "<string>",
"moshCommand": "<string>",
"expiresAt": "2023-11-07T05:31:56Z"
}{
"error": {
"code": "unauthenticated",
"message": "<string>",
"requestId": "<string>",
"retryable": true,
"operationId": "<string>",
"reason": "missing_key",
"hint": "<string>",
"docs": "<string>",
"docs_url": "<string>",
"requiredScopes": [
"<string>"
],
"retryAfterSeconds": 2,
"at": "2023-11-07T05:31:56Z"
}
}{
"error": {
"code": "unauthenticated",
"message": "<string>",
"requestId": "<string>",
"retryable": true,
"operationId": "<string>",
"reason": "missing_key",
"hint": "<string>",
"docs": "<string>",
"docs_url": "<string>",
"requiredScopes": [
"<string>"
],
"retryAfterSeconds": 2,
"at": "2023-11-07T05:31:56Z"
}
}{
"error": {
"code": "unauthenticated",
"message": "<string>",
"requestId": "<string>",
"retryable": true,
"operationId": "<string>",
"reason": "missing_key",
"hint": "<string>",
"docs": "<string>",
"docs_url": "<string>",
"requiredScopes": [
"<string>"
],
"retryAfterSeconds": 2,
"at": "2023-11-07T05:31:56Z"
}
}{
"error": {
"code": "unauthenticated",
"message": "<string>",
"requestId": "<string>",
"retryable": true,
"operationId": "<string>",
"reason": "missing_key",
"hint": "<string>",
"docs": "<string>",
"docs_url": "<string>",
"requiredScopes": [
"<string>"
],
"retryAfterSeconds": 2,
"at": "2023-11-07T05:31:56Z"
}
}{
"error": {
"code": "unauthenticated",
"message": "<string>",
"requestId": "<string>",
"retryable": true,
"operationId": "<string>",
"reason": "missing_key",
"hint": "<string>",
"docs": "<string>",
"docs_url": "<string>",
"requiredScopes": [
"<string>"
],
"retryAfterSeconds": 2,
"at": "2023-11-07T05:31:56Z"
}
}Issue an SSH token, for a plain `ssh` command without a key.
Returns a token to use as the SSH user name:
command is ssh -p <port> <token>@<host>. The server keeps its
sha256 and, when a vault key is configured, the token sealed, which
GET /v1/machines/{id}/ssh-tokens returns to its maker in a sign-in
session. This request takes no Idempotency-Key; a retry makes another
token. The sandbox may be in
any state but deleting: while it is not running, a client that logs
in is told to start it. The token works until expiresAt (absent with
noExpiry: never), until
DELETE /v1/machines/{id}/ssh-tokens, until the sandbox is deleted or,
for a token an API key made, until the key is revoked or expires.
API keys: needs one of the scopes machines:write, machines:ssh (legacy).
curl --request POST \
--url https://api.instabox.sh/v1/machines/{id}/ssh-tokens \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"ttlSeconds": 1296000,
"noExpiry": true
}
'import requests
url = "https://api.instabox.sh/v1/machines/{id}/ssh-tokens"
payload = {
"name": "<string>",
"ttlSeconds": 1296000,
"noExpiry": 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({name: '<string>', ttlSeconds: 1296000, noExpiry: true})
};
fetch('https://api.instabox.sh/v1/machines/{id}/ssh-tokens', 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.instabox.sh/v1/machines/{id}/ssh-tokens",
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([
'name' => '<string>',
'ttlSeconds' => 1296000,
'noExpiry' => 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.instabox.sh/v1/machines/{id}/ssh-tokens"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"ttlSeconds\": 1296000,\n \"noExpiry\": 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.instabox.sh/v1/machines/{id}/ssh-tokens")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"ttlSeconds\": 1296000,\n \"noExpiry\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.instabox.sh/v1/machines/{id}/ssh-tokens")
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 \"name\": \"<string>\",\n \"ttlSeconds\": 1296000,\n \"noExpiry\": true\n}"
response = http.request(request)
puts response.read_body{
"name": "<string>",
"id": "<string>",
"machineId": "<string>",
"host": "<string>",
"port": 123,
"token": "<string>",
"command": "<string>",
"hostKeyFingerprint": "<string>",
"moshCommand": "<string>",
"expiresAt": "2023-11-07T05:31:56Z"
}{
"error": {
"code": "unauthenticated",
"message": "<string>",
"requestId": "<string>",
"retryable": true,
"operationId": "<string>",
"reason": "missing_key",
"hint": "<string>",
"docs": "<string>",
"docs_url": "<string>",
"requiredScopes": [
"<string>"
],
"retryAfterSeconds": 2,
"at": "2023-11-07T05:31:56Z"
}
}{
"error": {
"code": "unauthenticated",
"message": "<string>",
"requestId": "<string>",
"retryable": true,
"operationId": "<string>",
"reason": "missing_key",
"hint": "<string>",
"docs": "<string>",
"docs_url": "<string>",
"requiredScopes": [
"<string>"
],
"retryAfterSeconds": 2,
"at": "2023-11-07T05:31:56Z"
}
}{
"error": {
"code": "unauthenticated",
"message": "<string>",
"requestId": "<string>",
"retryable": true,
"operationId": "<string>",
"reason": "missing_key",
"hint": "<string>",
"docs": "<string>",
"docs_url": "<string>",
"requiredScopes": [
"<string>"
],
"retryAfterSeconds": 2,
"at": "2023-11-07T05:31:56Z"
}
}{
"error": {
"code": "unauthenticated",
"message": "<string>",
"requestId": "<string>",
"retryable": true,
"operationId": "<string>",
"reason": "missing_key",
"hint": "<string>",
"docs": "<string>",
"docs_url": "<string>",
"requiredScopes": [
"<string>"
],
"retryAfterSeconds": 2,
"at": "2023-11-07T05:31:56Z"
}
}{
"error": {
"code": "unauthenticated",
"message": "<string>",
"requestId": "<string>",
"retryable": true,
"operationId": "<string>",
"reason": "missing_key",
"hint": "<string>",
"docs": "<string>",
"docs_url": "<string>",
"requiredScopes": [
"<string>"
],
"retryAfterSeconds": 2,
"at": "2023-11-07T05:31:56Z"
}
}Authorizations
Opaque instabox access token (1 hour). Refresh with /v1/auth/refresh (refresh token valid 30 days, rotates on use).
Path Parameters
Sandbox ID (m_ + 26 lowercase base32 characters).
^m_[a-z2-7]{26}$Body
Optional display name; whitespace is trimmed, at most 100 UTF-8 bytes. Existing callers may omit it.
Default 604800 (7 days), max 2592000 (30 days).
1 <= x <= 2592000A token that works until it is revoked: the reply has no expiresAt. Does not go with ttlSeconds.
Response
Token issued.
Connection ID (cn_…) of the token's grant.
ibssh_ and 26 lowercase base32 characters (128 bits): the SSH user name. Shown only here.
ssh -p <port> <token>@<host> (without -p on port 22).
SHA256 fingerprint of the SSH server's host key, which ssh asks to confirm on the first connection.
The same login with mosh: mosh --ssh="ssh -p <port>" <token>@<host> (mosh <token>@<host> on port 22). Absent when mosh is not available.
Absent: the token does not expire (noExpiry).
Was this page helpful?