We have a confession to make: we absolutely love the Go Programming Language! And since Go has been so good to us, we couldn't resist building a Go SDK for AhaSend. So we did!
We are proud to announce that the official Go SDK for AhaSend has been released!
Our Go SDK comes packed with features:
- Complete APIv2 Coverage: Send emails, manage domains, webhooks, routes, suppressions, and more
- Type Safety: Full Go type system with pointer utilities for optional fields
- Built-in Rate Limiting: Automatic protection against 429 errors with configurable limits
- Intelligent Retries: Exponential backoff with jitter for failed requests
- Webhook Processing: Standard Webhooks compliant verification and parsing
- Comprehensive Tracking: Opens, clicks, bounces, deliveries, and more
- Automatic Idempotency: Prevent duplicate API calls (including email sends) automatically
AhaSend Go SDK Example
Our Go SDK contains 11+ production-ready examples covering all major use cases. In the below example I'll walk you true the proces to sent your first email.
Prerequisites
Before running these examples, you need:
- An AhaSend account and API key
- Go 1.18 or later installed
Set your API credentials as environment variables:
export AHASEND_API_KEY="your-api-key-here" export AHASEND_ACCOUNT_ID="your-account-id-here"
Steps to send your first email
Create a new directory and initialize the go project.
$ mkdir ahasend-example $ cd ahasend-example $ go mod init ahasend-example- Add the ahasend-go SDK to your project
Download send_email.go
$ curl -o send_email.go https://raw.githubusercontent.com/AhaSend/ahasend-go/refs/heads/main/examples/send_email.go- Remove the first line (
//go:build ignore) fromsend_email.go. Run the following command to download the dependencies
$ go mod tidyChange the message (lines 44-78), specifically the sender and recipient these lines to your liking (and make sure to have validated the domain!)
message := requests.CreateMessageRequest{ From: common.SenderAddress{ Email: "[email protected]", Name: ahasend.String("Your Name"), }, Recipients: []common.Recipient{ { Email: "[email protected]", Name: ahasend.String("Recipient Name"), }, },To send the email execute
$ go run examples/send_email.go
For more production ready-examples head over to the Examples directory within the AhaSend Go SDK Repository on Github.