How to Create Preview Environments with our API

Flipper Cloud now supports preview environments through its REST API.

A preview environment is an isolated feature flag environment created for a temporary deployment, such as a pull request app or review app. When you create one, Flipper Cloud returns a token scoped specifically to that environment. When the deployment is finished, you can delete the environment by its ID.

Why use preview environments for feature flags?

Preview deployments should be isolated from production, including their feature flag state.

Using a separate Flipper Cloud environment lets a team safely change flags while reviewing a branch without affecting production, staging, or another developer’s work. It also avoids sharing a long lived production credential with temporary infrastructure.

Preview environments (sometimes called ephemeral environments) are useful for:

  • Pull request and branch deployments
  • Heroku Review Apps
  • Temporary QA environments
  • Automated acceptance testing
  • Short-lived customer demos

How does the API work?

First, create a token in a stable custom environment such as previews and enable its Manage preview environments permission.

Your deployment automation can then:

  1. Send POST /adapter/environments to create a preview environment.
  2. Store the returned environment ID and scoped token.
  3. Use that token while the preview deployment is running.
  4. Send DELETE /adapter/environments/{id} when the deployment is removed.

The returned token only has access to its new environment. It cannot create additional preview environments.

Why is preview management a separate permission?

Creating environments and issuing credentials is more powerful than reading or updating feature flags.

Flipper Cloud therefore treats Manage preview environments as a separate capability. You can give a token read/write access without automatically allowing it to create or remove environments.

This makes the intended access clear and keeps the credential used by your deployment automation separate from ordinary application tokens.

See the Flipper Cloud REST API documentation for endpoint details, responses, and possible errors.

Hope you find this helpful and keep the feature requests coming.