AhaSend
Back to Blog

Introducing: The AhaSend Go SDK

Fred Moody
Fred Moody
Product Update

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!

Image
We love Go!

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:

  1. An AhaSend account and API key
  2. Go 1.18 or later installed
  3. 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

  1. Create a new directory and initialize the go project.

    $ mkdir ahasend-example
    $ cd ahasend-example
    $ go mod init ahasend-example
  2. Add the ahasend-go SDK to your project
  3. Download send_email.go

    $ curl -o send_email.go https://raw.githubusercontent.com/AhaSend/ahasend-go/refs/heads/main/examples/send_email.go
  4. Remove the first line (//go:build ignore) from send_email.go.
  5. Run the following command to download the dependencies

    $ go mod tidy
  6. Change 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"),
    			},
    		},
  7. 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.