smsgora

package module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

SMS Gora Go client

Go Reference

Go client for the SMS Gora SMS Gateway API.

SMS Gora turns Android phones with ordinary SIM cards into an SMS gateway. Your server calls the API, a linked phone sends the text, and replies and delivery reports come back to you. There's no sender ID registration and no per-message fee from us: your mobile operator bills the texts like any SMS.

  • Standard library only, Go 1.21+
  • context.Context on every call, typed errors
  • Webhook signature check built in

Install

go get github.com/tekservixhq/smsgora-go

Quick start

Create an API key in the SMS Gora dashboard (SMS Gora -> API keys) and keep it on your server.

package main

import (
	"context"
	"fmt"
	"log"
	"os"

	smsgora "github.com/tekservixhq/smsgora-go"
)

func main() {
	sms := smsgora.New(os.Getenv("SMSGORA_KEY"))

	res, err := sms.SendSMS(context.Background(), smsgora.SendParams{
		To:      []string{"+15551234567"},
		Message: "Your verification code is 482913",
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(res.MessageIDs) // [1873]
}

Sending

ctx := context.Background()

// Several recipients (up to 1,000 per call)
sms.SendSMS(ctx, smsgora.SendParams{To: []string{"+15551234567", "+447700900123"}, Message: "Your order has shipped"})

// From a chosen phone and SIM, scheduled for later
slot := 1 // 0 = SIM 1, 1 = SIM 2
at := time.Date(2026, 12, 1, 8, 0, 0, 0, time.UTC)
sms.SendSMS(ctx, smsgora.SendParams{
	To: []string{"+15551234567"}, Message: "Reminder: your appointment is tomorrow at 10:00",
	DeviceID: 42, SimSlot: &slot, ScheduleAt: &at,
})

// Different texts for different people in one call (up to 5,000 recipients)
sms.SendBulkSMS(ctx, 42, "Hello, your parcel is ready for pickup.", []smsgora.BulkMessage{
	{Recipients: []string{"+15551234567"}, Message: "Hi Aline, parcel #1042 is ready."},
	{Recipients: []string{"+15557654321"}},
})

Delivery status and incoming SMS

msg, _ := sms.GetMessage(ctx, 1873)
fmt.Println(msg["status"]) // queued -> dispatched -> sent -> delivered (or failed)

sms.CancelMessage(ctx, 1874) // works while queued or scheduled

inbox, _ := sms.ListReceivedSMS(ctx, 0, url.Values{"since": {"2026-11-01"}, "limit": {"50"}})
phones, _ := sms.ListDevices(ctx)
account, _ := sms.GetAccount(ctx)

Anything else in the API reference is one call away:

var batch map[string]any
err := sms.Request(ctx, "GET", "/batches/311", nil, &batch)

Webhooks

Add your HTTPS URL in SMS Gora -> Webhooks (or with CreateWebhook) and keep the secret. Each request carries X-SmsGora-Signature: sha256=..., an HMAC-SHA256 of the raw body:

http.HandleFunc("/sms/webhook", func(w http.ResponseWriter, r *http.Request) {
	raw, _ := io.ReadAll(r.Body)
	if !smsgora.VerifyWebhook(raw, r.Header.Get("X-SmsGora-Signature"), os.Getenv("SMSGORA_WEBHOOK_SECRET")) {
		http.Error(w, "bad signature", http.StatusUnauthorized)
		return
	}
	w.WriteHeader(http.StatusOK) // answer within 10 seconds; queue slow work

	var event struct {
		Event string `json:"event"`
		Data  struct {
			From    string `json:"from"`
			Message string `json:"message"`
		} `json:"data"`
	}
	json.Unmarshal(raw, &event)
	if event.Event == "sms.received" {
		log.Println(event.Data.From, event.Data.Message)
	}
})

Errors

API errors are *smsgora.Error with Status, Message, field Errors and, on 429, RetryAfter.

var apiErr *smsgora.Error
if errors.As(err, &apiErr) && apiErr.Status == 429 {
	time.Sleep(apiErr.RetryAfter) // rate limit (300 requests/minute per key) or plan limit reached
}

Never ship the key inside a mobile or desktop app: anyone could read it. Call the API from your server.

Migrating from TextBee

SMS Gora accepts TextBee-style requests, so most integrations switch by changing the base URL and key. See the compatibility notes.

More from Tekservix

  • WAservix WhatsApp API Gateway: send WhatsApp messages from your own number (go get github.com/tekservixhq/waservix-go)
  • AI Sales Agent: answers customers on WhatsApp and SMS using your website's content
  • Website to App: turn your website into Android and iOS apps
  • SMS Gora is also available for Node.js (npm install smsgora), Python (pip install smsgora) and PHP (composer require tekservix/smsgora)

License

MIT

Documentation

Overview

Package smsgora is a Go client for the SMS Gora SMS Gateway API.

SMS Gora turns Android phones with ordinary SIM cards into an SMS gateway: your server calls the API, a linked phone sends the text, and replies and delivery reports come back to you.

Docs: https://tekservix.com/smsgora/docs/

Index

Constants

View Source
const DefaultBaseURL = "https://tekservix.com/smsgora/api/v1"

DefaultBaseURL is the SMS Gora API endpoint.

View Source
const Version = "1.0.1"

Version of this client.

Variables

This section is empty.

Functions

func VerifyWebhook

func VerifyWebhook(rawBody []byte, signature, secret string) bool

VerifyWebhook checks the X-SmsGora-Signature header (sha256=<hex HMAC-SHA256 of the raw body>). Pass the raw request body, before JSON decoding.

Types

type BulkMessage

type BulkMessage struct {
	Recipients []string `json:"recipients"`
	Message    string   `json:"message,omitempty"`
}

BulkMessage is one entry of SendBulkSMS.

type Client

type Client struct {
	APIKey     string
	BaseURL    string
	HTTPClient *http.Client
}

Client talks to the SMS Gora API. Create one with New and reuse it.

func New

func New(apiKey string) *Client

New returns a client for the given API key (create one in SMS Gora -> API keys).

func (*Client) CancelMessage

func (c *Client) CancelMessage(ctx context.Context, id int64) error

CancelMessage cancels a queued or scheduled message.

func (*Client) CreateWebhook

func (c *Client) CreateWebhook(ctx context.Context, webhookURL string, events []string, deviceID int64) (map[string]interface{}, error)

CreateWebhook registers a webhook. The answer includes the secret (only returned once). events defaults to ["sms.received"]; deviceID 0 means all phones.

func (*Client) DeleteWebhook

func (c *Client) DeleteWebhook(ctx context.Context, id int64) error

DeleteWebhook removes a webhook.

func (*Client) GetAccount

func (c *Client) GetAccount(ctx context.Context) (map[string]interface{}, error)

GetAccount returns your account, plan and usage.

func (*Client) GetBatch

func (c *Client) GetBatch(ctx context.Context, id int64) (map[string]interface{}, error)

GetBatch returns a batch created by sending to several recipients.

func (*Client) GetDevice

func (c *Client) GetDevice(ctx context.Context, id int64) (map[string]interface{}, error)

GetDevice returns one phone.

func (*Client) GetMessage

func (c *Client) GetMessage(ctx context.Context, id int64) (map[string]interface{}, error)

GetMessage returns one message. Status is queued, dispatched, sent, delivered, failed or cancelled.

func (*Client) ListDevices

func (c *Client) ListDevices(ctx context.Context) ([]map[string]interface{}, error)

ListDevices lists your linked Android phones.

func (*Client) ListMessages

func (c *Client) ListMessages(ctx context.Context, filters url.Values) (interface{}, error)

ListMessages lists messages. Filters: direction (in/out), status, device_id, phone, since, after_id, page, limit.

func (*Client) ListReceivedSMS

func (c *Client) ListReceivedSMS(ctx context.Context, deviceID int64, filters url.Values) (interface{}, error)

ListReceivedSMS lists incoming SMS for all phones (deviceID 0) or one phone.

func (*Client) ListWebhooks

func (c *Client) ListWebhooks(ctx context.Context) ([]map[string]interface{}, error)

ListWebhooks lists webhooks registered by API.

func (*Client) Request

func (c *Client) Request(ctx context.Context, method, path string, body, out interface{}) error

Request calls any documented endpoint and decodes the `data` field into out (which may be nil).

func (*Client) SendBulkSMS

func (c *Client) SendBulkSMS(ctx context.Context, deviceID int64, messageTemplate string, messages []BulkMessage) (map[string]interface{}, error)

SendBulkSMS sends different texts to different people in one call (up to 5,000 recipients). Entries without their own Message use messageTemplate.

func (*Client) SendSMS

func (c *Client) SendSMS(ctx context.Context, p SendParams) (*SendResult, error)

SendSMS sends an SMS. It picks your best online phone unless DeviceID is set.

type Error

type Error struct {
	Status     int                 // HTTP status code
	Message    string              // message from the API
	Errors     map[string][]string // field errors, if any
	Body       []byte              // raw answer
	RetryAfter time.Duration       // set on HTTP 429
}

Error is returned when the API answers with an error.

func (*Error) Error

func (e *Error) Error() string

type SendParams

type SendParams struct {
	To         []string   // up to 1,000 numbers in international format
	Message    string     // up to 1,600 characters
	DeviceID   int64      // optional: send from this phone
	SimSlot    *int       // optional: 0 = SIM 1, 1 = SIM 2
	ScheduleAt *time.Time // optional: send later
}

SendParams describes an SMS to send.

type SendResult

type SendResult struct {
	MessageIDs []int64 `json:"message_ids"`
	BatchID    *int64  `json:"batch_id,omitempty"`
	Status     string  `json:"status,omitempty"`
}

SendResult is returned by SendSMS.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL