Go
Official Go SDK for Keplars
Installation
Install the package
go get github.com/KeplarsHQ/go-sdkSet your API key
export KEPLARS_API_KEY=kms_your_workspace_id.live_your_secretSend your first email
package main
import (
"context"
"fmt"
"os"
"github.com/KeplarsHQ/go-sdk/keplars"
)
func main() {
client, err := keplars.NewClient(os.Getenv("KEPLARS_API_KEY"))
if err != nil {
panic(err)
}
ctx := context.Background()
response, err := client.Emails.SendInstant(ctx, &keplars.SendEmailRequest{
From: "[email protected]",
To: "[email protected]",
Subject: "Hello!",
Body: "<h1>It works!</h1>",
IsHTML: true,
})
if err != nil {
panic(err)
}
fmt.Println("ID:", response.ID)
}Priority Levels
| Method | Delivery | Use case |
|---|---|---|
SendInstant | 0–5 seconds | OTP, 2FA, password reset |
SendHigh | 0–30 seconds | Transactional confirmations |
SendAsync / Send | 0–5 minutes | Welcome emails, notifications |
SendBulk | Background | Newsletters, campaigns |
client.Emails.SendInstant(ctx, req)
client.Emails.SendHigh(ctx, req)
client.Emails.SendAsync(ctx, req)
client.Emails.SendBulk(ctx, req)Using Templates
response, err := client.Emails.SendInstant(ctx, &keplars.SendEmailRequest{
From: "[email protected]",
To: "[email protected]",
TemplateID: "your-template-id",
Params: map[string]interface{}{
"user_name": "Jane",
"verification_code": "123456",
},
})Schedule an Email
response, err := client.Emails.Schedule(ctx, &keplars.ScheduleEmailRequest{
From: "[email protected]",
To: "[email protected]",
Subject: "Weekly digest",
Body: "<p>Here is your digest.</p>",
IsHTML: true,
ScheduledFor: "2026-02-01T09:00:00Z",
Timezone: "America/New_York",
})Error Handling
import "github.com/KeplarsHQ/go-sdk/keplars"
response, err := client.Emails.SendInstant(ctx, req)
if err != nil {
var authErr *keplars.AuthenticationError
var rateLimitErr *keplars.RateLimitError
switch {
case errors.As(err, &authErr):
fmt.Println("Invalid API key")
case errors.As(err, &rateLimitErr):
fmt.Printf("Rate limit hit, retry after: %v\n", rateLimitErr.RetryAfter)
default:
panic(err)
}
}Admin API
Need to manage contacts, audiences, automations, or domains? Use an admin key - same client, different key suffix:
client, _ := keplars.NewClient("kms_xxx.adm_xxx")
client.Contacts.Add(ctx, &keplars.AddContactRequest{Email: "[email protected]", Name: "Jane"})
client.Audiences.Create(ctx, "Newsletter", "")
client.Automations.Enroll(ctx, "auto_id", "[email protected]")
client.Domains.Verify(ctx, "domain_id")See the full Admin API reference.
Next Steps
- Admin API - Contacts, audiences, automations, domains
- Send Emails - API reference
- Email Templates - Build reusable templates
- Schedule Emails - Delayed delivery