Preview
The Daytona SDK provides methods to generate preview links for accessing Sandboxes. Any process listening for HTTP traffic on ports 3000–9999 can be previewed.
Daytona offers two approaches for preview URLs, each with different authentication mechanisms: Standard Preview URL and Signed Preview URL.
Authentication
If the Sandbox has its public property set to true, preview links will be publicly accessible without authentication. Otherwise, authentication is required.
For private sandboxes, the authentication differs based on the preview URL type.
Standard Preview URL
The standard preview URL uses your sandbox ID in the URL structure and requires a separate authentication token sent via header.
URL Structure: https://{port}-{sandboxId}.{daytonaProxyDomain}
How it works:
- The URL contains the port and your sandbox ID
- A separate authentication token is provided
- The token must be sent in the
x-daytona-preview-tokenrequest header - The token automatically resets when the sandbox restarts
When to use:
- Programmatic access and API integrations where you control the HTTP headers
- Internal tools where token management through headers is straightforward
preview_info = sandbox.get_preview_link(3000)
print(f"URL: {preview_info.url}")print(f"Token: {preview_info.token}")
# Use with requestsimport requestsresponse = requests.get( preview_info.url, headers={"x-daytona-preview-token": preview_info.token})const previewInfo = await sandbox.getPreviewLink(3000);
console.log(`URL: ${previewInfo.url}`);console.log(`Token: ${previewInfo.token}`);
// Use with fetchconst response = await fetch(previewInfo.url, { headers: { 'x-daytona-preview-token': previewInfo.token }});preview_info = sandbox.preview_url(3000)
puts "Preview link url: #{preview_info.url}"puts "Preview link token: #{preview_info.token}"See: get_preview_link (Python SDK), getPreviewLink (TypeScript SDK), preview_url (Ruby SDK)
Authentication
The URL uses the sandbox ID, and authentication is done via header:
# URL structure: port-sandboxid.domaincurl -H "x-daytona-preview-token: vg5c0ylmcimr8b_v1ne0u6mdnvit6gc0" \ https://3000-sandbox-123456.proxy.daytona.workSigned Preview URL
The signed preview URL embeds the authentication token directly into the URL structure itself, eliminating the need for separate authentication headers.
URL Structure: https://{port}-{token}.{daytonaProxyDomain}
How it works:
- The URL contains the port and the signed authentication token (instead of the sandbox ID)
- Authentication is embedded in the URL - no headers needed
- You set a custom expiry time for the token (defaults to 60 seconds)
- The token persists across sandbox restarts until it expires
- You can manually revoke tokens before they expire if needed
When to use:
- Sharing preview links with users who can’t easily set custom headers
- Embedding in iframes, emails, or other contexts where header control is limited
- Creating time-limited shareable links with explicit expiration
- Webhooks and integrations that don’t support custom headers
# Create a signed preview URL that expires in 3600 seconds (1 hour)signed_url = sandbox.create_signed_preview_url(3000, expires_in_seconds=3600)
print(f"URL: {signed_url.url}") # Token is embedded in the URLprint(f"Token: {signed_url.token}") # Can be used to revoke access
# Use directly - no headers neededimport requestsresponse = requests.get(signed_url.url)
# Revoke the token before expiry if neededsandbox.expire_signed_preview_url(3000, signed_url.token)// Create a signed preview URL that expires in 3600 seconds (1 hour)const signedUrl = await sandbox.getSignedPreviewUrl(3000, 3600);
console.log(`URL: ${signedUrl.url}`); // Token is embedded in the URLconsole.log(`Token: ${signedUrl.token}`); // Can be used to revoke access
// Use directly - no headers neededconst response = await fetch(signedUrl.url);
// Revoke the token before expiry if neededawait sandbox.expireSignedPreviewUrl(3000, signedUrl.token);# Create a signed preview URL that expires in 3600 seconds (1 hour)signed_url = sandbox.create_signed_preview_url(3000, expires_in_seconds=3600)
puts "URL: #{signed_url.url}"puts "Token: #{signed_url.token}"See: create_signed_preview_url (Python SDK), getSignedPreviewUrl (TypeScript SDK), preview_url (Ruby SDK)
Authentication
The URL embeds the token in place of the sandbox ID - no headers needed:
# URL structure: port-token.domain (token is in the URL itself)curl https://3000-eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.proxy.daytona.workWarning Page
When opening the preview link in a browser, a warning page will be shown for the first time. This warning serves as a security measure to inform users about the potential risks of visiting the preview URL.
The warning page will only be shown when loading the preview link in a browser.
To avoid this warning you can do one of the following:
- Send the
X-Daytona-Skip-Preview-Warning: trueheader - Upgrade to Tier 3
- Deploy your own custom preview proxy