Email infrastructure guide
How to Send Email with an API
A step-by-step approach to authenticated API email sending, testing, and production safety.
A production email request needs more than a recipient and subject. It needs a verified sender, a purpose-appropriate template, authentication, error handling, and a way to observe the outcome.
What this means in practice
- A verified From domain
- An API key limited to the right workspace
- Structured HTML and text content
- A retry strategy that avoids duplicate delivery
Implementation checklist
- Create a verified domain and choose a sender address.
- Store the API key in server-side environment variables.
- Send a test message to a controlled inbox.
- Log the provider response ID and handle non-success responses.
- Add an idempotency key or event ID for retried jobs.
Questions teams ask
Should an API key be used in browser code?
No. Keep sending credentials on a server, worker, or trusted backend.
How do I avoid duplicate email sends?
Use a stable event identifier or idempotency key and persist the provider message ID before retrying failed jobs.