Guide 07 · deploy in one call
Instant full-stack previews of AI-generated apps
Building a v0-style app generator? One API call takes your agent's output from
files to a running server with a shareable HTTPS URL — files in, deps installed, process
started, app_url back.
1
One request, running app
curl -X POST $BASE/v1/sandboxes -H "Authorization: Bearer $KEY" -d '{ "template": "node", "files": [{"path": "/app/server.js", "content": "…generated app…"}, {"path": "/app/package.json", "content": "…"}], "setup": ["cd /app && npm install"], "start": "node /app/server.js", "port": 3000, "public": true, "timeout": 3600 }' # → { "id": "sb_…", "app_url": "https://3000-sb_….yourdomain.com", "deploy_log": "…" }
Two rules that trip people up. Your app must bind the port you
declared (hardcoding a different one is the #1 cause of preview 502s — the injected
$PORT is there for exactly this). And previews are private by default:
without "public": true (CLI: --public) the URL returns a
“Private sandbox” page unless the request carries the access token.2
Embed it
Drop app_url straight into an iframe next to your chat UI. Every regeneration
is a fresh sandbox — old previews expire on their own timeout.
3
Debug failed builds
deploy_log carries setup output; GET /v1/sandboxes/{id}/logs streams
the running server. Feed both back to the model to self-heal the build.