Set Up Preview Deployments
Preview deployments create a temporary environment for every non-production branch, giving you a live URL to review changes before merging.
Enable preview environments
Preview deployments are controlled at the project level.
- Open your project in the dashboard
- Go to Settings
- Find Preview Environments and toggle it on
- Click Save
Once enabled, any push to a branch that is not the project's main branch (usually main or master) will automatically create a preview environment and deploy to it.
The main branch is configured in your project settings under Git > Branch. Pushes to this branch deploy to the default (production) environment. All other branches create preview environments.
Run previews on-demand
By default, every preview environment runs 24/7 just like production. You can instead have each newly created preview start in on-demand mode, where it scales to zero when idle and wakes on the next request — so a stack of stale feature-branch previews stops consuming resources.
Under Settings > General, below the Enable Preview Environments switch, you'll find:
| Setting | Default | Range | What it does |
|---|---|---|---|
| On-Demand Preview Environments | Off | — | When on, every newly auto-created preview starts in on-demand mode |
| Idle timeout (seconds) | 300 | 60–86400 | How long a preview sits idle before it scales to zero |
| Wake timeout (seconds) | 30 | 5–120 | How long Temps waits for a sleeping preview to wake before failing the request |
The on-demand toggle is disabled until preview environments are enabled, and the two timeout inputs only appear once on-demand is turned on. Both inputs are validated client-side against the same ranges the backend enforces.
This setting is opt-in — it defaults to off, and it only applies to previews created after you enable it. Existing preview environments keep whatever configuration they already had. When on, Temps seeds each new preview with on-demand mode plus your idle/wake timeouts; CPU, memory, replicas, and security still inherit from the environment → project → global defaults.
You can also set this through the project-settings update API. The UpdateProjectSettingsRequest body accepts three optional fields:
curl -X POST "https://your-temps-instance/api/projects/{project_id}/settings" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"preview_envs_on_demand": true,
"preview_envs_idle_timeout_seconds": 300,
"preview_envs_wake_timeout_seconds": 30
}'
If a timeout falls outside its valid range, the request is rejected with a validation error (for example, preview_envs_idle_timeout_seconds 30 is not in valid range (60-86400)).
How preview branches work
When a push arrives on a non-main branch:
- Temps checks if a preview environment already exists for that branch
- If not, it creates one — the environment is named after the branch (e.g.
feature/loginbecomes thefeature-loginenvironment) - The application is built and deployed to that environment
- A unique URL is generated for the preview
If the branch is pushed again, Temps redeploys to the same preview environment rather than creating a new one. If a previously deleted branch is pushed again, Temps restores the soft-deleted environment.
Preview URLs
Preview deployments get URLs in the format:
https://{project-slug}-{environment-slug}.{preview-domain}
For example, if your project is my-app and the branch is feature/login, the preview URL would be:
https://my-app-feature-login.yourdomain.com
Each individual deployment within the preview also gets its own URL:
https://{deployment-slug}.{preview-domain}
These per-deployment URLs let you compare different versions of the same branch.
Control which variables are included
Not all environment variables should be available in preview deployments. For example, you might want to keep production API keys or payment processor credentials out of previews.
Each environment variable has an Include in Preview toggle:
- Go to your project's Environment Variables page
- For each variable, check or uncheck Include in Preview
- Variables with this toggle off will not be injected into preview environments
When creating a new environment variable via the API, set include_in_preview: false to exclude it:
curl -X POST "https://your-temps-instance/api/projects/{project_id}/env-vars" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"key": "STRIPE_SECRET_KEY",
"value": "sk_live_...",
"environment_ids": [1],
"include_in_preview": false
}'
Managed service variables (like POSTGRES_URL and REDIS_URL) are always injected into all environments, including previews. Each preview environment gets its own isolated database within the shared service.
Preview comments on pull requests
When a deployment runs for a branch that has an open GitHub pull request or GitLab merge request, Temps posts a single sticky comment on that PR/MR and updates the same comment in place as the deployment progresses — it never spams a new comment per build. This works identically on GitHub and GitLab.
The comment is keyed by a hidden HTML marker scoped to the project and environment:
<!-- temps-preview:project=N:env=N -->
On each update, Temps finds the existing comment carrying that marker and edits it; if none exists, it creates one. The comment body reflects the current phase of the deployment:
| Phase | Comment heading | Additional content |
|---|---|---|
| Building / in-progress | 🚧 Deploying preview | — |
| Succeeded | ✅ Preview ready | Preview URL |
| Failed | ❌ Preview build failed | Link to deployment logs |
| Cancelled | ⛔ Preview deployment cancelled | Commit SHA + link to deployment logs |
When a deployment is cancelled — from the dashboard or via the API — Temps updates the sticky comment to the cancelled state. Prior to this, cancelling a deployment would leave the comment stuck on 🚧 Deploying preview indefinitely. The cancelled body includes the commit SHA so it is clear which revision was stopped.
Required token scopes
For Temps to post comments, the connection needs write access to pull requests:
| Provider | Scope |
|---|---|
| GitHub App | pull_requests:write |
| GitLab token | api |
Newly created GitHub Apps request pull_requests:write automatically. An existing GitHub App installation that predates this and lacks the scope will hit a 403 — Temps logs it and skips the comment, but you'll need to upgrade the app's permissions to get sticky comments.
Preview comments degrade gracefully. A missing git connection, no open PR/MR, an unsupported provider, or a 401/403 from the provider are all logged and skipped — they never block or fail the deployment itself.
Access preview URLs
Find the URL for any preview deployment:
- Open your project in the dashboard
- Click Environments in the sidebar
- You will see all environments listed — preview environments are marked with a Preview badge
- Click on a preview environment to see its URL and deployment history
Alternatively, on the Deployments page, each deployment entry shows its environment name and a direct link to the live URL.
Create environments manually
Auto-created previews cover feature branches, but you can also create environments by hand for long-lived branches like staging or develop:
- Go to your project's Environments page
- Click New Environment
- Enter a name (e.g.
staging) - Select the branch it tracks (e.g.
develop) - Configure replicas and resource limits (optional)
Manual environments behave like auto-created previews but are never soft-deleted when the branch is removed.
Per-environment overrides
Each environment can override the project-level deployment configuration:
- Name
branch- Type
- string
- Description
The Git branch this environment tracks.
- Name
replicas- Type
- integer
- Description
Number of container instances. Default: 1.
- Name
exposed_port- Type
- integer
- Description
Override the container port. Default: auto-detected from the image's EXPOSE directive.
- Name
automatic_deploy- Type
- boolean
- Description
Whether pushes to the branch trigger automatic deployments. Default: true.
- Name
cpu_limit- Type
- integer
- Description
CPU limit for containers, in millicores (e.g. 500 for half a core).
- Name
memory_limit- Type
- integer
- Description
Memory limit for containers, in megabytes (e.g. 512).
Notify external systems with webhooks
Temps can fire outbound webhooks when a deployment changes state, so you can post a message to Slack, Discord, or any HTTP endpoint when a preview goes live or fails:
- Go to Settings > Webhooks
- Add a webhook URL
- Select the deployment events you care about
The available deployment events are:
| Event | When it fires |
|---|---|
deployment.created | A deployment was queued |
deployment.succeeded | The build completed successfully |
deployment.failed | The deployment failed (build error, health-check timeout, etc.) |
deployment.cancelled | The deployment was cancelled |
deployment.ready | The deployment is live and receiving traffic |
Each deployment payload carries the project_name, environment, branch, commit_sha, commit_message, status, and the live url — enough to build a meaningful notification.
Clean up stale previews
Preview environments accumulate over time as branches are created. To clean them up:
- Go to Environments in your project
- Find the preview environment you want to remove
- Click the Delete button (or use the actions menu)
Deleting a preview environment:
- Stops and removes the running containers
- Soft-deletes the environment record (it can be restored if the same branch is pushed again)
- Does not delete the Git branch
Production protection: The production environment cannot be deleted. This is enforced at the system level regardless of user permissions.
You can also tear down individual deployments without deleting the entire environment. On the Deployments page, use the Teardown action on any deployment to stop its container and free resources while keeping the environment available for future pushes.
Troubleshooting
Preview not created after a push
- Verify that Preview Environments is toggled on in project settings
- Confirm the push targets a branch other than the project's main branch
- Check your Git provider's webhook delivery logs to confirm Temps received the push
Preview URL returns 404
- The deployment may still be building — check the Environments tab for its status
- If you serve previews from a custom domain, make sure a wildcard DNS record (for example
*.yourdomain.com) points at your Temps server so every preview subdomain resolves
Variables missing in a preview
- Confirm the variable has Include in Preview enabled
- Variables are copied when the preview environment is first created. A variable added afterwards is not retroactively injected into existing previews — add it to the preview environment or recreate the preview