API Key Management
List, create, rotate, and revoke the rail_* API keys on your account. Key management lives on the Reporting API (https://api.tensorrail.com) under /v1/api-keys.
Listing keys and scopes works with any authenticated call. Creating, rotating, and revoking keys requires a signed-in dashboard operator with a fresh two-factor verification — an API key calling these endpoints receives 401 ERR_1019 (two_factor_required). This is deliberate: a leaked key must never be able to mint or replace credentials on its own.
Key modes
Keys have the shape rail_<type>_<mode>_<secret> (see Authentication). The mode is chosen at creation:
| Mode | Prefix | Operates on |
|---|---|---|
test | rail_<type>_test_… | Sandbox data |
live | rail_<type>_live_… | Production data |
List keys
GET /v1/api-keys
curl "https://api.tensorrail.com/v1/api-keys" \
-H "Authorization: Bearer rail_full_live_xxx"
Returns an array of key entries. Each entry includes at least:
| Field | Description |
|---|---|
key_id | The key's identifier — used in the rotate / revoke paths |
name | The label given at creation |
prefix | The non-secret prefix (e.g. rail_full_test_…); the secret itself is never returned after creation |
created | Creation timestamp (RFC 3339) |
List available scopes
GET /v1/scopes — no authentication required.
curl "https://api.tensorrail.com/v1/scopes"
{ "scopes": ["payments:read", "payments:write", "refunds:read", "…"] }
This is the machine-readable form of the scope table. New keys carry the 19 default scopes; contact your account manager for additional scopes (for example routing:write).
Create a key
POST /v1/api-keys — dashboard operator session + two-factor; scope api_keys:manage.
Body
| Field | Type | Required | Description |
|---|---|---|---|
mode | string | No | test (default) or live |
name | string | No | A label for the key |
The new key's plaintext is returned once in the response — store it immediately; only the prefix is retrievable afterwards.
In the dashboard: Developers → API Keys → Create key.
Rotate a key
POST /v1/api-keys/{id}/rotate — dashboard operator session + two-factor; scope api_keys:manage.
Rotation issues a replacement key and returns its plaintext once; the response's key_id identifies the new key. Rotation is the routine-hygiene path — the old key keeps working for a 24-hour grace window so you can deploy the replacement without downtime. Rotation requires a fresh two-factor step-up and is rate-limited. A security email is sent to your operators on every rotation.
For a suspected compromise, use Emergency key revoke instead: it kills the old key immediately, with no grace window and no cooldown.
Revoke a key
DELETE /v1/api-keys/{id} — dashboard operator session + two-factor; scope api_keys:manage.
Revokes the key. In the dashboard: Developers → API Keys → Revoke.
Key entries named tensorrail_gateway are TensorRail-managed credentials that keep your dashboard connected. They are hidden from the list and cannot be rotated or revoked through these endpoints (attempts return 403).
Errors
| Code | HTTP | Cause |
|---|---|---|
ERR_1019 | 401 | Mutation attempted without a fresh two-factor verification (including any API-key call) |
ERR_1004 | 403 | The session/key lacks api_keys:manage |
ERR_2002 | 400 | Malformed key id in the path |
ERR_3010 | 422 | Account provisioning is not complete yet |
ERR_5005 | 503 | The key service is temporarily unavailable; retry |
Related
- Authentication: key prefixes and the scope table
- Emergency key revoke: immediate revocation for compromised keys
- Reporting API: base URL and auth