# Create a preview code

Collection: api
Human docs: https://zei.sh/docs/api

Mint temporary HTTP browser or agent access to an exposed port.

POST /public/sandboxes/:sandboxId/preview-codes
Permission: MACHINE_READ.
Use the browser handoff URL for a real browser and base_url with the bearer code for fetch, WebSocket, Playwright, or CDP.
Request body: {"port":3000,"ttl_seconds":300,"path":"/health"}
Response: url, handoff_url, base_url, code, and expires_at.
TTL is 1 through 3600 seconds. Do not append paths to the browser handoff URL.

Example:

```
curl -X POST https://api.zei.sh/api/v1/public/sandboxes/:sandboxId/preview-codes \
  -H "X-API-Key: $ZEISH_API_KEY"
  -H "Content-Type: application/json" \
  -d '{"port":3000,"ttl_seconds":300,"path":"/health"}'
```
