Skip to main content

Getting Started with Hypersender SDK

This guide will walk you through the process of installing and configuring the Hypersender Go SDK for your Golang application, whether it is a net/http service, a Gin or Echo app, or a simple command-line tool.

Prerequisites

Before you begin, ensure you have the following:
  • Go 1.24 or higher: The SDK uses only the Go standard library, with no third-party dependencies.
  • Go modules: For package management and dependency resolution
  • Hypersender account: Sign up at Hypersender to obtain your API key and Instance ID.
You can find your API key and Instance ID in the Hypersender dashboard
Hypersender Dashboard API Key

Installation

1

Install the SDK with go get

Run the following command in your module’s directory to install the Hypersender Go SDK:
After installation, you can verify the package is in your module with go list -m github.com/hypersender/hypersender-go.
2

Configure Environment Variables

The SDK reads its credentials from environment variables, using the same names as the Laravel package. Set the variables for the APIs you use: WhatsApp, SMS, OTP, or any mix of them.For WhatsApp API, set the following environment variables in your .env file:
Learn how to get the Hypersender whatsapp API token and Instance ID from Dashboard: Demo Link.
For SMS API, set the following environment variables in your .env file:
Learn how to get the Hypersender SMS API token and Instance ID from the dashboard: Demo Link.
For OTP API, set the following environment variables in your .env file:
For Enterprise instance management (Enterprise accounts only), set:
Go does not read .env files on its own. Export the variables in your shell or hosting platform, or install a package such as godotenv (go get github.com/joho/godotenv) and load the file before you create the client.
3

Send your first message

Import github.com/hypersender/hypersender-go, create a client, and call the API you need. The client picks up the environment variables when you create it.

Reading responses and errors

Every method takes a context.Context first, then its required arguments, then an optional options struct (pass nil when you don’t need it). It returns the API’s JSON as a hypersender.Result, which is a map[string]any, so the fields keep the API’s names. Nested objects are map[string]any too, and lists are []any, so read them with type assertions:
When the API answers with a 4XX or 5XX status, the method returns a *hypersender.Error with the StatusCode, Message, and raw Body of the response. Check for it with errors.As:
If a credential is missing, the method returns a plain error that names the environment variable to set.

Configure in code instead of environment variables

If you can’t use environment variables, pass the credentials when you create the client:
Options override environment variables. Use hypersender.WithEnterprise(apiKey) for the Enterprise API key and hypersender.WithHTTPClient(httpClient) to use your own *http.Client (the default has a 30 second timeout). The client is safe for concurrent use, so create it once and share it. To work with more than one account at the same time, create a hypersender.NewClient(...) client for each one. Each client has the same WhatsApp, SMS, OTP, and Enterprise fields.

You’re all set!

You have successfully installed and configured the Hypersender Go SDK in your application. You can now start using the SDK to send messages and manage your communications.
Last modified on November 24, 2026