Auth
Session check. The rest of the Better Auth surface is served under `/api/v1/auth/*`.
List agent API keys
GET /api/v1/agent-keys
Keys owned by the signed-in user, each with the scopes it actually carries. The secret is never returned. Each key also carries rateLimit, the same budget the MCP endpoint publishes as X-RateLimit-*, so a client can show calls left and the reset instant without calling the key.
Responses
200— The user’s keys.object401— Missing or invalid credential (session token or API key; only when auth is configured). Error503— Auth is not configured in this environment. Error
curl "$API_URL/api/v1/agent-keys" \
-H "Authorization: Bearer $TOKEN"Mint an agent API key
POST /api/v1/agent-keys
Creates a 90-day key owned by the signed-in user. scopes chooses the grant in the same vocabulary the PRM advertises: onboarding, accounting:read, accounting:write; a token grants exactly itself and accounting:write does not imply read. Omit scopes for the full read+write grant every key has had (onboarding and accounting). An unknown token is a 400 with code: "invalid_scope" and the supported list, never silently dropped; unknown body fields are rejected. The granted scopes are returned here and by GET /api/v1/agent-keys. The full key is returned once.
Request body (application/json)
Type: object
| Field | Type | Required | Description |
|---|---|---|---|
agentId | string | yes | |
name | string | no | |
scopes | string[] | no |
Responses
201— The new key. Thekeyfield is shown only here.object400— Malformed request, or a scope outside the supported set. Error401— Missing or invalid credential (session token or API key; only when auth is configured). Error503— Auth is not configured in this environment. Error
curl -X POST "$API_URL/api/v1/agent-keys" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{ ... }'Revoke an agent API key
DELETE /api/v1/agent-keys/{id}
Deletes one of the signed-in user’s keys. Another user’s key is a 404.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | yes |
Responses
200— Key revoked. Ok401— Missing or invalid credential (session token or API key; only when auth is configured). Error404— Key not found. Error503— Auth is not configured in this environment. Error
curl -X DELETE "$API_URL/api/v1/agent-keys/:id" \
-H "Authorization: Bearer $TOKEN"Current session
GET /api/v1/auth/me
The credential behind this request and the user it belongs to. via says which one it was: apiKey for an elk_ key (x-api-key or Authorization: Bearer elk_…), oauth for an OAuth access token, session for a signed-in session token. Any valid credential may call it, so this is the one route an agent key can reach before it holds a scope (#193).
Responses
200— Authenticated.object401— Missing or invalid credential (session token or API key; only when auth is configured). Error503— Auth is not configured in this environment. Error
curl "$API_URL/api/v1/auth/me" \
-H "Authorization: Bearer $TOKEN"Schemas
Error
| Field | Type | Required | Description |
|---|---|---|---|
error | string | yes |
Ok
| Field | Type | Required | Description |
|---|---|---|---|
ok | true | yes |