Skip to content

API Keys

API keys authenticate all requests to the Mandato API. Each key is scoped to an account and an environment (test or production). You can create multiple keys for different services, CI/CD pipelines, or team members.

When listing keys, the key value is masked — only the prefix is shown.

{
"id": "key_a1b2c3d4e5f6",
"name": "Production backend",
"keyPrefix": "sk_live_4f8a",
"environment": "production",
"lastUsedAt": "2025-01-15T10:00:00.000Z",
"expiresAt": null,
"revokedAt": null,
"createdAt": "2025-01-10T09:00:00.000Z"
}
FieldTypeDescription
idstringUnique API key identifier
namestringHuman-readable name for the key
keyPrefixstringFirst 12 characters of the key (e.g., sk_live_4f8a)
environmentstringtest or production
lastUsedAtstring|nullISO 8601 timestamp of last use
expiresAtstring|nullISO 8601 expiration timestamp (null = never expires)
revokedAtstring|nullISO 8601 revocation timestamp (null = active)
createdAtstringISO 8601 creation timestamp

When creating a key, the full key value is returned once:

{
"id": "key_a1b2c3d4e5f6",
"key": "sk_live_4f8a9b2c3d1e6f7a8b9c0d1e2f3a4b5c",
"keyPrefix": "sk_live_4f8a",
"name": "Production backend",
"environment": "production",
"expiresAt": null,
"createdAt": "2025-01-10T09:00:00.000Z"
}

GET /v1/api-keys

Returns all API keys for your account, including revoked keys. Key values are masked.

Terminal window
curl https://api.getmandato.dev/v1/api-keys \
-H "Authorization: Bearer sk_test_your_key"
{
"data": [
{
"id": "key_a1b2c3d4e5f6",
"name": "Production backend",
"keyPrefix": "sk_live_4f8a",
"environment": "production",
"lastUsedAt": "2025-01-15T10:00:00.000Z",
"expiresAt": null,
"revokedAt": null,
"createdAt": "2025-01-10T09:00:00.000Z"
},
{
"id": "key_f6e5d4c3b2a1",
"name": "CI/CD pipeline",
"keyPrefix": "sk_test_b2c1",
"environment": "test",
"lastUsedAt": "2025-01-14T16:30:00.000Z",
"expiresAt": "2026-01-01T00:00:00.000Z",
"revokedAt": null,
"createdAt": "2025-01-11T10:00:00.000Z"
},
{
"id": "key_c3d4e5f6a1b2",
"name": "Old staging key",
"keyPrefix": "sk_test_9a8b",
"environment": "test",
"lastUsedAt": "2024-12-01T08:00:00.000Z",
"expiresAt": null,
"revokedAt": "2025-01-05T12:00:00.000Z",
"createdAt": "2024-06-15T09:00:00.000Z"
}
]
}

POST /v1/api-keys

Creates a new API key. The full key value is included in the response and will not be shown again.

FieldTypeRequiredDescription
namestringYesDescriptive name for the key
environmentstringNotest (default) or production
expiresAtstringNoISO 8601 expiration date. Omit for a key that never expires.
Terminal window
curl -X POST https://api.getmandato.dev/v1/api-keys \
-H "Authorization: Bearer sk_test_your_key" \
-H "Content-Type: application/json" \
-d '{
"name": "Production backend",
"environment": "production",
"expiresAt": "2026-01-01T00:00:00.000Z"
}'
{
"data": {
"id": "key_a1b2c3d4e5f6",
"key": "sk_live_4f8a9b2c3d1e6f7a8b9c0d1e2f3a4b5c",
"keyPrefix": "sk_live_4f8a",
"name": "Production backend",
"environment": "production",
"expiresAt": "2026-01-01T00:00:00.000Z",
"createdAt": "2025-01-10T09:00:00.000Z"
}
}
StatusTypeDescription
400validation_errorMissing name, invalid environment, or invalid expiration date

DELETE /v1/api-keys/:id

Revokes an API key immediately. Revoked keys cannot be used to authenticate and cannot be re-activated. Create a new key as a replacement.

ParameterTypeDescription
idstringAPI key ID (e.g., key_a1b2c3d4e5f6)
Terminal window
curl -X DELETE https://api.getmandato.dev/v1/api-keys/key_a1b2c3d4e5f6 \
-H "Authorization: Bearer sk_test_your_key"
{
"data": {
"id": "key_a1b2c3d4e5f6",
"revoked": true
}
}
StatusTypeDescription
404not_foundAPI key not found or belongs to a different account
409conflictAPI key is already revoked

Use descriptive names that indicate the purpose and environment of each key:

NameEnvironmentUsage
Production backendproductionMain application server
CI/CD pipelinetestAutomated testing in CI
Staging servertestPre-production environment
Mobile app v2productionMobile client integration
Partner integration - AcmeproductionThird-party partner access

This makes it easy to identify which key to revoke if one is compromised, and to audit key usage in the dashboard.