> ## Documentation Index
> Fetch the complete documentation index at: https://aeros-c1d071c8.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# API overview

> Authentication, errors, rate limits, and the WebSocket log stream.

The panel's frontend uses the same REST API documented here. All routes live under `/api` on the panel's port (default `3000`). Request and response bodies are JSON.

## Authentication

Most endpoints need a session cookie named `aeros_session`. Get one by logging in:

```bash theme={null}
curl -s -c cookies.txt \
  -H 'Content-Type: application/json' \
  -d '{"username":"admin","password":"your-password"}' \
  http://127.0.0.1:3000/api/auth/login
```

Then send the cookie with each request:

```bash theme={null}
curl -s -b cookies.txt http://127.0.0.1:3000/api/system/metrics
```

A missing, expired, or unknown session returns:

```json 401 theme={null}
{ "error": "Authentication required" }
```

Sessions last 7 days. See [Security](https://aeros-c1d071c8.mintlify.site/security.md#sessions) for how they are stored.

### Endpoints without a session

| Endpoint | Protection |
| :- | :- |
| `GET /api/health` | None |
| `GET /api/auth/status` | None |
| `POST /api/auth/setup` | Works only while no user exists |
| `POST /api/auth/login` | Rate limited |
| `POST /api/auth/logout` | None |
| `GET /api/public/status` | Disabled by default, optional token. See [Public status](https://aeros-c1d071c8.mintlify.site/api/public-status.md). |
| `POST /api/webhooks/github/:id` | HMAC signature. See [GitHub webhooks](https://aeros-c1d071c8.mintlify.site/api/webhooks.md). |

## Mutations and `Origin`

Every `POST`, `PUT`, `DELETE`, and `PATCH` under `/api` passes through the same-origin check, including the unauthenticated ones. Requests from scripts that send no `Origin` header, like `curl`, pass the check. Browser requests from another origin get `403` unless that origin is listed in `CORS_ORIGIN`. See [Security](https://aeros-c1d071c8.mintlify.site/security.md#cross-site-request-protection).

## Errors

Errors use one shape:

```json theme={null}
{ "error": "Human-readable message" }
```

| Status | Meaning |
| :- | :- |
| `400` | Validation failed, for example an invalid service name or blocked working directory. |
| `401` | Not authenticated, wrong credentials, or invalid webhook signature or status token. |
| `403` | Blocked by the cross-site or cross-origin check. |
| `404` | Project, backup job, or webhook not found, or the public status endpoint is disabled. |
| `409` | Conflict, for example a deploy already running, setup already done, or alerts unsupported on this host. |
| `429` | Too many failed logins. |
| `500` | The underlying command or database call failed. The message comes from the error. |
| `502` | The alert test reached the webhook but it did not answer with `2xx`. |

## Rate limits

Only `POST /api/auth/login` is rate limited: 10 attempts per client IP per 15 minutes. Other endpoints have no rate limit, but they all run behind authentication or the checks listed above.

```json 429 theme={null}
{ "error": "Too many failed login attempts. Try again in 812s." }
```

## Long-running actions

`POST /api/projects/:id/deploy` and `POST /api/projects/:id/rollback` return `202` right away. Progress is streamed over the WebSocket for that service, with lines prefixed `[DEPLOY]` or `[ROLLBACK]`. `GET /api/projects` reports `deploying` and `deployment_action` while one runs.

## WebSocket log stream

```text theme={null}
ws://<host>:<port>/ws?service=<service_name>
```

Use `wss://` when the panel is served over HTTPS. The connection needs:

* An `Origin` header that matches the panel's host, or one listed in `CORS_ORIGIN`. Browsers send it automatically.
* The `aeros_session` cookie.
* A `service` query parameter matching `^[a-zA-Z0-9][a-zA-Z0-9._-]{0,63}$`.

On connect, the server spawns `journalctl -u <service> -f -n 100` and sends its output as text frames. It also sends deploy and rollback lines for that service, plus these system messages:

| Message | When |
| :- | :- |
| `ERROR: <text>` | `journalctl` wrote to stderr. |
| `SYSTEM: journalctl unavailable (<reason>).` | `journalctl` could not start, for example on a non-Linux host. |
| `SYSTEM: Log stream closed.` | `journalctl` exited. |

The client sends nothing. Closing the socket kills the `journalctl` process.

| Close code | Reason |
| :- | :- |
| `4403` | `Forbidden origin` |
| `4401` | `Unauthorized` |
| `4400` | `Invalid service name` |

```js Browser theme={null}
const ws = new WebSocket(`${location.protocol === 'https:' ? 'wss' : 'ws'}://${location.host}/ws?service=discord-bot`);
ws.onmessage = (event) => console.log(event.data);
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.