The official Posthawk SDK for Go. Zero external dependencies, idiomatic error handling, and context support. Send your first email in under a minute.
$ go get github.com/endibuka/posthawk-goCreate a client, call Send, and check the error. Standard Go patterns — no wrappers, no magic. Just (T, error) tuples.
package mainimport ( "context" "fmt" "log" posthawk "github.com/endibuka/posthawk-go")func main() { client := posthawk.New("ck_live_...") result, err := client.Emails.Send(context.Background(), &posthawk.SendEmailRequest{ From: "hi@yourdomain.com", To: []string{"user@example.com"}, Subject: "Hello from Posthawk", HTML: "<h1>Welcome!</h1>", }) if err != nil { log.Fatal(err) } fmt.Println("Sent! Job ID:", result.JobID)}result, err := client.Emails.Send(ctx, &posthawk.SendEmailRequest{ From: "hi@yourdomain.com", To: []string{"user@example.com"}, Subject: "Test", HTML: "<p>Hello</p>",})if err != nil { var posthawkErr *posthawk.Error if errors.As(err, &posthawkErr) { fmt.Printf("API error %d: %s\n", posthawkErr.StatusCode, posthawkErr.Message, ) } return}fmt.Println("Success:", result.JobID)All errors are *posthawk.Error with StatusCode and Message fields. Use standard Go error handling.
Send later by adding ScheduledFor. Full management API to list, cancel, or change the send time. Uses RFC 3339 time strings.
// Schedule for laterresult, err := client.Emails.Send(ctx, &posthawk.SendEmailRequest{ From: "hi@yourdomain.com", To: []string{"user@example.com"}, Subject: "Reminder", Text: "Don't forget your appointment!", ScheduledFor: time.Now().Add(24 * time.Hour).Format(time.RFC3339),})// Manage scheduled emailslist, _ := client.Scheduled.List(ctx, &posthawk.ListScheduledParams{ Status: "scheduled",})client.Scheduled.Cancel(ctx, "id")client.Scheduled.Reschedule(ctx, "id", &posthawk.RescheduleRequest{ ScheduledFor: "2026-04-01T10:00:00Z",})One command to add posthawk-go to your project. Zero external dependencies — stdlib only.
Initialize with your API key. Use WithBaseURL for self-hosted instances. The client handles auth and serialization.
Call client.Emails.Send() with a context and your params. Check the returned error, then use the result.
Built entirely on Go's standard library — net/http, encoding/json, and context. No third-party packages to audit.
Every method returns (T, error) tuples. Errors are typed *posthawk.Error with StatusCode and Message fields.
Schedule, list, cancel, and reschedule emails. Pass RFC 3339 strings or format from time.Time.
Every method accepts context.Context for timeout control, cancellation, and deadline propagation.
Install the SDK and send your first email in under a minute.
We use analytics cookies to understand how you use our site and improve your experience. Privacy Policy