E2B icon

E2B

Run commands and manage E2B sandboxes and snapshots

Sandbox → Get Preview URL

AI-generated

Summary

Return an external HTTPS preview URL exposing a specified port inside an existing sandbox.

Inputs

  • Sandbox ID (required) — ID of the sandbox to get the preview URL for.
  • Port (required) — Port number inside the sandbox to expose via the preview URL.
  • Timeout — Timeout in seconds for the operation (defaults to 300).

Output shape

a single JSON object containing the sandboxId, port, host, and the constructed URL string.

The URL exposes the specified port of the connected sandbox as a public HTTPS endpoint. The output includes host and url fields for direct use. The operation throws an error if the sandbox connection fails or the request encounters issues.

Examples

Example 1: Retrieve the preview URL for port 3000 inside sandbox with ID 'abc123'.

Provide sandboxId='abc123' and port=3000. Use the resulting 'url' field to access the sandbox port externally.

Links

Discussion