Website · API reference · Go docs
Send receipts, codes and notifications from your Go server in a few lines, with 221 Pay (Wave, Orange Money) payment links built in. One dependency, the official Standard Webhooks library, for verifying webhooks.
go get github.com/orvlabs/iris-goCreate a key in the Iris console under API keys. Keep it on your server, never in a browser or mobile app.
package main
import (
"context"
"log"
"os"
iris "github.com/orvlabs/iris-go"
)
func main() {
client := iris.New(os.Getenv("IRIS_API_KEY"))
sent, err := client.SendEmail(context.Background(), iris.SendEmailRequest{
From: "Boutique <commandes@boutique.sn>",
To: []string{"Awa <awa@example.sn>"},
Subject: "Votre commande",
HTML: "<p>Merci {{params.prenom}} !</p>",
Data: map[string]any{"prenom": "Awa"},
IdempotencyKey: "commande-CMD-2041",
})
if err != nil {
log.Fatal(err)
}
log.Println("queued", sent.ID)
}With the same IdempotencyKey (an order number, for example), a retry after a network timeout does not send the email twice.
Tip
Use a test key (iris_test_…) while you build. It is checked exactly like a real one, but nothing is delivered and no units are used.
sent, err := client.SendEmail(ctx, iris.SendEmailRequest{
From: "factures@boutique.sn",
To: []string{"awa@example.sn"},
Subject: "Votre facture",
HTML: "<p>Votre facture est prête.</p>{{bloc_paiement}}",
Payment: &iris.Payment{
AmountXOF: 15000,
Reference: "FAC-2026-0042",
Description: "Facture FAC-2026-0042",
Methods: []string{"wave", "orange_money"},
},
})Amounts are whole CFA francs. The same reference and amount always reuse the same link. Link your 221 Pay merchant account in the console first.
Every error from the API is an *iris.Error with the HTTP status, a stable Code, and Message, Fix and Docs that say what to change.
var apiErr *iris.Error
if errors.As(err, &apiErr) {
switch {
case apiErr.Code == "not_enough_credits":
// top up in the console
case apiErr.Retryable(): // 429, 502, 503
// retry later, with an increasing delay and the same IdempotencyKey
default:
log.Printf("iris refused: %s: %s (%s)", apiErr.Code, apiErr.Message, apiErr.Fix)
}
}ListEmails, ListEvents and ListSuppressions fetch the next page as you range over them.
for email, err := range client.ListEmails(ctx, iris.ListEmailsParams{To: "awa@example.sn"}) {
if err != nil {
return err
}
log.Println(email.ID, email.Status)
}http.HandleFunc("/webhooks/iris", func(w http.ResponseWriter, r *http.Request) {
body, err := io.ReadAll(r.Body)
if err != nil {
http.Error(w, "unreadable body", http.StatusBadRequest)
return
}
ev, err := iris.VerifyWebhook(os.Getenv("IRIS_WEBHOOK_SECRET"), r.Header, body) // whsec_…
if err != nil {
http.Error(w, "bad signature", http.StatusUnauthorized)
return
}
// Deduplicate on ev.ID: a retry carries the same one.
log.Println(ev.Type, ev.Data.Email) // email.delivered, email.bounced, email.opened…
w.WriteHeader(http.StatusNoContent)
})Read the raw body before parsing it: the signature covers the exact bytes.
iris.New(key) |
Client for https://iris.orvlabs.com, 30 s timeout, Iris-Version: 2026-11-23 (iris.APIVersion). Change BaseURL, Version or HTTPClient if you need to. |
SendEmail |
POST /api/emails: send now or at SendAt, templates, attachments, one-click unsubscribe, 221 Pay links, secrets, calendar invitations. |
ListEmails, GetEmail, CancelEmail |
GET /api/emails, GET /api/emails/{id}, POST /api/emails/{id}/cancel (a scheduled email or its BatchID). |
CheckEmailAddresses |
POST /api/emails/check, up to 100 addresses. |
ListEvents, GetStats |
GET /api/events, GET /api/stats. |
ListSuppressions, DeleteSuppression |
GET /api/suppressions, DELETE /api/suppressions/{email}. |
RevokeSecret |
POST /api/secrets/{id}/revoke. |
GetInboundAttachment |
GET /api/inbound/{delivery}/attachments/{index}, an io.ReadCloser. |
CreateVerification, CheckVerification, CancelVerification, ResendVerification |
/v1/verify: one-time codes by email, SMS or WhatsApp. |
*iris.Error |
Status, Code, Message, Fix, Docs, Retryable(). |
iris.VerifyWebhook(secret, headers, body) |
Checks the signature and decodes the email event. |
Every route, field and error code is in the API reference.