Posthawk
SDK

Go
SDK

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-go
Simple API

Send emails with
idiomatic Go

Create a client, call Send, and check the error. Standard Go patterns — no wrappers, no magic. Just (T, error) tuples.

Go
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)}
Error Handling
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)
Typed Errors

errors.As for
API errors

All errors are *posthawk.Error with StatusCode and Message fields. Use standard Go error handling.

Scheduling

Schedule, cancel,
and reschedule

Send later by adding ScheduledFor. Full management API to list, cancel, or change the send time. Uses RFC 3339 time strings.

Go
// 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",})
Getting started

Up and running
in minutes

01

Install the module

One command to add posthawk-go to your project. Zero external dependencies — stdlib only.

02

Create a client

Initialize with your API key. Use WithBaseURL for self-hosted instances. The client handles auth and serialization.

03

Send your first email

Call client.Emails.Send() with a context and your params. Check the returned error, then use the result.

Zero Dependencies

Built entirely on Go's standard library — net/http, encoding/json, and context. No third-party packages to audit.

Idiomatic Errors

Every method returns (T, error) tuples. Errors are typed *posthawk.Error with StatusCode and Message fields.

Schedule Emails

Schedule, list, cancel, and reschedule emails. Pass RFC 3339 strings or format from time.Time.

Context Support

Every method accepts context.Context for timeout control, cancellation, and deadline propagation.

Start sending emails

Install the SDK and send your first email in under a minute.

Cookie Preferences

We use analytics cookies to understand how you use our site and improve your experience. Privacy Policy