devbox.exposedPorts to publish an HTTP server running on a Devbox at a devbox.so URL, and to list and remove the URLs a Devbox exposes.
Exposed port operations start a stopped Devbox automatically.
devbox.so URLs work and who can open them.
exposedPorts.create()
Use exposedPorts.create() to expose an HTTP port and get its URL.
Example
API reference
Arguments and options
ExposedPort
required
The port to expose.
OperationOptions
Supports
signal and timeoutMs. See Handle errors and timeouts.Return value
exposedPorts.create() resolves with the ExposedPortInfo for the new port, including its url. It throws a RangeError for an invalid port number and a TypeError for an empty name, before contacting the Devbox.
exposedPorts.get()
Use exposedPorts.get() to look up one exposed port by ID, name, or number.
Example
API reference
Arguments and options
ExposedPortSelector
required
The port to look up. See
ExposedPortSelector.OperationOptions
Supports
signal and timeoutMs. See Handle errors and timeouts.Return value
exposedPorts.get() resolves with the matching ExposedPortInfo. It lists the Devbox’s exposed ports and selects the match on the client. It rejects with ExposedPortNotFoundError when no port matches.
exposedPorts.list()
Use exposedPorts.list() to list the HTTP ports a Devbox exposes.
Example
API reference
Arguments and options
OperationOptions
Supports
signal and timeoutMs. See Handle errors and timeouts.Return value
exposedPorts.list() resolves with an ExposedPortInfo for each HTTP port the Devbox agent reports, including ports owned by Namespace. Check owner to distinguish them. Port forwards are not included.
exposedPorts.delete()
Use exposedPorts.delete() to stop exposing a port. The process listening on the port keeps running.
Example
API reference
Arguments and options
ExposedPortSelector
required
The port to stop exposing. See
ExposedPortSelector.OperationOptions
Supports
signal and timeoutMs. See Handle errors and timeouts.Return value
exposedPorts.delete() resolves when the port is no longer exposed. It rejects with ExposedPortNotFoundError when no port matches the selector.
Exposed port types
ExposedPortInfo
string
required
The port ID.
string
The port name, when one is set.
number
required
The port number.
string
required
The
devbox.so URL that serves the port."user" | "namespace" | "unknown"
required
Who manages the port.
ExposedPortSelector
Selects a port by exactly one of id, name, or number. Passing none or more than one throws a TypeError.
Related documentation
Shareable URLs
Learn how devbox.so URLs work.
Run services
Supervise the servers you expose.
Handle errors and timeouts
Cancel operations and handle SDK failures.