Skip to main content
Use the official Go SDK to call the MailGlyph API from server-side apps.

Prerequisites

Before you start, make sure you have:
  • A MailGlyph secret API key (sk_...) for server-side API requests
  • A MailGlyph public API key (pk_...) for event tracking (/v1/track)
  • At least one verified sending domain for email sending
Setup links:

Install

Initialize clients (mailglyph.New)

Create one SDK client for your secret key and one for your public key:
Set environment variables:

Initialize with alias (mailglyph.NewClient)

NewClient is an alias for New.

Configure base URL and timeout (mailglyph.WithBaseURL, mailglyph.WithTimeout)

Use this when testing against staging or local environments:

Use a custom HTTP client (mailglyph.WithHTTPClient)

Key usage rules

The Go SDK enforces key restrictions automatically:
  • pk_* keys can only call Events.Track
  • sk_* keys can call non-track endpoints, including Events.GetNames and Events.ListNames
Unlike the Node.js SDK, the Go SDK does not expose a keyType property on the client.

Next pages