Skip to main content
POST
/
v1
/
api-keys
Create API Key
curl --request POST \
  --url https://api.example.com/v1/api-keys \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "<string>",
  "permissions": [
    "<string>"
  ],
  "domainRestrictions": [
    "<string>"
  ],
  "ipRestrictions": [
    "<string>"
  ],
  "expiresAt": "<string>"
}
'

Create API Key

Create a new API key with specified permissions.
name
string
required
A descriptive name for the API key.
permissions
string[]
Array of permissions. Use * for full access.
domainRestrictions
string[]
Restrict key to specific domains.
ipRestrictions
string[]
Restrict key to specific IP addresses or CIDR ranges.
expiresAt
string
ISO 8601 timestamp for key expiration.

Request

curl -X POST https://api.lettr.dev/v1/api-keys \
  -H "Authorization: Bearer le_xxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Production Server",
    "permissions": ["emails:send", "emails:read"]
  }'

Response

{
  "id": "key_123abc",
  "object": "api_key",
  "name": "Production Server",
  "key": "le_xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "permissions": ["emails:send", "emails:read"],
  "domainRestrictions": [],
  "ipRestrictions": [],
  "createdAt": "2024-01-15T10:30:00Z"
}
The full API key is only shown once upon creation. Store it securely—you won’t be able to retrieve it again.

Available Permissions

PermissionDescription
*Full access
emails:sendSend emails
emails:readRead email details
emails:listList emails
domains:*All domain operations
api-keys:*All API key operations
webhooks:*All webhook operations
analytics:readRead analytics