REST API¶
The API lives under /api/v1. The machine-readable description is served at
/api/v1/openapi.json (OpenAPI 3).
Authentication¶
Bearer token — a personal API token:
Authorization: Bearer mcr_.... What it may do is limited by its scopes (The relay and its credentials).Session cookie — the browser session. State-changing requests then need the CSRF token in the
X-CSRFTokenheader. Administrators with a cookie session need two-factor authentication and, for dangerous actions, a fresh confirmation (POST /auth/reauth, Fresh authentication for dangerous actions).
Answers are JSON: {"data": ...} (with pagination for lists) or
{"error": {"code": ..., "message": ...}}. Common codes: unauthorized (401),
forbidden and insufficient_scope (403), reauth_required and
mfa_required (403), invalid_request (400), conflict (409).
Endpoints for users¶
Method |
Path |
Purpose |
|---|---|---|
GET |
|
The current user’s profile |
GET, POST |
|
List / create API tokens (value shown once; scopes and expiry in the body) |
DELETE |
|
Revoke a token |
GET |
|
Servers visible to the user |
GET, PUT |
|
The selected servers |
GET, PUT, DELETE |
|
Personal credential overrides ( |
GET |
|
Generated configuration: |
POST |
|
Confirm password (and code) for administrator actions |
Administrator endpoints¶
Method |
Path |
Purpose |
|---|---|---|
GET, POST |
|
List ( |
GET, PUT, DELETE |
|
One server ( |
GET, POST |
|
List / create users |
GET, PUT, DELETE |
|
One user and their permissions |
GET, PUT |
|
A user’s selection |
GET, PUT, DELETE |
|
A user’s override |
GET |
|
A user’s generated configuration |
POST |
|
Switch off two-factor authentication |
POST |
|
Revoke all programmatic credentials |
POST |
|
Apply a template |
GET, POST |
|
List / create templates |
GET, PUT, DELETE |
|
One template |
GET |
|
The audit trail (filterable) |
A token needs admin:read for GET and admin:write for everything else.
Example¶
TOKEN=mcr_...
curl -s -H "Authorization: Bearer $TOKEN" https://mcprack.example.com/api/v1/servers
curl -s -X POST -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
-d '{"name": "ci", "scopes": ["proxy:access"], "expires_in_days": 30}' \
https://mcprack.example.com/api/v1/tokens