Skip to main content

API Keys (/api/v1/keys)

Manage programmatic API access for RiskInMind. These endpoints allow you to generate, retrieve, revoke, and regenerate your keys, as well as view API usage logs.


1. Retrieve Current API Key

Retrieve the active API key for the authenticated user.

  • Method: GET
  • Endpoint: /api/v1/keys/
  • Authentication: Required (Bearer Token)

Response

{
"success": true,
"data": {
"keyId": "key_12345",
"keySnippet": "sk_live_...9f8a",
"status": "ACTIVE",
"createdAt": "2023-10-01T12:00:00Z"
}
}

2. Generate API Key

Generates a new API Key for the authenticated user/organization. Note that if you already have an active key, this may overwrite it or return an error depending on the application limits.

  • Method: POST
  • Endpoint: /api/v1/keys/generate
  • Authentication: Required (Bearer Token)

Request Body

Optional metadata or labeling depending on implementation.

{
"label": "Production Application Key"
}

Response

{
"success": true,
"data": {
"apiKey": "sk_live_abcdef1234567890",
"createdAt": "2023-10-01T12:00:00Z"
}
}

Note: Ensure you store the apiKey safely. It may not be fully visible again.


3. Regenerate API Key

Revokes the current active API key and generates a new one.

  • Method: POST
  • Endpoint: /api/v1/keys/regenerate
  • Authentication: Required (Bearer Token)

Response

{
"success": true,
"data": {
"apiKey": "sk_live_newkey12345",
"message": "Key regenerated successfully."
}
}

4. Revoke API Key

Permanently revokes the current active API key.

  • Method: POST
  • Endpoint: /api/v1/keys/revoke
  • Authentication: Required (Bearer Token)

Response

{
"success": true,
"message": "API Key revoked successfully."
}

5. Get Usage Logs

Retrieve logs associated with the API key usage, useful for monitoring request volumes and rate limits.

  • Method: GET
  • Endpoint: /api/v1/keys/logs
  • Authentication: Required (Bearer Token)
  • Query Parameters:
    • page (optional): Page number.
    • limit (optional): Number of records per page.

Response

{
"success": true,
"data": [
{
"endpoint": "/api/v1/loans/predict",
"method": "POST",
"statusCode": 200,
"timestamp": "2023-10-01T12:05:00Z"
}
],
"meta": {
"total": 150,
"page": 1,
"limit": 10
}
}