Learn how to send text messages (SMS) with Golang. This guide covers 3 different ways with a step-by-step tutorial & pros + cons for each.
Updated Jun 30, 2026
Digital communication has become one of the critical factors in almost all the areas, such as banking, health, government, education, and social media, for many purposes such as user authorization, appointment booking, and many more. Among different approaches to communication, SMS is one of the well-known methods.
Developers use many APIs and related approaches to implement SMS functionality in those areas. In the modern world, many developers use Golang during their development process. As a result, SMS implementation using Golang is getting popular.
This post discusses three ways to send an SMS using Golang.
Twilio APIs provide seamless communication with users via voice, SMS, video, or chat. Developers can send SMS easily using the Twilio Go Helper Library.
Twilio SMS pricings and services depend on the country you live in. For example, in the UK, only sending and receiving picture messages are free of charge, and alphanumeric sender id services have a different approach.

For outbound services for UK users, the pricing depends on the country.
As prerequisites, you must have a Twilio account and a Twilio mobile number. Twilio offers a $15 credit for new users when upgrading to a paid version. When using Twilio, it is essential to know its features and limitations.
01 - First, you must create a trial account by navigating to the Twilio signup page. After filling in all the essential details, you will be prompted to the welcome page. You will have the option to select how you need to use Twilio. For example, you can use Twilio with no code at all.
However, here you need to select either with code or with minimal code and select the language as Golang.
02 - After starting the trial, you will be prompted to the dashboard, where you will have free credits of $15.

Now, you can create your own main.go file and start the most exciting part.
package mainimport ("fmt""strings""math/rand""time""net/http""net/url""encoding/json")func main() {// Set account keys & informationaccountSid := "ACXXXXXXXXX"authToken := "XXXXXXXXXX"urlStrting := "https://api.twilio.com/2010-04-01/Accounts/" + accountSid + "/Messages.json"message := [1]string{"Hello SMS"}rand.Seed(time.Now().Unix())//Set up the data for the text messagemessageDate := url.Values{}messageDate.Set("To","numberTo")messageDate.Set("From","numberFrom")messageDate.Set("Body",quotes[rand.Intn(len(quotes))])msgDataReader := *strings.NewReader(messageDate.Encode())//Create HTTP request clientclient := &http.Client{}request, _ := http.NewRequest("POST", urlStrting, &msgDataReader)request.SetBasicAuth(accountSid, authToken)request.Header.Add("Accept", "application/json")request.Header.Add("Content-Type", "application/x-www-form-urlencoded")//Make HTTP POST requestclient.Do(req)}
03 - Then, you must import all the packages in the import block, and in the main package, initialize accountSid and AuthToken. You can find your accountSid and AuthToken in the account info section. urlString is the Twilio API that we use for SMS messages. The message is defined as the possible message bodies.
04 - Then, set up the messageDate by initializing the sender, the receiver number, and the message body.
05 - Next, create the HTTP request client by initializing the request and wrapping credentials using the SetBasicAuth() function.
06 - Then, make the POST request using HTTP client.do.
07 - Finally, run the following command to send the SMS.
go run main.go
Furthermore, the Twilio dashboard can send SMS using programming languages like Java, C#, Ruby, Python, Php, and NodeJS.
TextMagic API is a much simpler way of sending SMS using Golang. It provides a communication link between the application layer and TextMagic's API gateway. Furthermore, it allows you full access even during the trial period.
The pricing for TextMagic works is similar to Twilio APIs. For the UK, the price for an SMS, MMS, and carrier lookup is $0.05.

As a prerequisite, what TextMagic API need is to have the Go distribution on your computer.
01 - First, you must create an account in TextMagic. Here, I will sign up with Google.
02 - Next, go to the API Settings page and create the API keys. Here click on the Add new API key button, enter a name, and click on the Generate new key button.
03 - You must install the TextMagic in Golang helper by running the following command.
go get github.com/textmagic/textmagic-rest-go
04 - You can use the following code example to send an SMS.
package mainimport ("fmt"textmagic "github.com/textmagic/textmagic-rest-go")func main() {client := textmagic.NewClient("userName", "APIKey")params := map[string]string{"phones": "+44XXXXXXXXX","text" : "Hello SMS",}message, err := client.CreateMessage(params)if err != nil {fmt.Println(err)} else {fmt.Println(message.Id)}}
05 - Finally, run the main.go file to send SMS using the following command.
go run main.go
When considering requirements in the modern world, there are many scenarios where organizations need different approaches for communication, such as Email, Slack, WhatsApp, and even Twilio-like SMS services.
Courier is a multi-channel platform that allows seamless communication with various channels. With Courier, you can handle all such channels using only a single Golang API.
01 - First, you need to sign-up for Courier and create a free account by following the descriptive guide and selecting SMS as the required service.
02 - Then connect with an SMS provider. Here, I will click on Twilio since I have already created an account with Twilo. Other than Twilio, there are many SMS providers which you can select.

03 - Enter your account SID and the token available on Twilio Dashboard.

04 - On the next screen, set the receiver's phone number.

05 - In the next screen, you can select the method or language needed in the service. You can also run the cURL command in the terminal to check your SMS gateway. I will choose Golang and continue to the next step.
06 - You must download the Golang package (SDK) using the following command.
go get -u github.com/trycourier/courier-go/v2
07 - Next, you can create the main.go file and paste the following code snippet generated in the Courier user interface.
package mainimport ("context""log""github.com/trycourier/courier-go/v2")func main() {client := courier.CreateClient("<YOUR_AUTH_TOKEN>", nil)requestID, err := client.SendMessage(context.Background(),courier.SendMessageRequestBody {Message: map[string]interface{}{"to": map[string]string{"phone_number": "447548418181",},"content": map[string]string{"title": "Welcome to Courier!","body": "Want to hear a joke? {{joke}}",},"data": map[string]string{"joke": "What did C++ say to C? You have no class.",},},})if err != nil {log.Fatalln(err)}log.Println(requestID)}
08 - Finally, run the following command and check if you can receive the message.
go run main.go
This article proposed three ways to send SMS notifications via Golang and guided you in selecting the best SMS notification service for your Golang application. Also, we have discussed the pros and cons of using each method. We hope now you can select the most suitable approach for your future projects.
Thank you for reading.
Keep exploring
One API, every channel
Courier gives you one API for email, SMS, push, and chat, with templates, routing, retries, and delivery logs built in.
Last updated Jun 30, 2026. Code samples are illustrative; provider APIs and pricing change over time, so check each provider’s docs before relying on them.
© 2026 Courier. All rights reserved.