Skip to main content
Two questions decide a box’s network posture: who is allowed to reach it, and what it is allowed to reach. The inbound half is the public flag and preview URLs; the outbound half is NetworkSpec. Dialing a box port from your own code is a different job, and Network covers it.

Prerequisites

  • An API key exported as BOXLITE_API_KEY, and the base URL as BOXLITE_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 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

Both values travel in the path. There is no request body, and a 200 returns the box. The call needs write access to boxes in your organization, and it is recorded in your organization’s audit trail.
Be clear-eyed about what you just did. A public box drops the credential requirement in front of it: anyone who has a URL to it can reach the service, from anywhere, with no API key and no token, and that holds until you set the flag back to 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:
If what you actually want is to let one person see one port for a short while, do not touch this flag at all — use a signed preview URL instead.

Get a preview URL for a port

A 200 returns: The port is part of the URL, so a preview URL addresses one port, not the whole box. A box running an app on 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 the token from the response above. The preview proxy accepts it three ways, and tries them in this order:
The query-parameter form is what makes a private preview URL openable in a browser: append it once, and the proxy strips the parameter before the request reaches your service, then sets a cookie so the following requests on that host carry the authorization for you. Because that form puts a credential in a URL, treat such a link like a password — it lands in browser history, server logs, and anything the recipient pastes it into. For sharing with a person, a signed URL is the better instrument: it expires on its own and you can revoke it. A request that carries no credential the proxy accepts is redirected to sign in, so a human reaching a private box in a browser can authenticate instead of being refused outright.

Share a port temporarily with a signed URL

This is the call to prefer when you want to hand someone a working link and keep the box private. The signature is what authorizes the request, so the recipient needs no API key and you never flip the public flag — the box stays closed to everyone who does not hold the link, and the link stops working on its own. 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.
A 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

The 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.
Revoke as soon as the review is over, the demo ends, or the link lands somewhere you did not intend. Waiting for an expiry you set generously is a choice to stay exposed.

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 a NetworkSpec 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.