API
Authentication & Keys
API keys, scopes and plan entitlements for the Trade Wzrd API.
The API accepts two credential types on the same surface:
| Credential | Used by | Header |
|---|---|---|
| API key | bots, scripts, MCP, servers | Authorization: Bearer tw_live_... |
| Session JWT | the Trade Wzrd web app | Authorization: Bearer eyJ... |
A session JWT is the account owner and is never scope-limited. A key is delegated authority: it holds an explicit scope list, its own rate limit, and can be revoked without touching your account.
Key format
tw_live_<8 hex keyId>_<43 char urlsafe secret>tw_test_<8 hex keyId>_<43 char urlsafe secret>The server stores only a SHA-256 hash. The raw key is returned once, by the create or rotate response, and can never be retrieved again. Everything else shows the prefix (tw_live_ab12cd34...).
Key lifecycle
| Action | Endpoint | Auth required |
|---|---|---|
| Create | POST /api/v1/keys | Session |
| List (prefixes only) | GET /api/v1/keys | Session |
| Rotate secret | POST /api/v1/keys/{keyId}/rotate | Session |
| Revoke | DELETE /api/v1/keys/{keyId} | Session |
| Verify a key | POST /api/v1/keys/self-test | The key itself |
Key management always requires an interactive session. A key can never create, rotate, or revoke keys - that is the one authority a leaked key must not carry.
Create one in the Developers section of your dashboard, or via the API with your session:
POST /api/v1/keys{ "name": "my-bot", "scopes": ["accounts:read", "rooms:read", "trades:read"], "environment": "live", "ipAllowlist": [], // optional "expiresAt": null, // optional, epoch ms "rateLimitRpm": null // optional, clamped to the plan's rpm}The response contains the full key once, under key. Store it immediately.
Verify a key
POST /api/v1/keys/self-testAuthorization: Bearer tw_live_...{ "success": true, "data": { "via": "api_key", "keyId": "ab12cd34", "scopes": ["accounts:read", "rooms:read"], "canTrade": false, "entitlement": { "enabled": true, "maxKeys": 3, "rpm": 120, "ws": true, "wsConns": 3, "trade": false } }}Call this first whenever something returns 403 - it tells you whether the problem is the key, the scope, or the plan.
Revocation
Revocation takes effect on the next request. Any open WebSocket using the key is closed with 1008 KEY_REVOKED. Rotation issues a new secret under the same keyId, so your logs and dashboards keep their grouping - and closes open sockets the same way.
Scopes
| Scope | Grants |
|---|---|
accounts:read | List/get accounts, symbols, connection status; notifications; account WS channels |
accounts:write | Rename, reconnect, disconnect, sync symbols |
accounts:trade | Place / modify / close orders (REST + WS commands + close-all) |
rooms:read | Copy rooms, dashboards, historical trades, copy events |
rooms:write | Create/pause/resume/archive/edit rooms and receivers |
automations:read | Automations, execution logs, dry-run test |
automations:write | Create/update/delete automations and session filters |
trades:read | Trade events, portfolio analytics, trades SSE channel |
profile:read | Own profile |
keys:write | Never grantable - key management is session-only |
Rules:
- A key may only hold scopes its plan allows (
403 scope_not_in_planotherwise). accounts:tradeadditionally requires the plan's trade flag. Even with the scope, the call fails403 trade_scope_not_in_planwhen the plan forbids it.- Read/write separation is deliberate: a key that manages copy rooms must not be able to fire orders.
Plan entitlements
Whether an account may use the API at all is decided by its plan, not by the key. API access and MCP are included on Scale and Unlimited:
| Plan | Keys | Requests/minute | Sockets | Trading |
|---|---|---|---|---|
| Scale | 3 | 120 | 3 | Yes |
| Unlimited | 10 | 600 | 10 | Yes |
Behaviour when a subscription lapses:
- Existing keys are not deleted - they return
403 api_disabled. Re-subscribing restores them instantly. - Open WebSockets are not dropped mid-session; new connections are refused.
- Rate limits tighten on the next request.







