---
title: "Creates a Environment resource."
method: POST
path: "/v1/environments"
tags: ["Environment"]
---

# Creates a Environment resource.

`POST /v1/environments`

## Request

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

Creates a Environment resource.

## Request body

- EnvironmentEnvironmentCreateApiRequest
  - `appId` string, nullable
  - `name` string, required
  - `deployment` object, nullable: Deployment configuration. The git field is required to configure deployment; omit the whole object to skip deployment.
    - `git` object, required
      - `branch` string, required
      - `directory` string: Deploy directory. Optional; defaults to "/". Must not be null or empty when provided.
    - `buildCommands` string[]
    - `postDeployCommands` string[]
    - `startFirstDeployment` boolean: Trigger a first deployment right after the environment is created.
  - `softwareVersion` string, nullable: Major version only, e.g. "11". Optional; defaults to the app software's version.
  - `components` object: Component plans keyed by component slug. The value is a size key (e.g. "sm") or "off" to disable an optional component.
  - `autoscaling` boolean, required: Enable autoscaling. Optional; defaults to true.
  - `phpVersion` string, nullable: PHP runtime version; defaults to the platform default.
  - `sourceEnvironment` string, nullable: Public ID of an existing environment to clone component plans and settings from.
  - `environmentVariables` object: Environment variables to set on the new environment, keyed by name.

## Response `201`

Environment resource created

- 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
- `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)
