# REST API reference

Every Lessly feature area is reachable over HTTP as well as over MCP. The pages below are generated from the same platform tool catalog that produces the [MCP tools](/reference/mcp-tools) reference, so the two surfaces describe the same operations and cannot drift apart.

MCP is the canonical agent path; these REST pages document the equivalent HTTP surface for direct integrations. Each endpoint names the MCP tool it is bound to.

## Base URL

Every path on these pages is relative to:

```
https://api.lessly.com
```

A segment written as `:name` — for example `/mail/audiences/:audienceId/contacts` — is a path parameter you substitute.

## Authentication

Every endpoint requires a bearer token:

```bash
curl https://api.lessly.com/mail/domains \
  -H "Authorization: Bearer $LESSLY_API_KEY"
```

Create and revoke keys with the area's own key operations — `mail_apikey_create`, `realtime_apikey_create`, `tracking_api_keys_create` — or from the dashboard. A secret is shown once, when it is created, and cannot be read back afterwards.

A request with no `Authorization` header is rejected with `401` and the code `missing_token`. A malformed or revoked key is rejected with `401` and the code `invalid_token`.

## Errors

A failed request returns a non-2xx status and a JSON body with a single `error` object:

```json
{
  "error": {
    "code": "invalid_token",
    "message": "Invalid authentication token",
    "step": "token_validation"
  }
}
```

Branch on `code`: it is stable and machine-readable. `message` is written for people and may be reworded. `step` names the stage that rejected the request, which is what to quote when you report a problem.

## Areas

- [Analytics API](/reference/openapi/analytics) — 1 endpoint.
- [Brain API](/reference/openapi/brain) — 41 endpoints.
- [Consent API](/reference/openapi/consent) — 15 endpoints.
- [Deployment API](/reference/openapi/deployment) — 107 endpoints.
- [Mail API](/reference/openapi/mail) — 51 endpoints.
- [Organization API](/reference/openapi/organization) — 71 endpoints.
- [Realtime API](/reference/openapi/realtime) — 28 endpoints.
- [Support API](/reference/openapi/support) — 44 endpoints.
- [Tracking API](/reference/openapi/tracking) — 36 endpoints.
- [Users API](/reference/openapi/users) — 42 endpoints.
- [Waitlist API](/reference/openapi/waitlist) — 7 endpoints.
