/docs/components/api-key-management/api
REST API
Route and payload reference for internal API key administration.
These routes manage client API keys through an internal admin experience.
- Admin auth header: include
x-admin-key: ADMIN_API_KEYon every route. - Backend prerequisite: define
ADMIN_API_KEY=your-keyin the DB backend.envbefore calling these routes. - List: returns masked metadata only.
- Create: returns masked metadata plus the raw
apiKeyonce. - Rotate: returns masked metadata plus the replacement raw
apiKeyonce. - Delete: permanently removes the client key.
Routes
The create and update routes accept a name, active flag, and optional expiry date. The rotate route only needs the admin header.
Create Key
Update Key
Rotate Key
Request Contracts
Create and rotate responses expose the raw key once. Later list and get operations expose only masked or prefixed values.
- Raw key handling: save
apiKeyimmediately because the backend may not return it again. - Masked list responses: treat
maskedKeyandkeyPrefixas display-only metadata. - Client usage: send the saved raw key later as
x-api-keyon protected business routes.
Response Contracts
Handle these backend outcomes explicitly in the client admin experience.
- 401/403: missing or invalid
x-admin-key. - 404 Not Found: requested key record does not exist.
- 400 Bad Request: invalid create or update payload.
- One-time raw key: create and rotate are the only reliable moments to capture the full client key.
