
How do we set up Retool environments (staging vs prod) and promote releases safely?
Most teams want the flexibility of rapid iteration in Retool without risking their production data or users. Setting up clear staging vs. production environments—and a reliable way to promote releases—lets you ship confidently while keeping real systems safe.
This guide walks through how to set up Retool environments, connect staging vs prod resources, and promote app and database changes safely.
Why Retool environments matter for safe releases
Retool environments let you:
- Test against staging resources (databases or APIs) before touching real data.
- Keep configuration, secrets, and feature flags separate across environments.
- Safely promote changes from dev/staging to production instead of “cowboy deploying.”
- Inspect and release schema changes to your production database in a controlled way.
At a high level, you’ll typically have:
- Development: For building and experimenting.
- Staging: For realistic end‑to‑end testing.
- Production: For your end users and real data.
Step 1: Plan your environment strategy
Before configuring anything in Retool, define:
-
Environments you need
- Minimal:
staging,production - More mature setups:
dev,staging,production
- Minimal:
-
Ownership and access
- Who can edit in dev/staging?
- Who can publish to production?
- Who can change resource configuration and secrets?
-
Promotion flow
- How does a change move from dev → staging → production?
- When do you require code review or QA?
Having this upfront design helps you use Retool’s environment features intentionally instead of ad‑hoc.
Step 2: Create Retool environments
In Retool, each environment in your Retool instance represents a distinct configuration context. You can:
- Set up multiple environments (for example, staging and production).
- Use environmental configuration variables to define environment‑specific values and secrets.
- Automatically create and configure a Retool Database for each environment so you can safely test and ship changes to production.
Typical setup:
-
Development environment
- Default space for builders.
- Connect to dev databases and test APIs.
-
Staging environment
- Mirrors production as closely as possible.
- Connected to staging resources with realistic—but non‑critical—data.
-
Production environment
- Locked down.
- Connected to production resources and used by end‑users.
You’ll use these environments across:
- Resources (databases, APIs, analytics vendors)
- Apps (which environment they run against)
- Config variables and secrets
Step 3: Configure staging vs production resources
The core of safe Retool environments is how you wire up resources (databases and APIs) per environment.
3.1. Connect staging and production databases
For each database you use in Retool:
-
Create or confirm separate databases
your_app_db_dev/your_app_db_staging/your_app_db_prod- Ensure staging and dev are isolated from production data.
-
Add as Retool resources
- In Retool, create a resource for each environment.
- Use connection strings to access your databases in Retool and in external SQL clients if needed.
- Example naming:
Postgres – App (Staging)Postgres – App (Production)
-
Map to environments
- Assign the appropriate resource to each Retool environment.
- Confirm that when you switch an app from
stagingtoproduction, it automatically uses the production database.
Retool also supports Retool Database with multiple environments. You can automatically create a Retool Database for each environment, then safely test and ship changes across them.
3.2. Connect staging and production APIs
For external APIs (internal services, third‑party APIs):
-
Define separate API endpoints
- Example:
- Staging:
https://api-staging.internal.example.com - Production:
https://api.example.com
- Staging:
- Example:
-
Add them as environment‑specific resources
- Use environmental configuration variables for the base URL, keys, and secrets.
- Ensure staging uses sandbox or test API keys where possible.
-
Configure analytics vendors
- Connect analytics vendors (like Segment or Google Analytics) with environment‑specific tracking IDs.
- Keep staging traffic separated from production analytics.
Step 4: Use environment configuration variables and secrets
To avoid accidentally pointing an app to the wrong system, use environmental configuration variables for all environment‑specific values:
- Base URLs and API endpoints
- API keys and tokens
- Database connection strings (if not configured directly in resources)
- Feature flags or toggles that differ between staging and production
Best practices:
- Never hard‑code secrets in apps or queries.
- Use config variables like:
API_BASE_URLSEGMENT_WRITE_KEYFEATURE_NEW_FLOW_ENABLED
- Reference them consistently across your apps and queries.
- Make sure production secrets are only accessible to the appropriate admins.
Step 5: Build apps against staging resources
To keep production safe, always:
-
Develop against dev or staging
- Set your environment to
staging(ordev) while building. - Connect queries to staging databases and APIs.
- Use realistic test data in staging to catch issues early.
- Set your environment to
-
Use the query library
- Build and reuse queries for any database or API with Retool’s IDE.
- Store shared queries in the query library and parameterize them for different environments.
- This makes it easier to adjust environment‑specific behavior in one place.
-
Test user flows
- Run through key workflows in staging:
- Data reads and writes
- Error handling
- Edge cases and performance
- Confirm no queries point to production resources while in staging.
- Run through key workflows in staging:
Step 6: Promote Retool app changes safely
Once an app is built and tested in staging, you’re ready to promote it.
A safe promotion flow typically looks like this:
-
Finalize the app in staging
- Make sure all queries point to staging resources.
- Validate UI, performance, and permissions.
-
Switch the app to production environment
- In user mode, toggle the app to run in
production. - Because you’ve mapped resources per environment, production automatically uses production databases and APIs.
- Confirm that all environment‑specific variables resolve to production values.
- In user mode, toggle the app to run in
-
Use access controls for publishing
- Limit who can:
- Change an app’s environment.
- Modify production resources.
- Consider a lightweight review process (e.g., another developer validates the app in staging before promotion).
- Limit who can:
-
Roll out to users
- Once you’re confident in production behavior, share the app with your end‑users.
- Monitor logs and analytics (which should also be configured per environment).
Step 7: Safely ship database schema changes
Schema changes are where production risk is highest. Retool helps you inspect and release schema changes across environments:
-
Prototype schema in dev
- Develop your app against a dev or staging database.
- Evolve your schema as needed while iterating on the app.
-
Inspect schema changes
- Compare your staging/dev schema with production.
- Identify new tables, columns, indexes, or constraints that must be added.
-
Sync schema to production
- When ready, release schema changes to your production database.
- Use your normal database migration process or Retool Database’s environment‑aware tooling (if you’re using Retool Database).
- Ensure schema changes are applied before or in sync with updating apps that depend on them.
-
Verify after release
- Immediately validate:
- Queries that touch new schema.
- App behavior that relies on new columns or tables.
- Monitor for errors or performance regressions.
- Immediately validate:
This approach lets you develop an app against your dev database, preview schema changes, and then safely release them to end‑users by syncing to production.
Step 8: Manage resources and environments at scale
As more teams adopt Retool, you’ll need some additional structure.
8.1. Use flexible workspaces
Use flexible spaces (Workspaces) to:
- Give different teams their own independent area.
- Let each team manage their own apps, resources, and environments.
- Reduce cross‑team interference while staying on the same Retool instance.
Each workspace can still follow the same pattern:
- Staging vs production resources
- Environment configuration variables
- Clear promotion workflows
8.2. Define environment permissions
Use resource environment permissions to restrict who can:
- Modify production resources.
- Change environment configuration variables.
- Deploy schema changes to production.
This minimizes risk by ensuring only trusted admins or senior engineers can affect production.
Example: A typical staging → production release flow
To make this concrete, here’s how a common release might look:
-
Setup
Postgres – CRM (Staging)andPostgres – CRM (Production)configured as resources.API_CRM_BASE_URLandAPI_KEY_CRMset as environment variables for staging and production.- App “Customer Support Dashboard” built to use these resources and variables.
-
Build & test in staging
- Developers build new features using the staging environment.
- Queries hit
Postgres – CRM (Staging)and staging CRM APIs. - QA team tests all workflows end‑to‑end.
-
Review
- Another engineer reviews the app in staging and confirms:
- No hard‑coded staging URLs or secrets.
- Queries are parameterized properly.
- Permissions match production expectations.
- Another engineer reviews the app in staging and confirms:
-
Promote
- Admin switches the app to
productionin user mode. - Because resources and variables are environment‑specific, the app now:
- Talks to
Postgres – CRM (Production). - Uses production CRM base URL and API keys.
- Sends analytics to production trackers.
- Talks to
- Admin switches the app to
-
Post‑deploy checks
- Monitor analytics, error logs, and key workflows.
- If issues arise, you can switch users back to the previous version while fixing issues in staging.
Key best practices for Retool staging vs prod environments
To safely promote releases in Retool:
- Always build and test against staging or dev before touching production.
- Use separate resources for staging and production databases/APIs.
- Rely on environment configuration variables for URLs, keys, and secrets.
- Automatically provision a Retool Database per environment when using Retool Database, so schema changes can be tested before production.
- Inspect and release schema changes carefully, in sync with app updates.
- Control production access with environment permissions and workspace‑level policies.
- Promote via environment switching, not manual rewiring of resources each time.
With these patterns, your team can iterate quickly in Retool while keeping production stable and secure, ensuring that every release from staging to prod is both deliberate and safe.