Groundmail with Go
Use the Go SDK in HTTP handlers, workers, cron jobs, or any server-side Go service where your API key can stay private.
1. Install the SDK
go get github.com/Groundmail/groundmail-sdks/go@v0.8.22. Configure your API key
export GROUNDMAIL_API_KEY=gm_your_key_here3. Send an email
package main
import (
"fmt"
"log"
"os"
groundmail "github.com/Groundmail/groundmail-sdks/go"
)
func main() {
client, err := groundmail.New(os.Getenv("GROUNDMAIL_API_KEY"))
if err != nil {
log.Fatal(err)
}
result, err := client.Emails.Send(map[string]any{
"from": "ops@yourdomain.com",
"to": "user@example.com",
"subject": "Your receipt",
"html": "<p>Thanks for your purchase.</p>",
})
if err != nil {
log.Fatal(err)
}
fmt.Println(result["id"], result["status"])
}Resources
The client includes thin wrappers for common API resources:
client.Emails— send, batch, list, cancel, resend, test webhooks, deliverability insightsclient.Domains— create, verify, apply DNS, update, deleteclient.Webhooks— CRUD for webhook endpointsclient.Templates— CRUD plus publishclient.Suppressions— list, create, remove
See the API reference for request fields. The Go SDK accepts the same JSON shapes as the REST API.
Source
Package source lives in go/ in the public groundmail-sdks repository (mirrored from the private app monorepo on release).