# Environments

Base URL `https://pfcloud.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 |  |

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

