Skip to main content
If your sandbox is running a dev server or API on some port, a preview turns that port into an HTTPS URL a browser can open. See Previews for the full field reference; this guide walks through creating one, choosing an auth mode, and cleaning up.

Create a preview

port must be 1024–65535 — privileged ports are never previewable. Create returns 201 with the created preview plus a capability_jws — that token is returned only on create, never again from list, so hold onto it if you need the token-mode exchange below.

Token vs. public auth

auth_mode (REST) / auth (SDK) is one of two values:
  • token (default) — access is gated by a one-time browser exchange (below). This is what you want for anything not meant to be open to the internet.
  • public — anyone with the URL can view it, no credential at all. The only thing protecting a public preview is the 26 random characters in its hostname. Use this deliberately, for demos or sharing outside your organization — not as the default.
The CLI marks public preview URLs in its output as a reminder of what you just did.

The token-mode browser exchange

In token mode, a browser needs to trade the capability_jws for a session cookie once before it can view the preview. At a high level: navigate to preview.url with ?bonya_token=<capability_jws> appended, and Roxy (the preview proxy) validates the token, sets a host-scoped Secure/HttpOnly cookie, and redirects to the same URL with the token stripped — before any guest content renders. See Previews for the exact mechanics. You don’t have to build that URL by hand — the TypeScript, Python, and Go SDKs each expose a helper that does it for you:
This throws/raises/errors if called on a public preview, since there’s no token to exchange.
Don’t store capability_jws in a URL, log, or anywhere durable beyond the single navigation described above — it’s a bearer credential for the preview.

List and delete

List never includes capability_jws — only create does. Delete is idempotent and deliberately doesn’t distinguish “already deleted” from “belongs to another organization,” so it always returns 204.

Previews

Sandboxes