MATIH Platform is in active MVP development. Documentation reflects current implementation status.
6. Identity & Access Management
API Key Endpoints

API Key Endpoints

The API key endpoints manage the full lifecycle of programmatic access keys, including creation, validation, scoping, rotation, and revocation. Served by ApiKeyController at /api/v1/api-keys.


Endpoints

MethodEndpointDescriptionRole
POST/api/v1/api-keysCreate API keyAny
GET/api/v1/api-keysList user's keysAny
GET/api/v1/api-keys/tenantList tenant keysAdmin
POST/api/v1/api-keys/validateValidate a keyAny
DELETE/api/v1/api-keys/:keyIdRevoke a keyOwner
DELETE/api/v1/api-keys/user/:userId/allRevoke all user keysAdmin
PATCH/api/v1/api-keys/:keyId/scopesUpdate key scopesOwner
PATCH/api/v1/api-keys/:keyId/ip-whitelistUpdate IP whitelistOwner
PATCH/api/v1/api-keys/:keyId/rate-limitUpdate rate limitOwner
GET/api/v1/api-keys/expiringGet expiring keysAdmin
GET/api/v1/api-keys/scopesGet available scopesAny
POST/api/v1/api-keys/:keyId/rotateInitiate key rotationOwner
GET/api/v1/api-keys/:keyId/rotation-statusGet rotation statusOwner
POST/api/v1/api-keys/:keyId/rotation/cancelCancel rotationOwner
POST/api/v1/api-keys/:keyId/rotation/completeComplete rotation nowOwner
GET/api/v1/api-keys/rotation-recommendationsGet rotation recommendationsAny

POST /api/v1/api-keys

Creates a new API key. The full key value is returned only once at creation time.

{
  "name": "CI Pipeline Key",
  "description": "Used by CI/CD pipeline for deployments",
  "scopes": ["queries:read", "queries:execute"],
  "keyType": "service",
  "testMode": false,
  "expirationDays": 90,
  "ipWhitelist": ["10.0.0.0/8"],
  "rateLimit": 1000
}
StatusDescription
201Key created, full key value returned
400Invalid request or scope
429API key limit exceeded for the user

Key Rotation

Rotation creates a new key and schedules the old key for revocation after a grace period. During the grace period, both keys are valid.

  1. Initiate: POST /api/v1/api-keys/:keyId/rotate -- returns the new key
  2. Check status: GET /api/v1/api-keys/:keyId/rotation-status
  3. Complete early: POST /api/v1/api-keys/:keyId/rotation/complete -- revokes old key immediately
  4. Cancel: POST /api/v1/api-keys/:keyId/rotation/cancel -- keeps old key, revokes new key

Error Codes

CodeStatusDescription
API_KEY_NOT_FOUND404Key does not exist
API_KEY_LIMIT_EXCEEDED429Maximum key count reached
DUPLICATE_KEY_NAME409Key name already in use
INVALID_SCOPE400Requested scope is not valid
ROTATION_IN_PROGRESS409Another rotation is already active
NO_ROTATION_IN_PROGRESS404No active rotation to cancel or complete