POST /api/v1/oauth/clients
Create a new OAuth 2.0 client. Admin only.Request Body
Only
read, write, and admin are accepted. Unknown scopes are silently dropped; if every scope is dropped, the request falls back to ["read"].
Example
Response (201)
clientId is kci_ followed by 16 random bytes (hex); clientSecret is kcs_ followed by 32 random bytes (hex). Only the HMAC-SHA256 hash of the secret is persisted — the cleartext secret is never stored.
GET /api/v1/oauth/clients
List active (non-revoked) OAuth clients for the tenant. Admin only. Returns at most 1000 rows ordered bycreatedAt descending.
Response
DELETE /api/v1/oauth/clients?id=
Revoke an OAuth client (soft delete — setsrevokedAt). Admin only.
Query Parameters
Response
204 No Content on success. 404 Not Found when the id does not belong to the caller’s tenant.
POST /api/v1/oauth/token
Exchange client credentials for an access token. Follows the OAuth 2.0 client credentials grant. Rate limited to 20 requests per 60 seconds perclient_id (or per IP when client_id is absent). The rate limiter is fail-closed — if Redis is unreachable the request is denied to prevent brute-force attacks.
Accepts both application/x-www-form-urlencoded and application/json request bodies.
Request Body
Example — Form Encoded
Example — JSON
Response
{ sub: clientId, tid: tenantId, role, scopes, iss: "kaireon", iat, exp } and is signed HS256 with the JWT_SIGNING_SECRET. role is derived from scopes — admin scope grants admin role, write grants editor, otherwise the role is viewer.
Error Responses
Using the Token
Include the access token in theAuthorization header for subsequent API calls:
Configuration
The OAuth subsystem reads three environment variables. The token route hard-fails on startup when the required ones are missing — there is no silent dev-only fallback.
Rotating either secret invalidates all in-flight access tokens (HS256 signature verify fails) and breaks
clientSecret verification for every existing client. Plan rotations during a maintenance window and re-issue client secrets after the rotation.
See also: Authentication | Environment variables