Expose ports from a box with public URLs. Each public URL maps to a specific port and can optionally require authentication.
Quickstart#
Create a public URL#
Start a web server inside your box and create a public URL to access it.
Add authentication#
Protect your public URL with bearer token or basic authentication.
API#
Create Public URL#
Creates a public URL that exposes a port on your box. Returns the URL and authentication credentials if requested.
With Bearer Token#
Add bearerToken: true to require an authorization header when accessing the public URL.
With Basic Authentication#
Add basicAuth: true to require username and password when accessing the public URL.
With Both Auth Methods#
Enable both authentication methods. Either one will work when accessing the public URL.
List Public URLs#
Get all active public URLs for this box.
Delete Public URL#
Remove a public URL by port number.
Behavior#
One Public URL Per Port#
Creating a public URL for a port that already has one will overwrite the previous one, including any auth credentials.
Public URL Lifecycle#
A public URL outlives a pause. While the box is paused, a request to the URL resumes it. See Waking a Paused Box.
Public URLs are removed when the box is deleted.
Waking a Paused Box#
An incoming HTTP request to a public URL resumes its box if the box is paused. The request is held while the box comes back and until the app's port is listening, so the caller gets the app's real response instead of an error. If the public URL requires authentication, the credentials are checked before the box is woken.
The wait is bounded at 30 seconds. If the port is not listening by then, the request returns 503 with a Retry-After: 5 header rather than hanging: a browser gets a page that refreshes itself, and any other client gets a plain 503 to retry. The box keeps resuming in the background, so a retry usually succeeds. Anything slower than 30 seconds to start, such as a cold npm install, should be built into the image or a snapshot instead of left to the init command.
Set a client timeout longer than that window. Both examples below set one explicitly, because some clients default to a shorter timeout than a cold start takes.
For the app to answer on its own after a resume, the box needs to start its server again. An init command does that: the box runs it once every time the container starts, including after a resume.
Auto-Resume#
Creating a public URL on a paused box automatically resumes it.
Examples#
Expose an agent-built app#
Let an agent build a web app, then create a public URL to test it.
Share a secure public URL#
Create a public URL with authentication for sharing with team members.
Multi-port application#
Create multiple public URLs for different services in the same box.
Temporary testing public URL#
Create a public URL, run tests against it, then clean up.
getPreviewUrl, listPreviews, and deletePreview, but they are deprecated aliases for getPublicURL, listPublicURLs, and deletePublicURL.