Skip to content

Transactional SMS

The Transactional SMS object represents a transactional SMS template in your Go-Mailer account. The API lets you send SMS messages to your users from your application.

  • POST /sms
  • Delivery webhook

Send an SMS

Sends the specified transactional SMS to the specified recipient. The recipient doesn't have to be a contact in your account.

POSThttps://api.go-mailer.com/v1/sms

Request body

Send SMS request body
ParameterTypeRequiredDescription
codestringRequired

The SMS template's unique code.

tostringRequired

The recipient's phone number, in the format 234xxxxxxxxx.

tracking_idstringOptional

A unique tracking ID for the message. It's returned to you in delivery notifications.

contextobjectOptional

key => value pairs that replace the placeholders in your transactional SMS.

Each key is the placeholder's name. If your template uses @firstname, send { firstname: "Sample Name" }.

Sample request

POST /v1/sms
const response = await fetch("https://api.go-mailer.com/v1/sms", {
  method: "POST",
  headers: {
    Authorization: "Bearer <API_KEY>"
  },
  body: JSON.stringify({
    code: "BIRTHDAY_SMS",
    to: "234xxxxxxxxx",
    tracking_id: "unique-tracking-id",
    context: {
      firstname: "John",
      age: 47,
    }
  })
});

Delivery webhook

If you've configured a webhook URL in your Go-Mailer account, SMS delivery notifications are sent to that URL.

Payload

SMS delivery webhook payload
FieldTypeDescription
message_idstring

The unique ID of the SMS message.

messagestatestring

The state of the message, e.g. sent, delivered or failed.

tracking_idstring

The tracking ID you supplied when you sent the message.

Sample payload

Webhook payload
{
  "message_id": "unique-message-id",
  "messagestate": "failed",
  "tracking_id": "unique-tracking-id"
}