Skip to main content
Download an environment’s state file from the env zero remote backend API. Use it to read state from a script, across many environments, or from a pipeline outside env zero. The remote backend API is separate from the REST API in the rest of this reference. It is served from https://backend.api.env0.com, and it authenticates with a remote backend token instead of HTTP Basic authentication.

Prerequisites

State files can contain secret values in plain text. Store the downloaded file as you would a secret.

Download the current state

Two requests download the state. The first returns the ID of the current state version. The second downloads that version.
1

Export the token

2

Get the current state version ID

The id in the response is the state version ID. hosted-state-download-url is the full URL for the next request:
The attributes object can contain more fields, such as serial.
3

Download the state file

The response body is the state file as stored, with the content type application/json.
To download a previous state version, use the States tab, as described on the Remote backend page.

Download state for many environments

To download the current state of several environments, repeat both requests for each environment ID. Get the IDs from List Environments.

Endpoints

Both endpoints use the GET method and the base URL https://backend.api.env0.com.
  • State access control sets which environments can read state during env zero deployments. Requests with an API key use the key’s permissions instead.
  • API access covers authentication for the rest of the REST API.