Skip to main content
Use the official Python 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

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

Configure base URL, timeout, and retries

Use this when testing against staging or local environments:

Key usage rules

The Python SDK enforces key restrictions automatically:
  • pk_* keys can only call events.track
  • sk_* keys can call all non-track endpoints, including events.get_names

Close clients

Use context managers or call close() / await close() explicitly:

Next pages