Runs examples for real against your account. Test keys only; kept in this tab, never stored on our side. Get a key
ZapSMTP / Docs / Get started

SDKs and OpenAPI

Official libraries for seven languages, Laravel and Rails. Every one covers the whole API and behaves the same way: it retries safely, walks every page of a list, raises typed errors and verifies webhook signatures.

Libraries

Node.js

npm install zapsmtp

TypeScript types for every request and response; ESM and CommonJS; no dependencies.

Node.js 18+, Bun, Deno

GitHubnpm

Python

pip install zapsmtp

Sync and async clients, typed models, httpx underneath.

Python 3.9+

GitHubPyPI

PHP

composer require zapsmtp/zapsmtp-php

PSR-18 HTTP client, Guzzle by default; typed models with array access.

PHP 8.1+

GitHubPackagist

Laravel

composer require zapsmtp/zapsmtp-laravel

A mail transport for your Mailables, a facade for the API and verified webhook events.

Laravel 10, 11, 12

GitHubPackagist

Go

go get github.com/zapsmtp/zapsmtp-go

Standard library only; context on every call; range over every page.

Go 1.23+

GitHubpkg.go.dev

Ruby

gem install zapsmtp

Standard library only; an ActionMailer delivery method for Rails.

Ruby 3.0+

GitHubRubyGems

Java

implementation("com.zapsmtp:zapsmtp-java:0.1.0")

Builders for every request, immutable models, java.net.http underneath.

Java 11+

GitHubMaven Central

.NET

dotnet add package ZapSMTP

Async API with cancellation, dependency injection, IAsyncEnumerable paging.

.NET 8, .NET Standard 2.0

GitHubNuGet

Send your first email

Create a test key in the dashboard (zap_test_…) and put it in ZAP_API_KEY. Test keys deliver nothing, and the simulator address acts out a delivery.

Send an email
import { ZapSMTP } from 'zapsmtp';

const zap = new ZapSMTP(); // reads ZAP_API_KEY

const { id } = await zap.emails.send({
  from: 'Acme <hello@acme.com>',
  to: 'delivered@simulator.zapsmtp.xyz',
  subject: 'Hello from ZapSMTP',
  html: '<p>It works.</p>',
});
console.log(id);

What every SDK does

  • The whole API. Every endpoint in the reference, with types for its parameters and response. The libraries are generated from the same description as these pages, so a new endpoint reaches every language at once.
  • Safe retries. Rate limits (429), server errors and lost connections are retried twice by default, waiting as Retry-After says or backing off exponentially. Sends always carry an Idempotency-Key, so a retried send never goes out twice; pass your own key to tie a send to your order or event.
  • Every page. List methods return one page; each SDK can also iterate every item of every page.
  • Typed errors. Authentication, permission, not found, conflict, validation, rate limit, server and connection errors are separate classes carrying the status, the error code and the request id. See Errors, limits & paging.
  • Webhook verification. One call checks the Zap-Signature header in constant time, rejects signatures older than five minutes and accepts both secrets during a rotation.
  • Configuration. The key comes from ZAP_API_KEY and the base URL from ZAP_BASE_URL when not passed in code. Timeouts, retries and extra headers can be set per client or per request.

Verify a webhook

Pass the body exactly as it arrived, before parsing it. The call returns the event or throws. The payloads are described in Webhook events.

Verify the signature
import { verifyWebhook } from 'zapsmtp';

// the raw body, before any JSON parsing
const event = verifyWebhook(rawBody, req.headers, process.env.ZAP_WEBHOOK_SECRET);

Laravel and Rails

Laravel. Set MAIL_MAILER=zapsmtp and your Mailables go through the API: attachments, inline images, tags and metadata included. The package also gives a ZapSMTP facade for the whole API and a webhook route that checks signatures and fires Laravel events.

Rails. Set config.action_mailer.delivery_method = :zapsmtp and Action Mailer sends through the API. Pass tags, metadata or a template with mail(zapsmtp: { tags: [...] }). The gem includes a Rack middleware that verifies webhooks.

OpenAPI

The whole API as an OpenAPI 3.1 description: every operation with its parameters, request and response schemas and documented errors. Import it into Postman or Insomnia, or generate a client for a language without an SDK (Rust, Elixir, Dart, Swift) with OpenAPI Generator. Each operation's x-sdk-method names the SDK method that calls it.

Its repository: github.com/ZapSMTP/zapsmtp-openapi.

Other clients

Any SMTP library works too: SMTP relay. Moving from another provider: Migrating to ZapSMTP.