---
title: "Initialize a new environment"
method: POST
path: "/projects/{projectId}/environments/{environmentId}/initialize"
tags: ["Environment"]
---

# Initialize a new environment

`POST /projects/{projectId}/environments/{environmentId}/initialize`

Initialize and configure a new environment with an existing repository.
The payload is the url of a git repository with a profile name:

```
{
    "repository": "git@github.com:platformsh/a-project-template.git@master",
    "profile": "Example Project",
    "files": [
      {
        "mode": 0600,
        "path": "config.json",
        "contents": "XXXXXXXX"
      }
    ]
}
```
It can optionally carry additional files that will be committed to the
repository, the POSIX file mode to set on each file, and the base64-encoded
contents of each file.

This endpoint can also add a second repository
URL in the `config` parameter that will be added to the contents of the first.
This allows you to put your application in one repository and the Upsun
YAML configuration files in another.

## Path parameters

- `projectId` string, required
- `environmentId` string, required

## Request body

- EnvironmentInitializeInput
  - `profile` string, required — Name of the profile to show in the UI
  - `repository` string, required — Repository to clone from
  - `config` string, nullable, required — Repository to clone the configuration files from
  - `files` object[], required — A list of files to add to the repository during initialization
    - `path` string, required — The path to the file.
    - `mode` integer, required — The octal value of the file protection mode.
    - `contents` string, required — The contents of the file (base64 encoded).
  - `resources` object, nullable, required
    - `init` 'default' | 'minimum', nullable, required — The resources used when initializing the environment

## Response `default`

- AcceptedResponse
  - `status` string, required — The status text of the response
  - `code` integer, required — The status code of the response

---

[API](https://skmtc.net/upsun/apis/upsun-com-rest-api.md) · [All operations](https://skmtc.net/upsun/apis/upsun-com-rest-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/upsun/upsun-com-rest-api/revisions/6cc88fde6435/schema)
