Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.paubox.com/llms.txt

Use this file to discover all available pages before exploring further.

1

Install the SDK

Add the SDK to your Go module:
go get github.com/paubox/paubox-go
The SDK requires Go 1.22 or later and has no external dependencies.
2

Set your credentials

Export your Paubox API key and username as environment variables:
export PAUBOX_API_KEY="YOUR_API_KEY"
export PAUBOX_USERNAME="YOUR_USERNAME"
To obtain credentials, see Authentication.
3

Send your first email

Create a file main.go with the following code:
package main

import (
    "context"
    "fmt"
    "log"
    "os"

    paubox "github.com/paubox/paubox-go"
)

func main() {
    client, err := paubox.New(
        os.Getenv("PAUBOX_API_KEY"),
        os.Getenv("PAUBOX_USERNAME"),
    )
    if err != nil {
        log.Fatal(err)
    }

    ctx := context.Background()

    resp, err := client.SendMessage(ctx, &paubox.SendMessageRequest{
        Message: paubox.Message{
            Recipients: []string{"recipient@example.com"},
            Headers: paubox.MessageHeaders{
                From:    "sender@yourdomain.com",
                Subject: "Your first Paubox email",
            },
            Content: paubox.MessageContent{
                PlainText: paubox.Ptr("This message was sent with the Paubox Go SDK."),
            },
        },
    })
    if err != nil {
        log.Fatal(err)
    }

    fmt.Println("Sent. Tracking ID:", resp.SourceTrackingID)
}
Run it:
go run main.go
Sent. Tracking ID: abc123-def456-...
4

Check delivery status

Use the tracking ID returned by SendMessage to check delivery:
disp, err := client.GetEmailDisposition(ctx, resp.SourceTrackingID)
if err != nil {
    log.Fatal(err)
}

for _, d := range disp.Data.Message.MessageDeliveries {
    fmt.Printf("%s%s\n", d.Recipient, d.Status.DeliveryStatus)
}
recipient@example.com → delivered

Next steps

  • Email client: send batches, attach files, manage dynamic templates, handle errors
  • Forms client: retrieve form schemas and submit responses