Skip to content

Authentication

All API calls (except the login endpoint itself) require a short-lived JWT access token supplied as a Bearer token in the Authorization header. Access tokens expire quickly; use the refresh endpoint to obtain a new one without re-entering credentials.

The same access token can be passed to the WebSocket endpoint as the token query parameter.

Authenticate with username and password.

Request body (JSON):

{
"username": "trader1",
"password": "secret"
}

Response 200 (JSON):

{
"access_token": "<jwt>",
"refresh_token": "<opaque>",
"access_expires_at": 1716180000,
"permission_tier": 2
}
FieldTypeDescription
access_tokenstringJWT for API requests; include as Authorization: Bearer <access_token>
refresh_tokenstringOpaque token; use with /auth/refresh
access_expires_atintUnix epoch seconds when the access token expires
permission_tierint1=Monitor, 2=Trader, 3=Power, 4=Admin

Obtain a new access token using a refresh token.

Request body (JSON):

{ "refresh_token": "<opaque>" }

Response 200 (JSON):

{
"access_token": "<new_jwt>",
"access_expires_at": 1716183600
}

Invalidate the current session. The access token is added to the JWT blocklist; the refresh token is revoked.

Headers: Authorization: Bearer <access_token>

Response: 204 No Content

All endpoints return standard HTTP status codes. Error bodies follow:

{ "error": "human-readable message", "code": "machine_code" }

Common codes:

HTTP StatusMeaning
400Bad request / validation error
401Missing or invalid token
403Insufficient permission tier
404Resource not found
409Conflict (e.g. duplicate idempotency key)
422Unprocessable entity (business rule violation)
429Rate limit exceeded
500Internal server error

The API enforces per-IP and per-user rate limits on write endpoints. When a limit is exceeded, the response is 429 Too Many Requests with a Retry-After header in seconds.