API key format
Sentrail API keys start withagk_ and are generated once — the raw key is never stored. Sentrail stores only a SHA-256 hash.
Creating a key
Keys are created through the dashboard at Settings → API Keys → New Key, or via themanage-api-keys edge function (requires an authenticated user session with admin role).
When creating a key, you assign:
- Name — human-readable label
- Scopes — one or more of the valid scopes (see below)
- Expiry — number of days until the key expires (default: 90)
Passing the key
Include the key in theAuthorization header as a Bearer token on every request:
Scopes
| Scope | Grants access to |
|---|---|
gateway | gateway-proxy — forward requests to tool APIs |
evaluate | evaluate-action — evaluate without forwarding |
mcp | mcp-gate — MCP tool gating (falls back to evaluate) |
401.
Key lifecycle
Keys are checked on every request:- The raw key is hashed with SHA-256
- The hash is looked up in
api_keys - If
revoked = true, the key is rejected - If
expires_atis in the past, the key is rejected - If
scopesdoes not include the required scope, the key is rejected - On success,
last_used_atis updated
Revoking a key
Revoke a key in Settings → API Keys or via the manage-api-keys function. Revoked keys are rejected immediately on the next request.Error responses
401. Sentrail does not distinguish between a missing key and a wrong-scope key to avoid leaking information.
API keys (
agk_) are for agent-facing endpoints. The kill-switch, approval-decision, and manage-api-keys endpoints require a Supabase user JWT (from a logged-in dashboard session), not an agk_ key.