# Environments

Base URL `https://deploy.pfctek.com/api/v1`. Every call needs `Authorization: Bearer mf_…`. Changes accept an `Idempotency-Key` header. Ids are public ids (UUIDs).

## GET /sites/{site}/environments

**List environments**

Scope: `sites:read`

| Parameter | In | Description |
| --- | --- | --- |
| `site` | path | Public id from the dashboard address (required) |

## POST /sites/{site}/environments

**Add an environment**

Scope: `sites:write`

| Parameter | In | Description |
| --- | --- | --- |
| `site` | path | Public id from the dashboard address (required) |

| Body field | Type | Description |
| --- | --- | --- |
| `name` | string |  |
| `domain` | string |  |
| `server` | string |  |
| `branch` | string |  |
| `php_version` | string |  |
| `create_database` | boolean |  |
| `copy_env` | boolean |  |
| `override_room` | boolean | Team owner only: add it although the server is too small for another site (pfcloud estimates its memory). Without it such a request answers 422 with the reason on `server`. |

## PUT /sites/{site}/previews

**Pull request preview settings**

Scope: `sites:write`

| Parameter | In | Description |
| --- | --- | --- |
| `site` | path | Public id from the dashboard address (required) |

| Body field | Type | Description |
| --- | --- | --- |
| `preview_domain` | string |  |
| `preview_server` | string |  |
| `preview_env` | string |  |

## POST /sites/{site}/environments/{environment}/promote

**Promote an environment to production**

Scope: `deployments:write`

| Parameter | In | Description |
| --- | --- | --- |
| `site` | path | Public id from the dashboard address (required) |
| `environment` | path | The environment’s site id (required) |

