Skip to content

API Keys Rail

API key management, rotation, and access control.

The API Keys Rail provides endpoints for creating, managing, and securing API keys for programmatic access.

/api/v1/api-keys
POST /api/v1/api-keys

Create a new API key.

Request Body:

{
"name": "Production Integration",
"type": "SECRET",
"scopes": ["contracts:read", "contracts:write", "kyc:read"],
"expiresAt": "2026-01-15",
"ipWhitelist": ["192.168.1.0/24", "10.0.0.0/8"],
"rateLimit": 1000,
"metadata": {
"environment": "production",
"team": "backend"
}
}

Response:

{
"data": {
"keyId": "key_abc123",
"name": "Production Integration",
"key": "IOF_GENERATED_KEY_SHOWN_ONCE",
"prefix": "sk_live",
"type": "SECRET",
"scopes": ["contracts:read", "contracts:write", "kyc:read"],
"expiresAt": "2026-01-15T00:00:00Z",
"createdAt": "2025-01-15T10:00:00Z"
}
}

::: caution The full API key is only shown once. Store it securely. :::

GET /api/v1/api-keys

List all API keys.

Query Parameters:

ParameterTypeDescription
typestringFilter by key type
statusstringFilter by status

Response:

{
"data": [
{
"keyId": "key_abc123",
"name": "Production Integration",
"prefix": "sk_live_xxx",
"type": "SECRET",
"status": "ACTIVE",
"lastUsedAt": "2025-01-15T09:30:00Z",
"expiresAt": "2026-01-15T00:00:00Z"
}
]
}
GET /api/v1/api-keys/:keyId

Get API key details (not the key itself).

PATCH /api/v1/api-keys/:keyId

Update API key settings.

Request Body:

{
"name": "Production Integration (Updated)",
"scopes": ["contracts:read"],
"ipWhitelist": ["192.168.1.0/24"]
}
POST /api/v1/api-keys/:keyId/rotate

Rotate an API key.

Request Body:

{
"gracePeriod": "24h"
}

Response:

{
"data": {
"keyId": "key_abc123",
"newKey": "IOF_ROTATED_KEY_SHOWN_ONCE",
"oldKeyValidUntil": "2025-01-16T10:00:00Z"
}
}
DELETE /api/v1/api-keys/:keyId

Revoke an API key.

GET /api/v1/api-keys/:keyId/usage

Get API key usage statistics.

Query Parameters:

ParameterTypeDescription
periodstringHOURLY, DAILY, MONTHLY
fromstringStart date
tostringEnd date

Response:

{
"data": {
"keyId": "key_abc123",
"period": "DAILY",
"usage": [
{
"date": "2025-01-15",
"requests": 15420,
"errors": 23,
"latencyP50": 45,
"latencyP99": 250
}
],
"totals": {
"requests": 150000,
"errors": 230
}
}
}
POST /api/v1/api-keys/validate

Validate an API key.

Request Body:

{
"key": "${IOF_API_KEY}"
}

Response:

{
"data": {
"valid": true,
"keyId": "key_abc123",
"scopes": ["contracts:read", "contracts:write"],
"tenantId": "tenant_123"
}
}
TypePrefixDescription
SECRETsk_Full access (server-side)
PUBLISHABLEpk_Limited access (client-side)
RESTRICTEDrk_Restricted scope
StatusDescription
ACTIVEKey is active
ROTATINGKey is being rotated
EXPIREDKey has expired
REVOKEDKey was revoked
ScopeDescription
contracts:readRead contracts
contracts:writeCreate/update contracts
kyc:readRead KYC data
kyc:writeSubmit KYC
adminFull admin access
EventDescription
api_key.createdKey created
api_key.rotatedKey rotated
api_key.revokedKey revoked
api_key.expiredKey expired
api_key.usedKey used (audit)