Setup API Keys
Generate and manage API keys for programmatic email access
Generate API keys for secure programmatic access to Keplars Mail Service.
API Keys: Secure tokens that allow your applications to send emails programmatically without requiring manual login.
Create API Key
Access API Keys
- Sign in to dash.keplars.com
- Navigate to API Keys in the sidebar
- Click Generate New API Key
Configure Key
- Enter a descriptive name (e.g., "Production API")
- Select your connected email account
- Choose permissions (Send Emails is most common)
Save Key
Important: Copy your API key immediately - it's shown only once.
- Copy the generated API key
- Store it securely in your environment variables
- Click Done
Using API Keys
Basic Usage
Include your API key in the Authorization header:
curl -X POST "https://api.keplars.com/api/v1/send-email/async" \
-H "Authorization: Bearer $KEPLARS_API_KEY" \
-H "Content-Type: application/json" \
-d '{"to":["[email protected]"],"subject":"Hello from Keplars","body":"Your first API email!"}'const res = await fetch(
'https://api.keplars.com/api/v1/send-email/async',
{
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.KEPLARS_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
to: ['[email protected]'],
subject: 'Hello from Keplars',
body: 'Your first API email!',
}),
},
);
const { data } = await res.json();import requests, os
res = requests.post(
'https://api.keplars.com/api/v1/send-email/async',
json={
'to': ['[email protected]'],
'subject': 'Hello from Keplars',
'body': 'Your first API email!',
},
headers={'Authorization': f'Bearer {os.environ["KEPLARS_API_KEY"]}'},
)
data = res.json()['data']package main
import (
"bytes"
"fmt"
"io"
"net/http"
"os"
)
func main() {
body := bytes.NewBufferString(`{"to":["[email protected]"],"subject":"Hello from Keplars","body":"Your first API email!"}`)
req, _ := http.NewRequest("POST",
"https://api.keplars.com/api/v1/send-email/async", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KEPLARS_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, _ := (&http.Client{}).Do(req)
defer resp.Body.Close()
b, _ := io.ReadAll(resp.Body)
fmt.Println(string(b))
}<?php
$ch = curl_init('https://api.keplars.com/api/v1/send-email/async');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => json_encode([
'to' => ['[email protected]'],
'subject' => 'Hello from Keplars',
'body' => 'Your first API email!',
]),
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('KEPLARS_API_KEY'),
'Content-Type: application/json',
],
]);
$data = json_decode(curl_exec($ch), true)['data'];
curl_close($ch);using System.Net.Http;
using System.Net.Http.Json;
var client = new HttpClient();
client.DefaultRequestHeaders.Add(
"Authorization", $"Bearer {Environment.GetEnvironmentVariable("KEPLARS_API_KEY")}"
);
var response = await client.PostAsJsonAsync(
"https://api.keplars.com/api/v1/send-email/async",
new
{
to = new[] { "[email protected]" },
subject = "Hello from Keplars",
body = "Your first API email!"
}
);
var body = await response.Content.ReadAsStringAsync();use reqwest::Client;
use serde_json::json;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new();
let res = client
.post("https://api.keplars.com/api/v1/send-email/async")
.header("Authorization", format!("Bearer {}", std::env::var("KEPLARS_API_KEY")?))
.json(&json!({
"to": [
"[email protected]"
],
"subject": "Hello from Keplars",
"body": "Your first API email!"
}))
.send()
.await?;
let data: serde_json::Value = res.json().await?;
println!("{}", data);
Ok(())
}#include <curl/curl.h>
#include <cstdlib>
#include <string>
int main() {
CURL* curl = curl_easy_init();
std::string auth = std::string("Authorization: Bearer ") + std::getenv("KEPLARS_API_KEY");
const char* payload = "{\"to\":[\"[email protected]\"],\"subject\":\"Hello from Keplars\",\"body\":\"Your first API email!\"}";
struct curl_slist* headers = nullptr;
headers = curl_slist_append(headers, auth.c_str());
headers = curl_slist_append(headers, "Content-Type: application/json");
curl_easy_setopt(curl, CURLOPT_URL, "https://api.keplars.com/api/v1/send-email/async");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, payload);
curl_easy_perform(curl);
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
}#include <curl/curl.h>
#include <stdio.h>
#include <stdlib.h>
int main(void) {
CURL* curl = curl_easy_init();
char auth[256];
snprintf(auth, sizeof(auth), "Authorization: Bearer %s", getenv("KEPLARS_API_KEY"));
const char* payload = "{\"to\":[\"[email protected]\"],\"subject\":\"Hello from Keplars\",\"body\":\"Your first API email!\"}";
struct curl_slist* headers = NULL;
headers = curl_slist_append(headers, auth);
headers = curl_slist_append(headers, "Content-Type: application/json");
curl_easy_setopt(curl, CURLOPT_URL, "https://api.keplars.com/api/v1/send-email/async");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, payload);
curl_easy_perform(curl);
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
return 0;
}Environment Variables
Store your API key securely:
# .env file
KEPLERS_API_KEY=kms_your_api_key_here// In your application
const apiKey = process.env.KEPLERS_API_KEY;Manage API Keys
View Keys
In your dashboard's API Keys section, you can:
- View all your API keys
- See usage statistics
- Check last activity
Update Keys
- Edit: Change name or permissions
- Deactivate: Temporarily disable
- Delete: Permanently remove
Security
Best Practices:
- Never commit API keys to code repositories
- Use environment variables
- Rotate keys regularly
- Monitor usage for suspicious activity
Admin API Keys
Admin API keys are separate from regular keys and are used exclusively for the Marketing API - creating audiences, managing contacts, and reading campaign data.
How Admin Keys Differ
| Regular API Key | Admin API Key | |
|---|---|---|
| Format | kms_xxx.live_xxx | kms_xxx.adm_xxx |
| Purpose | Send emails | Manage audiences & contacts |
| Scopes | None (send-only) | Granular: contacts:read, contacts:write, audiences:manage |
| Limit | No limit | Max 5 per workspace |
| Used for | /send-email/* endpoints | /public/audiences/* and /public/contacts/* |
Regular API keys are rejected with 403 FORBIDDEN on all Marketing API endpoints. You must use an Admin key.
Create an Admin API Key
Access Admin API Keys
- Sign in to dash.keplars.com
- Navigate to Settings → Admin API Keys
- Click Create Admin Key
Configure Scopes
Give the key a name, then select the scopes it needs:
| Scope | Allows |
|---|---|
contacts:read | GET /contacts/get-contacts, GET /contacts/get-contact |
contacts:write | POST /contacts/add-contact, PATCH /contacts/update-contact, DELETE /contacts/delete-contact |
audiences:manage | All audience endpoints (list, get, create, delete) |
Select only the scopes the key actually needs.
Save the Key
Copy the key immediately - it is shown only once.
Store it in your environment:
KEPLARS_ADMIN_KEY=kms_019abc.adm_x9y8z7...Using Your Admin Key
Pass it the same way as a regular key:
curl "https://api.keplars.com/api/v1/public/audiences/get-audiences" \
-H "Authorization: Bearer $KEPLARS_ADMIN_KEY"const res = await fetch(
'https://api.keplars.com/api/v1/public/audiences/get-audiences',
{ headers: { Authorization: `Bearer ${process.env.KEPLARS_ADMIN_KEY}` } },
);
const { data } = await res.json();import requests, os
res = requests.get(
'https://api.keplars.com/api/v1/public/audiences/get-audiences',
headers={'Authorization': f'Bearer {os.environ["KEPLARS_ADMIN_KEY"]}'},
)
data = res.json()['data']package main
import (
"fmt"
"io"
"net/http"
"os"
)
func main() {
req, _ := http.NewRequest("GET",
"https://api.keplars.com/api/v1/public/audiences/get-audiences", nil)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KEPLARS_ADMIN_KEY"))
resp, _ := (&http.Client{}).Do(req)
defer resp.Body.Close()
b, _ := io.ReadAll(resp.Body)
fmt.Println(string(b))
}<?php
$ch = curl_init('https://api.keplars.com/api/v1/public/audiences/get-audiences');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('KEPLARS_ADMIN_KEY'),
],
]);
$data = json_decode(curl_exec($ch), true)['data'];
curl_close($ch);using System.Net.Http;
var client = new HttpClient();
client.DefaultRequestHeaders.Add(
"Authorization", $"Bearer {Environment.GetEnvironmentVariable("KEPLARS_ADMIN_KEY")}"
);
var response = await client.GetAsync(
"https://api.keplars.com/api/v1/public/audiences/get-audiences"
);
var body = await response.Content.ReadAsStringAsync();use reqwest::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new();
let res = client
.get("https://api.keplars.com/api/v1/public/audiences/get-audiences")
.header("Authorization", format!("Bearer {}", std::env::var("KEPLARS_ADMIN_KEY")?))
.send()
.await?;
let data: serde_json::Value = res.json().await?;
println!("{}", data);
Ok(())
}#include <curl/curl.h>
#include <cstdlib>
#include <string>
int main() {
CURL* curl = curl_easy_init();
std::string auth = std::string("Authorization: Bearer ") + std::getenv("KEPLARS_ADMIN_KEY");
struct curl_slist* headers = nullptr;
headers = curl_slist_append(headers, auth.c_str());
curl_easy_setopt(curl, CURLOPT_URL, "https://api.keplars.com/api/v1/public/audiences/get-audiences");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_perform(curl);
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
}#include <curl/curl.h>
#include <stdio.h>
#include <stdlib.h>
int main(void) {
CURL* curl = curl_easy_init();
char auth[256];
snprintf(auth, sizeof(auth), "Authorization: Bearer %s", getenv("KEPLARS_ADMIN_KEY"));
struct curl_slist* headers = NULL;
headers = curl_slist_append(headers, auth);
curl_easy_setopt(curl, CURLOPT_URL, "https://api.keplars.com/api/v1/public/audiences/get-audiences");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_perform(curl);
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
return 0;
}Next Steps
- Send Emails - Start sending emails with your API key
- Marketing Guide - Create audiences and send campaigns
- Audiences API - Manage audiences programmatically
- Contacts API - Add and manage contacts via API
- Webhooks - Get delivery notifications