> For the complete documentation index, see [llms.txt](https://docs.release.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.release.com/reference-documentation/release-api/platform-api/environments.md).

# Environments

Manage environments (spaces) within your Release apps. Create, configure, and inspect ephemeral and permanent environments.

Base URL: `https://api.release.com`

***

## List Environments

Retrieve all environments for a specific app.

#### Endpoint

<mark style="color:green;">`GET`</mark> `/apps/{appId}/spaces`

#### Authentication

Authenticate using headers from your `~/.release.yaml` file. To set this up, [install the Release CLI](/cli/installation.md) and run `release auth login`.

| Header       | Description                                       |
| ------------ | ------------------------------------------------- |
| X-User-Email | User email from `~/.release.yaml` (`login` field) |
| X-User-Token | User token from `~/.release.yaml` (`token` field) |

#### Headers

| Header | Value              | Required |
| ------ | ------------------ | -------- |
| Accept | `application/json` | Yes      |

#### Path Parameters

| Parameter | Type              | Required | Description                      |
| --------- | ----------------- | -------- | -------------------------------- |
| appId     | `string (hashid)` | Yes      | The unique identifier of the app |

#### Status Codes

| Status | Description                                              |
| ------ | -------------------------------------------------------- |
| 200    | Successfully retrieved environments                      |
| 401    | Unauthorized — invalid or missing authentication headers |
| 404    | App not found                                            |

#### Example Responses

**200 OK**

```json
[
  {
    "id": "env789",
    "name": "feature-x",
    "type": "EPHEMERAL",
    "branch": "feature-branch",
    "status": "running"
  }
]
```

***

## Get Environment

Retrieve details for a specific environment.

#### Endpoint

<mark style="color:green;">`GET`</mark> `/apps/{appId}/spaces/{envId}`

#### Authentication

Authenticate using headers from your `~/.release.yaml` file. To set this up, [install the Release CLI](/cli/installation.md) and run `release auth login`.

| Header       | Description                                       |
| ------------ | ------------------------------------------------- |
| X-User-Email | User email from `~/.release.yaml` (`login` field) |
| X-User-Token | User token from `~/.release.yaml` (`token` field) |

#### Headers

| Header | Value              | Required |
| ------ | ------------------ | -------- |
| Accept | `application/json` | Yes      |

#### Path Parameters

| Parameter | Type              | Required | Description                              |
| --------- | ----------------- | -------- | ---------------------------------------- |
| appId     | `string (hashid)` | Yes      | The unique identifier of the app         |
| envId     | `string (hashid)` | Yes      | The unique identifier of the environment |

#### Status Codes

| Status | Description                                              |
| ------ | -------------------------------------------------------- |
| 200    | Successfully retrieved environment                       |
| 401    | Unauthorized — invalid or missing authentication headers |
| 404    | App or environment not found                             |

#### Example Responses

**200 OK**

```json
{
  "id": "env789",
  "name": "feature-x",
  "type": "EPHEMERAL",
  "branch": "feature-branch",
  "status": "running",
  "domain": "feature-x.example.release.com"
}
```

***

## Create Environment

Create a new environment for a specific app.

#### Endpoint

<mark style="color:green;">`POST`</mark> `/apps/{appId}/spaces`

#### Authentication

Authenticate using headers from your `~/.release.yaml` file. To set this up, [install the Release CLI](/cli/installation.md) and run `release auth login`.

| Header       | Description                                       |
| ------------ | ------------------------------------------------- |
| X-User-Email | User email from `~/.release.yaml` (`login` field) |
| X-User-Token | User token from `~/.release.yaml` (`token` field) |

#### Headers

| Header       | Value              | Required |
| ------------ | ------------------ | -------- |
| Content-Type | `application/json` | Yes      |
| Accept       | `application/json` | Yes      |

#### Path Parameters

| Parameter | Type              | Required | Description                      |
| --------- | ----------------- | -------- | -------------------------------- |
| appId     | `string (hashid)` | Yes      | The unique identifier of the app |

#### Request Body

| Field                    | Type      | Required | Description                                                                            |
| ------------------------ | --------- | -------- | -------------------------------------------------------------------------------------- |
| name                     | `string`  | Yes      | Environment name                                                                       |
| type                     | `string`  | Yes      | One of: `EPHEMERAL`, `PERMANENT`                                                       |
| initiation\_type         | `string`  | No       | One of: `manual`, `automatic`                                                          |
| branch                   | `string`  | Yes      | Git branch name                                                                        |
| seconds\_for\_expiration | `integer` | No       | TTL in seconds                                                                         |
| services                 | `object`  | No       | Per-service branch overrides in the form `{"service_name": {"branch": "branch-name"}}` |
| domain                   | `string`  | No       | Custom domain                                                                          |

**Example request body:**

```json
{
  "name": "feature-x",
  "type": "EPHEMERAL",
  "initiation_type": "manual",
  "branch": "feature-branch",
  "seconds_for_expiration": 604800,
  "services": {"backend": {"branch": "feature-branch"}},
  "domain": "custom.domain.com"
}
```

#### Status Codes

| Status | Description                                              |
| ------ | -------------------------------------------------------- |
| 201    | Environment created successfully                         |
| 401    | Unauthorized — invalid or missing authentication headers |
| 404    | App not found                                            |
| 422    | Validation error — invalid or missing required fields    |

#### Example Responses

**201 Created**

```json
{
  "id": "env789",
  "name": "feature-x",
  "type": "EPHEMERAL",
  "branch": "feature-branch",
  "status": "pending"
}
```

***

## Get Environment Config

Retrieve the latest application configuration for a specific environment.

#### Endpoint

<mark style="color:green;">`GET`</mark> `/apps/{appId}/spaces/{envId}/latest_config`

#### Authentication

Authenticate using headers from your `~/.release.yaml` file. To set this up, [install the Release CLI](/cli/installation.md) and run `release auth login`.

| Header       | Description                                       |
| ------------ | ------------------------------------------------- |
| X-User-Email | User email from `~/.release.yaml` (`login` field) |
| X-User-Token | User token from `~/.release.yaml` (`token` field) |

#### Headers

| Header | Value              | Required |
| ------ | ------------------ | -------- |
| Accept | `application/json` | Yes      |

#### Path Parameters

| Parameter | Type              | Required | Description                              |
| --------- | ----------------- | -------- | ---------------------------------------- |
| appId     | `string (hashid)` | Yes      | The unique identifier of the app         |
| envId     | `string (hashid)` | Yes      | The unique identifier of the environment |

#### Status Codes

| Status | Description                                              |
| ------ | -------------------------------------------------------- |
| 200    | Successfully retrieved environment configuration         |
| 401    | Unauthorized — invalid or missing authentication headers |
| 404    | App or environment not found                             |

#### Example Responses

**200 OK**

```json
{
  "config": "--- \nservices:\n  backend:\n    image: org/backend\n    ports:\n      - 3000\n"
}
```

***

## Get Environment Variables

Retrieve the environment variables configuration for a specific environment.

#### Endpoint

<mark style="color:green;">`GET`</mark> `/apps/{appId}/spaces/{envId}/latest_env_config`

#### Authentication

Authenticate using headers from your `~/.release.yaml` file. To set this up, [install the Release CLI](/cli/installation.md) and run `release auth login`.

| Header       | Description                                       |
| ------------ | ------------------------------------------------- |
| X-User-Email | User email from `~/.release.yaml` (`login` field) |
| X-User-Token | User token from `~/.release.yaml` (`token` field) |

#### Headers

| Header | Value              | Required |
| ------ | ------------------ | -------- |
| Accept | `application/json` | Yes      |

#### Path Parameters

| Parameter | Type              | Required | Description                              |
| --------- | ----------------- | -------- | ---------------------------------------- |
| appId     | `string (hashid)` | Yes      | The unique identifier of the app         |
| envId     | `string (hashid)` | Yes      | The unique identifier of the environment |

#### Status Codes

| Status | Description                                              |
| ------ | -------------------------------------------------------- |
| 200    | Successfully retrieved environment variables             |
| 401    | Unauthorized — invalid or missing authentication headers |
| 404    | App or environment not found                             |

#### Example Responses

**200 OK**

```json
{
  "env_config": "DATABASE_URL=postgres://...\nREDIS_URL=redis://...\n"
}
```

***

## Update Environment Config

Update the application configuration for a specific environment.

#### Endpoint

<mark style="color:green;">`POST`</mark> `/apps/{appId}/spaces/{envId}/serialized_configs`

#### Authentication

Authenticate using headers from your `~/.release.yaml` file. To set this up, [install the Release CLI](/cli/installation.md) and run `release auth login`.

| Header       | Description                                       |
| ------------ | ------------------------------------------------- |
| X-User-Email | User email from `~/.release.yaml` (`login` field) |
| X-User-Token | User token from `~/.release.yaml` (`token` field) |

#### Headers

| Header       | Value              | Required |
| ------------ | ------------------ | -------- |
| Content-Type | `application/json` | Yes      |
| Accept       | `application/json` | Yes      |

#### Path Parameters

| Parameter | Type              | Required | Description                              |
| --------- | ----------------- | -------- | ---------------------------------------- |
| appId     | `string (hashid)` | Yes      | The unique identifier of the app         |
| envId     | `string (hashid)` | Yes      | The unique identifier of the environment |

#### Request Body

| Field  | Type     | Required | Description                                    |
| ------ | -------- | -------- | ---------------------------------------------- |
| config | `string` | Yes      | The application configuration YAML as a string |

**Example request body:**

```json
{
  "config": "--- \nservices:\n  backend:\n    image: org/backend\n    ports:\n      - 3000\n"
}
```

#### Status Codes

| Status | Description                                              |
| ------ | -------------------------------------------------------- |
| 200    | Environment configuration updated successfully           |
| 401    | Unauthorized — invalid or missing authentication headers |
| 404    | App or environment not found                             |
| 422    | Validation error — invalid configuration                 |

#### Example Responses

**200 OK**

```json
{
  "config": "--- \nservices:\n  backend:\n    image: org/backend\n    ports:\n      - 3000\n"
}
```

***

## List Instances

Retrieve Kubernetes pod details for a specific environment.

#### Endpoint

<mark style="color:green;">`GET`</mark> `/apps/{appId}/spaces/{envId}/instances`

#### Authentication

Authenticate using headers from your `~/.release.yaml` file. To set this up, [install the Release CLI](/cli/installation.md) and run `release auth login`.

| Header       | Description                                       |
| ------------ | ------------------------------------------------- |
| X-User-Email | User email from `~/.release.yaml` (`login` field) |
| X-User-Token | User token from `~/.release.yaml` (`token` field) |

#### Headers

| Header | Value              | Required |
| ------ | ------------------ | -------- |
| Accept | `application/json` | Yes      |

#### Path Parameters

| Parameter | Type              | Required | Description                              |
| --------- | ----------------- | -------- | ---------------------------------------- |
| appId     | `string (hashid)` | Yes      | The unique identifier of the app         |
| envId     | `string (hashid)` | Yes      | The unique identifier of the environment |

#### Status Codes

| Status | Description                                              |
| ------ | -------------------------------------------------------- |
| 200    | Successfully retrieved instances                         |
| 401    | Unauthorized — invalid or missing authentication headers |
| 404    | App or environment not found                             |

#### Response Body

| Field        | Type     | Description                   |
| ------------ | -------- | ----------------------------- |
| name         | `string` | Pod name                      |
| kind         | `string` | Kubernetes resource kind      |
| status.phase | `string` | Current pod phase             |
| containers   | `array`  | List of containers in the pod |
| images       | `array`  | Container image references    |

#### Example Responses

**200 OK**

```json
[
  {
    "name": "backend-6d4f5b8c9-x2k7m",
    "kind": "Pod",
    "status": {
      "phase": "Running"
    },
    "containers": ["backend"],
    "images": ["org/backend:latest"]
  }
]
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.release.com/reference-documentation/release-api/platform-api/environments.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
