Skip to content

API Keys

API keys are used to authenticate programmatic access to the MoMail API. Each key is tied to your account and carries specific rate limits and permissions.

Retrieve all API keys for your account.

GET /api-keys
{
"success": true,
"data": [
{
"keyId": "key_abc123",
"name": "Production API",
"keyPrefix": "mk_a1b****",
"plan": "pro",
"rateLimit": 100,
"lastUsed": "2024-01-15T10:30:00.000Z",
"createdAt": "2024-01-01T00:00:00.000Z",
"expirationTs": null
}
],
"meta": {
"total": 1
}
}
FieldTypeDescription
keyIdstringUnique identifier for the key
namestringHuman-readable name for the key
keyPrefixstringMasked prefix of the API key
planstringSubscription plan (free, pro, enterprise)
rateLimitnumberRequests per minute allowed
lastUsedstringISO 8601 timestamp of last API call
createdAtstringISO 8601 timestamp of key creation
expirationTsstringExpiration timestamp (null if no expiration)

Generate a new API key.

POST /api-keys
{
"name": "Production API",
"expirationDays": 365
}
FieldTypeRequiredDescription
namestringYesDescriptive name (1-100 characters)
expirationDaysnumberNoDays until key expires (1-365)
{
"success": true,
"data": {
"keyId": "key_abc123",
"name": "Production API",
"apiKey": "mk_a1b2c3d4_e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0",
"keyPrefix": "mk_a1b****",
"plan": "free",
"rateLimit": 20,
"expirationTs": "2025-01-15T00:00:00.000Z",
"createdAt": "2024-01-15T10:30:00.000Z"
},
"meta": {
"warning": "This API key will only be shown once. Please store it securely."
}
}

Revoke an API key.

DELETE /api-keys/{id}
ParameterTypeRequiredDescription
idstringYesKey UUID
{
"success": true,
"data": {
"keyId": "key_abc123",
"revoked": true
}
}
  1. Use environment variables: Never hardcode API keys in source code
  2. Rotate regularly: Set expiration dates and create new keys periodically
  3. Use separate keys per environment: Create distinct keys for dev, staging, and production
  4. Restrict access: Only grant necessary permissions per key
Terminal window
# .env file
MOMAIL_API_KEY=mk_a1b2c3d4_e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0
const apiKey = process.env.MOMAIL_API_KEY;
Terminal window
# List API keys
curl https://api.momail.io/v1/api-keys \
-H "X-API-Key: your_key"
# Create API key
curl -X POST https://api.momail.io/v1/api-keys \
-H "X-API-Key: your_key" \
-H "Content-Type: application/json" \
-d '{
"name": "Production API",
"expirationDays": 365
}'
# Delete API key
curl -X DELETE https://api.momail.io/v1/api-keys/key_abc123 \
-H "X-API-Key: your_key"