Install
go get github.com/n4ouri/envoisms-go, then import "github.com/n4ouri/envoisms-go" and build a client with envoisms.NewClient(os.Getenv("ENVOISMS_API_KEY")). The source lives at github.com/envoisms/envoisms-go; the module path keeps its original name.
- client := envoisms.NewClient(os.Getenv("ENVOISMS_API_KEY"))
- MIT licence
Send an SMS
client.Send(&envoisms.SendMessageRequest{To: "+212612345678", Message: "…", From: "MyBusiness"}) queues the message and returns its ID, its status and its cost in MAD (resp.ID, resp.Status, resp.Cost.MAD).
- From: your validated Sender ID, or empty for your default
- Every Send carries an Idempotency-Key — generated, or set IdempotencyKey — so a retry after a timeout never bills the same message twice
Managed OTP: send, then check
client.SendOTP(&envoisms.SendOtpRequest{To: "+212612345678", Brand: "MyBusiness"}) returns a SessionID; client.CheckOTP(otpResp.SessionID, code) returns Verified. The code is generated, delivered and expired by EnvoiSMS, so your service never stores it.
- Channel: "whatsapp" in SendOTP sends the code over WhatsApp through the shared sender, no connection needed
- Underlying endpoints: POST /v1/verify/send and POST /v1/verify/check
SMS or WhatsApp
Default to SMS (leave Channel empty): it reaches every Moroccan mobile with no setup beyond your API key. Channel: "whatsapp" sends from your own connected WhatsApp Business number: without one the API answers 403 WHATSAPP_NOT_CONNECTED, and free-form text outside the 24-hour customer window answers 400 OUT_OF_24H_WINDOW — send an approved Template instead. Nothing is charged in either case.