---
title: "Update an environment"
method: PATCH
path: "/v1/environments/{publicId}"
tags: ["Environment"]
---

# Update an environment

`PATCH /v1/environments/{publicId}`

## Request

- Base URL: `https://api.fortrabbit.com`
- URL: `https://api.fortrabbit.com/v1/environments/{publicId}`
- Auth: HTTP bearer

Changes only the fields supplied; omitted fields are left unchanged. Environment variables are merged, not replaced: Add or change a variable by sending its name with a string value. Remove a variable by sending its name with a null value. Variables you do not name are left unchanged; omit the field entirely to change nothing. Platform-injected variables cannot be added, changed or removed.

## Path parameters

- `publicId` string, required

## Request body

- EnvironmentEnvironmentUpdateApiRequestJsonMergePatch
  - `name` string, nullable: New environment name. Omit to leave unchanged.
  - `git` object, nullable: Git configuration. When present, replaces the environment's branch and source directory.
    - `branch` string, required
    - `directory` string, nullable
  - `buildCommands` string[], nullable: Replaces the environment's build commands. Omit to leave unchanged; send [] to clear.
  - `postDeployCommands` string[], nullable: Replaces the environment's post-deploy commands. Omit to leave unchanged; send [] to clear.
  - `phpVersion` string, nullable: PHP runtime version. Setting it stops the environment from being auto-updated to newer PHP versions. Omit to leave unchanged.
  - `environmentVariables` object, nullable: Add or change a variable by sending its name with a string value. Remove a variable by sending its name with a null value. Variables you do not name are left unchanged; omit the field entirely to change nothing. Platform-injected variables cannot be added, changed or removed.

## Response `200`

Environment resource updated

- EnvironmentApiReadApiReadEnvironmentVariables
  - `publicId` string
  - `name` string
  - `softwareVersion` string, nullable
  - `createdAt` string, date-time
  - `updatedAt` string, date-time
  - `domains` string[]
  - `components` object
  - `phpVersion` string, nullable
  - `buildCommands` string[]
  - `postDeployCommands` string[]
  - `git` object
    - `branch` string, nullable
    - `directory` string, nullable
  - `environmentVariables` object: Variables set on this environment by its owners, keyed by name.

## Other responses

- `400`: Invalid input
- `404`: Not found
- `422`: An error occurred

---

[API](https://skmtc.dev/fortrabbit/apis/fortrabbit-api.md) · [All operations](https://skmtc.dev/fortrabbit/apis/fortrabbit-api/llms.txt) · [OpenAPI document](https://skmtc.dev/fortrabbit/apis/fortrabbit-api/revisions/36ca73befa52?raw)
