Tutorials
Sending emails with Go
A complete Go walkthrough with the official SDK: sending, error handling and retries.
Use the official notideus/sdk-go — Go 1.22 and later:
go get github.com/notideus/sdk-go
The send function
Emails.Send() authenticates with your API key, returns a typed *notideus.NotideusError on failure, and returns the stored email row:
package main
import (
"context"
"fmt"
"os"
notideus "github.com/notideus/sdk-go"
)
func main() {
client := notideus.New(os.Getenv("NT_KEY")) // "nt_live_…"
email, err := client.Emails.Send(context.Background(), notideus.SendEmailParams{
From: "Notideus <noreply@demo.dev>",
To: []string{"jane@example.com"},
Subject: "Welcome to Notideus",
HTML: "<p>Hi Jane,</p><p>Your account is ready.</p>",
IdempotencyKey: notideus.Ptr("docs-quickstart-1"),
})
if err != nil {
panic(err)
}
fmt.Println(email.ID, email.Status)
}
curl -X POST https://api.notideus.io/v1/emails \
-H "Authorization: Bearer $NT_KEY" \
-H "Content-Type: application/json" \
-d '{
"from": "Notideus <noreply@demo.dev>",
"to": ["jane@example.com"],
"subject": "Welcome to Notideus",
"html": "<p>Hi Jane,</p><p>Your account is ready.</p>",
"idempotency_key": "docs-quickstart-1"
}'
Expected output
Send returns the stored email row (201 Created). Response abbreviated to id, status, from, to and subject:
{
"id": "01a0a11c-188e-7c9e-9b69-753fcb4c8d0d",
"status": "queued",
"from_address": "Notideus <noreply@demo.dev>",
"to_emails": ["jane@example.com"],
"subject": "Welcome to Notideus"
}
id uniquely identifies this email; status is queued — it is picked up for delivery from there.
Error handling
The SDK returns a typed *notideus.NotideusError, which carries the API error code (.Code), the HTTP status (.Status), and .RetryAfter (seconds) on 429. Unwrap it with errors.As and branch on ne.Code:
client := notideus.New(os.Getenv("NT_KEY"))
_, err := client.Emails.Send(context.Background(), notideus.SendEmailParams{
From: "Notideus <noreply@demo.dev>",
To: []string{"jane@example.com"},
Subject: "Welcome to Notideus",
HTML: "<p>Hi Jane,</p><p>Your account is ready.</p>",
})
var ne *notideus.NotideusError
if errors.As(err, &ne) {
fmt.Fprintf(os.Stderr, "%s %d %s", ne.Code, ne.Status, ne.Message)
}
| Status | Code | What to do |
|---|---|---|
| 401 | unauthorized | Missing, invalid or revoked key — check NT_KEY. |
| 403 | insufficient_scope | The key lacks emails:send — create a key with the right scope. |
| 402 | quota_exceeded | Monthly allowance reached — back off and retry later. See Quotas and limits. |
| 422 | from_domain_not_verified | The From domain matches no verified team domain — verify it in the dashboard first. |
The SDK retries idempotent sends for you: it re-issues a request on network failure, 5xx or 429 (honoring
Retry-After) only when the send carries an idempotency_key — so a retried send never double-sends. Choosing the key is still yours: derive it from your own data (for example order-12345-welcome). See Idempotency for key choice and scope rules.