# Logs and commands

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

**List the site's logs**

Scope: `logs:read`

The logs that can be read (Laravel, Nginx, the app, each daemon) and the allowed line counts.

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

## GET /sites/{site}/logs/tail

**Read a log**

Scope: `logs:read`

The last lines of one log, read from the server. Logs are never stored by pfcloud.

| Parameter | In | Description |
| --- | --- | --- |
| `site` | path | Public id from the dashboard address (required) |
| `log` | query | A `log` from the list; the first one when left out |
| `lines` | query |  |

## GET /sites/{site}/commands

**List commands**

Scope: `commands:run`

Commands run in the site's folder, newest first.

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

## POST /sites/{site}/commands

**Run a command**

Scope: `commands:run`

Runs a command (one or several lines, up to 10000 characters) in the site's live folder as the site's user (never root; never on watch-only sites). Poll the command for its output.

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

| Body field | Type | Description |
| --- | --- | --- |
| `command` | string |  |

## GET /sites/{site}/commands/{command}

**Get a command**

Scope: `commands:run`

Status, exit code and output.

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

