curl --request POST \
--url https://api.instabox.sh/v1/machines/{id}/ports \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"port": 33279,
"name": "<string>",
"rotateToken": true
}
'import requests
url = "https://api.instabox.sh/v1/machines/{id}/ports"
payload = {
"port": 33279,
"name": "<string>",
"rotateToken": 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({port: 33279, name: '<string>', rotateToken: true})
};
fetch('https://api.instabox.sh/v1/machines/{id}/ports', 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}/ports",
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([
'port' => 33279,
'name' => '<string>',
'rotateToken' => 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}/ports"
payload := strings.NewReader("{\n \"port\": 33279,\n \"name\": \"<string>\",\n \"rotateToken\": 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}/ports")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"port\": 33279,\n \"name\": \"<string>\",\n \"rotateToken\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.instabox.sh/v1/machines/{id}/ports")
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 \"port\": 33279,\n \"name\": \"<string>\",\n \"rotateToken\": true\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"machineId": "<string>",
"port": 123,
"name": "<string>",
"url": "<string>",
"access": "public",
"createdAt": "2023-11-07T05:31:56Z",
"protocol": "http",
"address": "<string>",
"token": "<string>",
"tokenUrl": "<string>",
"expiresAt": null
}{
"id": "<string>",
"machineId": "<string>",
"port": 123,
"name": "<string>",
"url": "<string>",
"access": "public",
"createdAt": "2023-11-07T05:31:56Z",
"protocol": "http",
"address": "<string>",
"token": "<string>",
"tokenUrl": "<string>",
"expiresAt": null
}{
"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"
}
}Give one HTTP port of a sandbox an HTTPS URL, public or private.
API keys require machines:write. Also accepts the sandbox-local port credential.
With access omitted or public, anyone with the returned URL can reach the whole
service on that port. With access: private the URL answers only requests that carry
the port’s token: the tokenUrl of this response (the URL with ?_token=, which a
browser opens once; the proxy redirects it to the URL without the token and sets the
__Host-instabox_port_auth cookie), that cookie, or Authorization: Bearer <token>.
Other requests get 401 (403 for a wrong _token) without waking the sandbox. The
token is returned only by the publish that created or rotated it; the server keeps
its hash. The URL stays until the port is unpublished and answers only while the
sandbox runs; stopped or paused, it returns 503. Publishing a published port again
keeps its URL and sets its name when given; access changes who can reach it and
rotateToken (private ports) replaces the token, both closing the connections that
used the old access, like an unpublish. Publishing does not start a server on the
port. At most 16 ports per sandbox.
curl --request POST \
--url https://api.instabox.sh/v1/machines/{id}/ports \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"port": 33279,
"name": "<string>",
"rotateToken": true
}
'import requests
url = "https://api.instabox.sh/v1/machines/{id}/ports"
payload = {
"port": 33279,
"name": "<string>",
"rotateToken": 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({port: 33279, name: '<string>', rotateToken: true})
};
fetch('https://api.instabox.sh/v1/machines/{id}/ports', 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}/ports",
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([
'port' => 33279,
'name' => '<string>',
'rotateToken' => 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}/ports"
payload := strings.NewReader("{\n \"port\": 33279,\n \"name\": \"<string>\",\n \"rotateToken\": 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}/ports")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"port\": 33279,\n \"name\": \"<string>\",\n \"rotateToken\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.instabox.sh/v1/machines/{id}/ports")
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 \"port\": 33279,\n \"name\": \"<string>\",\n \"rotateToken\": true\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"machineId": "<string>",
"port": 123,
"name": "<string>",
"url": "<string>",
"access": "public",
"createdAt": "2023-11-07T05:31:56Z",
"protocol": "http",
"address": "<string>",
"token": "<string>",
"tokenUrl": "<string>",
"expiresAt": null
}{
"id": "<string>",
"machineId": "<string>",
"port": 123,
"name": "<string>",
"url": "<string>",
"access": "public",
"createdAt": "2023-11-07T05:31:56Z",
"protocol": "http",
"address": "<string>",
"token": "<string>",
"tokenUrl": "<string>",
"expiresAt": null
}{
"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
Desktop port 5901 and Orca port 6768 (plus the configured Orca port) are reserved.
1024 <= x <= 65535Omitted: the current name, or "Port N" for a new port.
100Omitted: the current protocol, or http for a new port. tcp publishes a raw TCP service behind TLS when the server enables it (403 otherwise; admins only while in preview); paid plans only, at most 5 per org by default (429). A port already published with the other protocol answers 409 until it is unpublished. A tcp port cannot be private (400).
http, tcp Omitted: the current access, or public for a new port. Changing it ends the old publication's connections. private is for http ports only.
public, private With a private port: a new token, returned in the response; connections that used the old one close. 400 for a public port.
Response
The port was already published; its name, access or token is updated when asked.
The publication's ID; a new one after an unpublish, an access change or a token rotation. The URL does not change.
https://<port>-<sandbox>.<domain> for http, tls://<address> for tcp. Empty when public ports (or raw TCP ports) are not configured.
public: anyone with the URL. private: only requests that carry the port's token (_token query parameter once, the cookie it sets, or Authorization: Bearer).
public, private http: an HTTPS URL. tcp: a raw TCP service behind TLS at address, routed by SNI, always public (docs/public-ports.md, "Raw TCP ports").
http, tcp tcp only: the TLS endpoint host:port; the client must send the host as SNI. psql: host=<host> port=<port> sslmode=require.
A private port's token (ibp_...), only in the publish response that created or rotated it.
url with ?_token=<token>: the link to share. Present with token.
Always null (public ports do not expire); kept for older in-guest instabox-port agents.
Was this page helpful?