# Environment

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}/env

**Read the .env**

Scope: `env:read`

Reads the site's .env from its server. pfcloud never stores it; every read is in the activity log (without contents). `keys_only=1` returns the key names only.

| Parameter | In | Description |
| --- | --- | --- |
| `site` | path | Public id from the dashboard address (required) |
| `keys_only` | query | Return only the key names, no values |

## PUT /sites/{site}/env

**Replace the .env**

Scope: `env:write`

Saves the whole file, like the dashboard editor. The previous file is kept as .env.previous. `after` lists the steps to run afterwards (laravel-cache, reload-php, restart-app, restart-daemons, as the site offers); left out, the site's remembered choice runs. The choice is remembered for the site.

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

| Body field | Type | Description |
| --- | --- | --- |
| `contents` | string |  |
| `after` | array |  |

## PATCH /sites/{site}/env

**Set or remove .env keys**

Scope: `env:write`

Sets keys (added or overwritten) and removes others, leaving every other line as it is. Keys match `^[A-Z_][A-Z0-9_]*$`; values are one line, written as given (quote them yourself when needed). The activity log records the key names, never the values.

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

| Body field | Type | Description |
| --- | --- | --- |
| `set` | object |  |
| `remove` | array |  |
| `after` | array |  |

