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 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 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
200 returns the box.
The call needs write access to boxes in your organization, and it is recorded in your organization’s audit trail.
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
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 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
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.
