Back to blog
Email APIDeveloper GuideEmailTutorial

What Is an Email API? A Developer's Guide

What an email API is, how it works, REST vs SMTP, common use cases, and how to pick one. With code examples in TypeScript, Python, and Go.

SendPigeon TeamMarch 11, 20266 min read

An email API lets you send email with an HTTP request. No SMTP connections, no mail server configuration. You call an endpoint, pass a message, and the API handles delivery.

If you've ever set up Nodemailer with SMTP credentials and wondered why it needs to be this complicated — an email API is the simpler version of that.

TL;DR

Email API = HTTP endpoint for sending email. You send a POST request with from, to, subject, and html. The API handles SMTP, authentication, deliverability, and tracking.

curl -X POST https://api.sendpigeon.dev/emails \
  -H "Authorization: Bearer sp_live_xxx" \
  -d '{"from": "you@app.com", "to": ["user@example.com"], "subject": "Hello", "html": "<p>Hi</p>"}'

How an email API works

Without an API, sending email from your app requires:

  1. Configure an SMTP server (or use a provider like Gmail)
  2. Manage SMTP credentials
  3. Open a TCP connection to the server
  4. Authenticate via SMTP handshake
  5. Send the message using SMTP commands
  6. Handle connection errors, timeouts, and retries
  7. Set up DKIM, SPF, and DMARC yourself

With an email API, step 1–7 becomes:

  1. Make an HTTP POST request

The API provider runs the mail servers, manages DNS authentication, processes bounces, and tracks delivery. You get a single integration point.

Your App → HTTP POST → Email API → SMTP → Recipient's inbox

Code examples

TypeScript (Node.js)

import { SendPigeon } from "sendpigeon";

const pigeon = new SendPigeon(process.env.SENDPIGEON_API_KEY!);

const { data, error } = await pigeon.send({
  from: "hello@yourdomain.com",
  to: ["user@example.com"],
  subject: "Your order shipped",
  html: "<h1>Your order is on the way</h1>",
});

if (error) {
  console.error("Send failed:", error.message);
} else {
  console.log("Sent:", data.id);
}

Python

from sendpigeon import SendPigeon

pigeon = SendPigeon(api_key="sp_live_xxx")

result = pigeon.send(
    from_="hello@yourdomain.com",
    to=["user@example.com"],
    subject="Your order shipped",
    html="<h1>Your order is on the way</h1>",
)

Go

client := sendpigeon.New("sp_live_xxx")

resp, err := client.Send(ctx, &sendpigeon.SendEmailRequest{
    From:    "hello@yourdomain.com",
    To:      []string{"user@example.com"},
    Subject: "Your order shipped",
    HTML:    "<h1>Your order is on the way</h1>",
})

Raw HTTP (any language)

curl -X POST https://api.sendpigeon.dev/emails \
  -H "Authorization: Bearer sp_live_xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "from": "hello@yourdomain.com",
    "to": ["user@example.com"],
    "subject": "Your order shipped",
    "html": "<h1>Your order is on the way</h1>"
  }'

Every language with HTTP support can use an email API. SDKs just make it cleaner.


Email API vs SMTP

Email APISMTP (e.g. Nodemailer)
ProtocolHTTP/RESTSMTP (TCP)
SetupAPI keySMTP host, port, user, pass
ConnectionStateless (one request)Stateful (open connection)
ServerlessWorks everywhereBlocked by some providers
Delivery trackingBuilt-inBuild it yourself
Bounce handlingAutomaticManual
AnalyticsOpens, clicks, deliveryNone
AuthenticationManaged (DKIM, SPF)Configure yourself

When SMTP still makes sense

  • You're sending between internal servers
  • You need raw protocol control (custom SMTP extensions)
  • You're building email infrastructure, not consuming it
  • Your email volume is massive and you want AWS SES at $0.10/1K

For most application email — password resets, notifications, receipts, welcome emails — an API is simpler and more reliable.


What an email API handles for you

DNS authentication (DKIM, SPF, DMARC)

Email authentication prevents spoofing and improves deliverability. With SMTP, you generate DKIM keys, rotate them periodically, and manage DNS records yourself.

With an email API, you add a few DNS records during setup and the provider handles the rest — key rotation, alignment, and monitoring.

Bounce processing

When an email bounces (invalid address, full mailbox), the bounce notification goes to your sending server. With raw SMTP, you parse these notifications and maintain a suppression list yourself.

Email APIs process bounces automatically. Hard bounces are suppressed so you never send to them again.

Delivery webhooks

Know what happened to every email you send:

{
  "event": "delivered",
  "email_id": "em_abc123",
  "to": "user@example.com",
  "timestamp": "2026-03-11T14:30:00Z"
}

Events include: sent, delivered, opened, clicked, bounced, complained. Wire these into your app to trigger follow-up actions or alert on problems.

Rate limiting and queuing

Email providers have sending limits. An API manages queuing and rate limiting server-side, so you don't need to build that into your application.


Common use cases

Use caseExample
TransactionalPassword resets, order confirmations, receipts
NotificationsNew message alerts, status updates, reminders
Welcome emailsOnboarding sequences after signup
MarketingNewsletters, product announcements, campaigns
TriggeredDatabase change triggers email via webhook
ScheduledWeekly digests, daily reports

How to pick an email API

The right API depends on your priorities:

Simplest setup — Look for built-in sandbox/testing, CLI tools, and clear docs. SendPigeon includes a local dev server and cloud sandbox.

Cheapest at scaleAmazon SES at $0.10/1K emails is hard to beat, but you manage everything yourself.

Fastest deliveryPostmark is known for fast transactional delivery (avg ~1.2s to inbox).

Multi-language SDKs — Most providers offer TypeScript, Python, Go, PHP, and Ruby SDKs. Check that your stack is supported.

Marketing + transactional — If you need both, look for providers that support campaigns alongside API sending.

For a full comparison, see Best Email API for Developers in 2026.


Getting started

Most email APIs follow the same setup pattern:

  1. Create an account and get an API key
  2. Add your domain — the provider gives you DNS records (SPF, DKIM, DMARC)
  3. Verify DNS — add the records to your domain's DNS settings
  4. Send your first email — via SDK or raw HTTP

With SendPigeon, the full setup takes about 5 minutes:

npm install sendpigeon
import { SendPigeon } from "sendpigeon";

const pigeon = new SendPigeon("sp_live_xxx");

await pigeon.send({
  from: "hello@yourdomain.com",
  to: ["user@example.com"],
  subject: "Welcome!",
  html: "<h1>You're in.</h1>",
});

Start free — 3,000 emails/month, no credit card.


Next Steps