Guides
Environments
Run production, staging and other environments of one project, plus a preview environment per pull request, each with its own URL, secrets, databases and deploys.
A project starts with one environment, production. You can add more, for example staging or qa: up to 5 per project, production included. Each environment has its own URL, secrets (ctx.env), databases, storage, Auth users, jobs, email and push settings, logs, deploys and backups. Members, roles, deploy keys, the linked repository, the slug and the custom domains belong to the project and apply to every environment. Production is the default: every deploy goes there unless it names another environment, so existing projects work exactly as before. On top of these, a project can have up to 10 preview environments (pr-<number>), short-lived copies of an environment such as staging for one pull request; see Preview environments (#previews).
Create an environment
- Dashboard: the environment selector in the top bar (Organisation / Project / Environment) → New environment, or the project's Environments page (/projects/:id/environments) → New environment.
- CLI: robodev env create staging [--from production] [--branch staging]. See CLI reference (/docs/cli#env-create).
- MCP: create_environment { project_id, name, copy_from?, branch? } on robodev mcp or the hosted Robodev connector.
- REST: POST /v1/projects/:id/environments with { name, copyFrom?, branch? } returns 201 with the environment.
Names are 2–20 characters: lowercase letters, digits and single hyphens, starting with a letter and not ending with a hyphen. Names starting with pr- are reserved, and a name can't already be in use: the default environment is called production until you rename it. A new environment starts with its own empty databases (created by its first deploy), empty storage and no Auth users. With Copy env vars from (copyFrom / --from / copy_from) it also gets a one-time copy of that environment's secrets, Auth settings, email templates and push settings; nothing is copied without it. The copy is never live-linked: changing a value in either environment later does not change the other. Jobs and crons come from the code you deploy.
Choose the deploy target
The target is picked in this order: an explicit environment, then a branch mapping (managed GitHub workflow only), then production. An unknown name fails with 404 environment_not_found and never creates an environment.
- CLI: robodev deploy --env staging, or ROBODEV_ENV=staging (the flag wins). robodev-be deploy --env staging works the same way.
- MCP: the optional environment argument on publish_backend_file, publish_backend_files and publish_frontend_files.
- REST: POST /v1/projects/:id/deploy?environment=staging (also on the deploy-blob routes), or call the deploy route with the environment's own project id.
- The deploy answer names the environment and returns its apiUrl, appUrl and docsUrl.
Branch deploys
Each environment, production included, can map one git branch, and a branch maps to one environment only. Set it when you create the environment or later with Edit branch on the Environments page (PATCH /v1/projects/:id/environments/:env with { branch }). Production's branch defaults to the repository's default branch.
With a linked repository, the managed workflow (.github/workflows/robodev-starbase.yml) runs on a push to any branch. A short target job asks Starbase which environment the branch deploys to (GET /v1/projects/:id/environments/resolve?branch=&defaultBranch=); the deploy job runs only when it names one, and passes it as ROBODEV_ENV. A push to an unmapped branch deploys nothing. When a pull request closes or merges, the same workflow deletes its preview environment pr-<number>, if there is one (a cleanup-preview job; pull requests from forks are skipped). The current version (4) also ignores pushes that only change .github/workflows/robodev-preview.yml, so turning PR previews on never starts a deploy. Repositories linked before environments keep the old workflow, which deploys production from the default branch, and repositories linked before previews keep one without the cleanup; run Repair in Settings › Repository to update it. The Environments page tells you when that is needed.
Production always wins its own branch: its mapped branch, or the repository's default branch when it has none. If another environment mapped that branch before a repository was linked, pushes to it still deploy production, and the dashboard refuses new mappings to it (branch_in_use). If the target job cannot reach Starbase or gets an unexpected answer, the run fails rather than skipping the deploy.
If the repository has its own robodev:deploy script (Tiny templates), the workflow runs it for production only. Every other environment deploys with the pinned CLI, bunx robodev@0.85.0 deploy --env <name>, because an older robodev in the repository would ignore the environment and deploy to production. To use a script of your own for other environments, call robodev 0.82.0 or newer with --env from it in your own CI.
Without a linked repository, a branch is stored but nothing reads it. Deploy from your own CI instead, for example a GitHub Actions job that runs on pushes to staging:
Plain robodev deploy never reads the git branch, so CI that already deploys production keeps doing so.
URLs
- Production keeps https://{slug}.robodev.povio.dev, its Default URL https://{projectId}.robodev.povio.dev and its custom domains.
- Another environment is served at https://{slug}--{env}.robodev.povio.dev, for example acme--staging.robodev.povio.dev. When the project has no slug, the name would be longer than 63 characters, or the host is already taken, the environment is served at its own https://{environmentId}.robodev.povio.dev instead. The dashboard, robodev env url and the API always show the URL that works.
- Changing the project's slug moves every environment's URL with it.
- Rename any environment with Rename on the Environments page, or PATCH /v1/projects/:id/environments/:env with { name }. Its id, data, secrets and branch stay. Anything that names it (--env, ROBODEV_ENV, ?environment=, MCP environment) must use the new name; the old one stops working. The running app sees the new name from its next deploy.
- Renaming another environment moves its URL to {slug}--{new name}.
- Renaming production (the default environment) keeps its URLs and custom domains, and deploys without a name still go to it. Its old name, production, is then free for another environment. A project that only runs staging can call its default environment staging.
- Custom domains are per environment: add them in Settings → Custom domains with that environment selected (or POST /v1/projects/{environmentId}/domains). A domain serves only its own environment, and that environment's primary domain becomes its URL.
Env vars and secrets
Secrets are per environment. Settings → Secrets shows the environment selected in the top bar. From the CLI: robodev secrets set STRIPE_KEY --env staging (also list and delete). From MCP: set_secret, list_secrets and delete_secret with environment. Values stay write-only everywhere, including the one-time copy at creation. See Secrets (/docs/secrets).
Databases and storage
Each environment has its own Postgres databases, created from robodev/database.ts by its first deploy, and its own storage. Production data is never shared with another environment, and deploying to staging only changes staging's schema. Backups run for every environment and restore into a new project, as for production.
Limits and errors
- 400 invalid_environment_name — the name breaks the rule above.
- 400 reserved_environment_name — a pr-* name.
- 409 environment_exists — the project already has an environment with that name (production, until the default environment is renamed).
- 409 environment_limit_reached — a project can have up to 5 environments, including production.
- 400 invalid_branch — branches are 1–255 characters, without spaces or control characters, not starting with - and not ending in .lock.
- 409 branch_in_use — another environment already deploys from that branch (production's own branch included).
- 404 environment_not_found — no environment with that name (deploy, copyFrom, PATCH, DELETE).
- 400 production_environment_required — production can't be deleted; delete the project instead.
- 400 environment_not_supported — a project-wide route (members, deploy keys, repository, slug, custom domains, security reviews, rename or delete project) was called with an environment's id. Use the project id.
- 403 user_required — creating, changing or deleting a standard environment needs a signed-in user, not a deploy key.
- 400 source_not_allowed — a preview was asked to copy production or another preview.
- 400 invalid_pr_number — the pull request number is not a whole number from 1 to 999999999.
- 400 invalid_ttl — previews expire after 3 to 14 days.
- 400 source_required — a preview needs from, the environment to copy.
- 409 preview_limit_reached — a project can have up to 10 preview environments (failed ones count until deleted).
- 409 environment_not_ready — a deploy, upload or restart on a preview that is still copying its databases, or whose copy failed.
- 503 pg_client_missing — this Starbase has no pg_dump and pg_restore 17 or newer, so it can't create previews.
- 400 preview_not_supported — a preview's branch is informational and can't be changed with PATCH; use env preview create --if-missing --branch.
- 409 environment_in_use — PR previews copy this environment; choose another source or turn PR previews off in Settings › Repository before deleting it.
- 400 preview_source_invalid, 400 invalid_preview_label — the PR previews setting needs a standard non-production source and a 1–50 character label.
- 409 workflow_missing, 409 workflow_customized — turning PR previews on needs the managed robodev-starbase.yml; run Repair first, or rename a hand-edited one.
- 409 confirmation_required, 409 repository_changed — saving PR previews needs the reviewed file changes; the answer carries the fresh plan.
Permissions
- List environments, resolve a URL or branch, deploy to any environment, and manage its secrets, logs and worker: project Admins, project Developers, organization admins and the project's deploy key.
- Create an environment, rename it or change its branch: project Admins, project Developers and organization admins (signed in).
- Delete an environment: project Admins and organization admins (signed in).
- Run Repair in Settings › Repository (updates the managed GitHub workflow): project Admins, project Developers and organization admins (signed in), when the organization has the repository provider attached.
- Create or delete a preview environment: project Admins, project Developers, organization admins and the project's deploy key, so CI can manage previews on its own.
Preview environments
A preview environment is a short-lived copy of a standard environment for one pull request. It is always named pr-<number> and served at https://{slug}--pr-{number}.robodev.povio.dev (or its own https://{environmentId}.robodev.povio.dev, as for other environments). Create it from staging or any other environment except production: production data is never copied into a preview, and a preview can't be copied either.
- Copied once at creation, and never live-linked: env vars (secrets, without ever leaving the server), Auth settings, email templates, push settings, and every database of the source: all of its tables, indexes, functions and other structure, but only the Auth users' rows (Robodev Auth's own tables; sign-in sessions are left out). Your app's tables, queued jobs and storage start empty, so a preview stays small whatever the source holds; seed test data in the preview if a pull request needs it. Changing the source later does not change the preview, and writes to the preview never reach the source.
- Not copied: storage starts empty, there are no deploys yet, and queued jobs, sign-in sessions and refresh tokens from the source are dropped from the copy, so users sign in again and no source job runs twice.
- Copying the databases runs in the background (pg_dump and pg_restore). Until it is done the preview is Creating…: secrets and logs work, but deploys, uploads and restarts answer 409 environment_not_ready. If the copy fails, the preview is marked Failed with the reason; delete it and create it again.
- Expiry: 7 days by default, 3 to 14 days with --ttl / ttlDays. Every successful deploy to the preview moves its expiry to that many days from the deploy. Starbase deletes expired previews, failed ones included.
- Cleanup: the managed GitHub workflow deletes pr-<number> when the pull request closes or merges, and the recipe below does too. A preview you created by hand goes away when it expires, or delete it yourself: robodev env delete pr-12 --yes, delete_environment, or Delete on the Environments page.
- Limits: up to 10 previews per project, separate from the 5 standard environments. Previews are not backed up and do not count towards the plan.
- The branch you give a preview is shown in lists only. Pushes to it never deploy the preview through the managed workflow; deploy with robodev deploy --env pr-12.
- Copied secrets are copies: a value such as PUBLIC_URL that holds the source's URL keeps it. Override it with robodev secrets set PUBLIC_URL --env pr-12.
- If the source environment is deleted later, its previews keep working and keep showing where they came from.
PR previews for a linked repository
With a repository linked through Starbase, anyone who can run Repair (project Admins, project Developers and organization admins, when the organization has the repository provider attached) turns on PR previews in Settings › Repository: the environment to copy (any standard environment except production), the trigger (every pull request, or pull requests with a label, preview by default) and the expiry (3 to 14 days). Saving shows exactly what Starbase will commit to the default branch and asks you to confirm: it adds .github/workflows/robodev-preview.yml (and updates robodev-starbase.yml to version 4 when it is older), in one commit that never deploys and never rotates the deploy key. Turning it off deletes the file the same way.
- The workflow reads the setting from Starbase on every run, so changing the source, trigger, label or expiry needs no commit and applies to the next push.
- For each open same-repo pull request it runs robodev env preview create --if-missing, then robodev deploy --env pr-<number> --force with the pinned robodev 0.85.0 (never the repository's own robodev:deploy script), and keeps one comment on the pull request with the URL and expiry. The comment needs pull-requests: write, which the workflow asks for; if it can't comment, the preview still deploys.
- With a label: adding the label creates and deploys the preview, pushes redeploy it while the label is on, and removing the label deletes it. Closing or merging the pull request deletes it through robodev-starbase.yml; Starbase deletes it when it expires.
- Runs for one pull request wait for each other. When its turn comes, a run checks the pull request and the setting again: if the pull request has closed or lost the label meanwhile, it deletes the preview instead of deploying. A delete that finds the preview still busy (409 project_cleanup_draining, for example a deploy still running) is tried again for a few minutes before the run fails.
- Pull requests from forks, and runs without the ROBODEV_DEPLOY_KEY secret (such as Dependabot), are skipped.
- Starbase commits the workflow to the default branch. GitHub runs a pull request's workflows from its merge with the base branch, so a pull request into a branch that doesn't contain robodev-preview.yml yet gets no preview until it does.
- Edited it yourself? A robodev-preview.yml without the Managed by Starbase header is yours: Repair leaves it alone, and turning PR previews on offers to replace it.
- While PR previews copy an environment, it can't be deleted (409 environment_in_use).
A preview for every pull request (GitHub Actions)
Without a linked repository, add this workflow yourself. It creates the preview the first time a pull request opens, deploys it on every push, comments its URL on the pull request and deletes it when the pull request closes. It uses the ROBODEV_DEPLOY_KEY repository secret that linking a repository already sets (or create a deploy key in Settings and add it yourself). Pull requests from forks are skipped, because they get no secrets. Save it as .github/workflows/robodev-preview.yml, next to the managed workflow; both deleting the same preview is harmless. If you later turn on PR previews, Starbase offers to replace this file.
--if-missing makes the create step idempotent: when pr-<number> already exists it is left as it is (its data is not copied again), its branch is updated and its expiry refreshed. env preview create waits until the databases are copied (usually seconds), so the deploy step after it finds the preview ready; robodev deploy --env on a preview that is still being created fails with environment_not_ready. Replace staging with the environment the previews should copy.
CLI, MCP and REST
- CLI: robodev env list [--json], robodev env create <name> [--from <env>] [--branch <branch>], robodev env preview create --from <env> --pr <number> [--branch <branch>] [--ttl <days>] [--if-missing] [--no-wait], robodev env url <name>, robodev env delete <name> [--yes] [--if-exists]; --env <name> (or ROBODEV_ENV) on robodev deploy, robodev secrets list|set|delete, robodev logs and robodev restart; robodev-be deploy --env <name>.
- MCP: list_environments, create_environment, create_preview_environment { from, pull_request, branch?, ttl_days? }, delete_environment, and an optional environment on publish_backend_file(s), publish_frontend_files, list_backend_files, read_backend_file, set_secret, list_secrets, delete_secret and restart_worker.
- REST: GET /v1/projects/:id/environments, POST /v1/projects/:id/environments, POST /v1/projects/:id/environments/previews with { from, pullRequest, branch?, ttlDays?, ifMissing? } (202 while the copy runs; 200 with created: false when ifMissing finds it), PATCH /v1/projects/:id/environments/:env, DELETE /v1/projects/:id/environments/:env, GET /v1/projects/:id/environments/resolve?branch=&defaultBranch=, POST /v1/projects/:id/deploy?environment=<name>. :env is an environment name or its id. Per-environment routes (secrets, logs, databases, storage, auth, deploy logs and so on) take the environment's own id from the list. The list answers previews after the standard environments, with kind: "preview" and a preview object (pullRequest, branch, source, status, error, ttlDays, expiresAt). PR previews: PUT /v1/projects/:id/repository/previews with { enabled, from, trigger, label, ttlDays, dryRun?, confirm? } (the same access as Repair; dryRun answers the plan of file changes, confirm echoes its actions), GET /v1/projects/:id/environments/previews/config (members and the deploy key; what the workflow reads), and repository.previews on the environments list.
Agent recipe: call list_environments (or robodev env list --json) first. If staging is missing and the human asked for it, create it with create_environment { name: "staging", copy_from: "production" }. Publish with environment: "staging" and set its secrets with set_secret { environment: "staging" }. Never delete an environment unless the human asks.
Preview recipe: when the human asks for a preview of a pull request, call create_preview_environment { from: "staging", pull_request: 12 }. It waits up to a minute for the database copy; if it is still creating, check list_environments before publishing with environment: "pr-12".