NetworkSpec. Dialing a box port from your own code is a different job, and Network covers it.
The routes on this page live under
/api/box/... — the platform API, which is a separate surface from the SDK REST API at /v1/boxes/... used everywhere else in these docs. The singular box and the missing version segment are intentional, not typos.Prerequisites
- An API key exported as
BOXLITE_API_KEY, and the base URL asBOXLITE_REST_URL. See API keys. - A running box with a service listening on a TCP port, bound to
0.0.0.0. - Write access to boxes in your organization, for the public flag.
Inbound: who can reach a box
A box is private or public, and any single port on it can be shared through a preview URL. Those are two independent decisions: the flag governs the box, the URL governs one port.A new box is private
Inbound access is disabled unless you ask for it. Create a box without saying anything about inbound and nothing outside it can reach its services — which is the posture you want for almost every box, and the reason you rarely need the public flag at all. Ask for the other posture at creation time withinbound:
mode takes "enabled" or "disabled", and "disabled" is what you get by omission.
Writing it out explicitly sends the same request as leaving it off — it documents the
intent for the next reader, nothing more.
The SDK does not read this back:
BoxInfo.network is None on Cloud, so you cannot
check a box’s inbound posture from await box.info(). Read it from the box’s row in
the console instead.InboundNetworkSpec carries an allow_net field for symmetry with the outbound side,
but no layer enforces an inbound allowlist, so a non-empty value is refused before the
request leaves your process:
mode alone. To let one audience in rather than everyone, keep
the box private and share a signed URL.
You are not locked in: the public flag below flips an existing box either way, without
recreating it or losing its filesystem.
Where to do each of these
Most of this section is shown as HTTP because that is the only surface some of it has. Two of the four operations are also in the console, and those are the ones you will reach for by hand:
The SDK’s network handle exposes
tunnel(port) and nothing else, and boxlite network has only tunnel, so neither can change inbound or mint a preview URL.
Reach for HTTP when you are automating; reach for the console when you are not.
A preview URL and an SDK tunnel are different tools
A preview URL is an HTTPS address for one port on one box, served by BoxLite’s preview proxy. Anything that speaks HTTPS can fetch it — a browser,curl, a webhook sender, a reviewer on their phone — and none of them needs the BoxLite SDK.
An SDK tunnel is the other shape. Your code asks the box for a tunnel and dials it with your API key, and the tunnel carries any TCP protocol rather than only HTTP.
Reach for a preview URL when something outside your own code has to fetch an HTTP service in the box: a browser preview, a webhook receiver, a link you send someone. Reach for a tunnel when your program is the client, or when the protocol is not HTTP — SSH, a database wire protocol, a raw byte stream. Tunnels are documented on Network.
Make a box public or private
- Console
- HTTP
Open the box, find the network panel, and use the Inbound access switch.The panel states the current posture in the terms that matter:
Turning it on asks you to confirm — “Open this box’s preview URLs to anyone?” —
because that is exactly what it does.
outbound on the same panel is read-only:
nothing changes a box’s egress after it is created.false. A URL is a string — it travels in chat messages, tickets, browser history, referrer headers, and screenshots. Anything the service in that box can read or write is now guarded by the secrecy of a link, so treat the box’s files, its environment variables, and its network credentials as exposed for as long as the flag is on. Set it back to private the moment you no longer need it:
Get a preview URL for a port
- Console
- HTTP
On the box’s network panel, choose get url and type the port.
That button is disabled while inbound is disabled. The HTTP route is not — it
returns a URL and a token for a private box too, which is what the token flow below
is for. If get url is greyed out and you expected otherwise, the box is private,
not broken.
8080 and a metrics endpoint on 9090 has two preview URLs, and you fetch each one separately. Change the port your service listens on and the old URL no longer describes it.
Present the token when the box is private
A private box’s preview URL is not open, so a request has to carry thetoken from the response above. The preview proxy accepts it three ways, and tries them in this order:
Share a port temporarily with a signed URL
Signed URLs are HTTP-only. There is no console control and no SDK or CLI method
for issuing or revoking one, so the calls below are the whole of it.
expiresInSeconds is an optional query parameter, and the default is 60 seconds. Sixty seconds is the right size for a link your own code generates and redirects to immediately; pass a larger value when a person has to open it, read it, and click around.
200 returns:
Generate a fresh signed URL per recipient and per sharing session rather than reusing one. Each is independently revocable, so one leaked link is one link you can kill.
Revoke a signed URL before it expires
token in the path is the token field from the signed-URL response — that is the reason to keep it rather than discarding everything but the url. A 200 returns no body.
Choose between the three
The order matters: start private, escalate to a signed URL when a human needs to see something, and reserve the public flag for a box whose contents you would publish deliberately.
Outbound: what the box can reach
Outbound is a per-box setting you make at creation, not a toggle you flip afterwards. Pass aNetworkSpec as the network field of BoxOptions, and the SDK sends that specification — the mode and the allowlist — to Cloud as part of the create call.
There are exactly two modes, enabled and disabled, plus the allow_net allowlist that narrows egress to named hosts. The NetworkSpec parameter table, the useful mode and allowlist combinations, and the verification recipe live on Network access, which owns them.
One property of the allowlist decides whether you can debug it. A host outside the allowlist is a DNS sinkhole, not a connection error: it resolves to 0.0.0.0. Your code therefore reports a failed connection to 0.0.0.0 rather than a refusal or a policy message, and a nslookup of a blocked host can still exit 0 because the lookup itself succeeded. Read the resolved address, never the exit code, when you want to know what a box’s DNS returned for a host.
mode="disabled" is the other end of the range. The mode means a box with no network interface at all: DNS and every outbound connection fail, while commands and file operations work as normal. That is the mode to ask for when a box’s only job is to run code you do not trust with a network. Network access documents both modes in full.
One more thing to know about a box you did not configure yourself. A box created without a network field inherits your organization’s default, and that default can be limited egress rather than open egress — so a box that resolves fewer hosts than you expect may be following the organization default rather than misbehaving. That default is set at the platform level; it is not a field of BoxOptions and not part of the boxes API.
Troubleshooting
Next steps
Network
Dial a port inside a box from your own code with an SDK tunnel, for HTTP, WebSocket, or any TCP protocol.
Boxes on Cloud
Images, sizes, and the lifecycle controls that decide whether a shared URL still has a box behind it.
Network access
The
NetworkSpec parameter table and the egress allowlist in full.
