API Reference
Complete reference for all Keplars REST API endpoints.
Base URL: https://api.keplars.com/api/v1
All endpoints require a Bearer token:
Authorization: Bearer $KEPLARS_API_KEYAPI Key Types
Keplars has two types of API keys with different purposes and formats.
Regular API Keys
Used for sending emails programmatically. Created under Settings → API Keys in the dashboard.
Format: kms_<workspaceId>.live_<secret>
Example: kms_019abc.live_a1b2c3d4e5f6...These keys are tied to a specific email account in your workspace and can only call the email sending endpoints.
Admin API Keys
Used for the Marketing API - managing audiences, contacts, and reading campaign data. Created under Settings → Admin API Keys in the dashboard.
Format: kms_<workspaceId>.adm_<secret>
Example: kms_019abc.adm_x9y8z7w6v5u4...Admin keys are scoped - you choose which permissions to grant when creating the key. They also cover the Domains API for programmatic custom domain provisioning.
| Scope | Access |
|---|---|
contacts:read | List and get contacts |
contacts:write | Add, update, and delete contacts |
audiences:manage | Create, list, get, and delete audiences |
automations:read | List and get automations |
automations:write | Create and update automations |
automations:trigger | Trigger automation runs |
domains:manage | Add custom sending domains, verify, and delete |
api-keys:create | Create regular (sending) API keys tied to a verified custom domain |
Which key do I need?
For sending emails → use a Regular API key. For audiences and contacts → use an Admin API key with the required scope. Marketing endpoints reject Regular keys with 403 FORBIDDEN. For programmatic domain provisioning: domains:manage to add/verify domains, api-keys:create to generate the sending key for a domain.
Admin key limit
You can have a maximum of 5 Admin API keys per workspace. Regular keys have no limit.
Programmatic Domain Provisioning
Use this flow to go from zero to sending email from your own domain entirely via the API - no dashboard required.
You need an Admin API key with both domains:manage and api-keys:create scopes.
Step 1 - Add your domain
POST /api/v1/public/domains/add-domain
Authorization: Bearer <admin-key>
{
"domain": "mail.yourdomain.com",
"region": "us-east-1"
}Save the id from the response - you'll need it in every subsequent step.
{
"data": {
"id": "b1e2f3a4-...",
"domain": "mail.yourdomain.com",
"status": "pending",
"dns_records": { ... }
}
}Add the DNS records returned in dns_records to your DNS provider (SPF, DKIM, DMARC, MAIL FROM).
Step 2 - Verify the domain
Poll this endpoint until verification_status is verified. DNS propagation typically takes 2–10 minutes.
GET /api/v1/public/domains/domain-status/{domainID}
Authorization: Bearer <admin-key>{
"data": {
"verification_status": "verified"
}
}You can also trigger an active re-check:
POST /api/v1/public/domains/verify-domain/{domainID}
Authorization: Bearer <admin-key>Step 3 - Create a sending API key
POST /api/v1/public/domains/api-keys/create
Authorization: Bearer <admin-key>
{
"name": "My App Sending Key",
"custom_domain_id": "b1e2f3a4-..."
}{
"data": {
"secret_key": "kms_019abc.live_a1b2c3d4...",
"api_key": { "id": "...", "name": "My App Sending Key" }
}
}Store the key now
secret_key is shown once and cannot be retrieved again. Save it to your secrets manager (e.g. environment variable, Vault, Bitwarden) before proceeding.
Step 4 - Send email
Use the secret_key from Step 3 as a Regular API key on any send endpoint:
POST /api/v1/send-email/instant
Authorization: Bearer kms_019abc.live_a1b2c3d4...
{
"from": "[email protected]",
"to": [{ "email": "[email protected]" }],
"subject": "Hello from my domain",
"html": "<p>It works!</p>"
}Endpoints
Examples
End-to-end code examples in Node.js, Python, Go, and cURL.
Email Sending
5 priority-tiered endpoints: instant, high, async, bulk, and schedule.
Contacts
Add and update contacts within audiences.
Audiences
Create and manage contact audiences for email campaigns.
Automations
Build and trigger automated email workflows.
Domains
Programmatically add custom sending domains and poll verification status.
Sending Regions
Domain endpoints accept a region field that controls which Keplars sending infrastructure handles mail from your domain. Choose the region closest to your recipients for best deliverability.
| Value | Location | Default |
|---|---|---|
us-east-1 | United States | ✓ |
ap-southeast-1 | Singapore | |
af-south-1 | Cape Town |
Omitting region defaults to us-east-1. The region is fixed at creation time and cannot be changed after the domain is added.
Error Format
All errors return a consistent JSON shape:
{
"success": false,
"error": "VALIDATION_ERROR",
"message": "Field 'to' is required"
}| Status | Code | Meaning |
|---|---|---|
| 401 | UNAUTHORIZED | Missing or invalid API key |
| 403 | FORBIDDEN | Key type not allowed for this endpoint |
| 403 | INSUFFICIENT_SCOPE | Admin key missing required scope |
| 400 | VALIDATION_ERROR | Missing required field or invalid value |
| 400 | INVALID_TEMPLATE | template_id not found |
| 429 | RATE_LIMITED | Plan email quota reached |
| 403 | PLAN_REQUIRED | Feature requires LAUNCH plan or higher |
| 500 | INTERNAL_ERROR | Retry with exponential backoff |