/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_KEY` on every route.
- Backend prerequisite: define `ADMIN_API_KEY=your-key` in the DB backend `.env` before calling these routes.
- List: returns masked metadata only.
- Create: returns masked metadata plus the raw `apiKey` once.
- Rotate: returns masked metadata plus the replacement raw `apiKey` once.
- 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 `apiKey` immediately because the backend may not return it again.
- Masked list responses: treat `maskedKey` and `keyPrefix` as display-only metadata.
- Client usage: send the saved raw key later as `x-api-key` on 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.
