SDKs

Official SDKs for Node.js, Python, Go and PHP, and a Laravel mail driver. They call the same REST API as every other example in these docs, with types, retries and webhook checks built in. You do not need one: any HTTP client works.

Install

npm install @smtpfast/sdk
LanguagePackageRuns on
Node.js and TypeScript@smtpfast/sdkNode.js 22+, Bun, Deno, edge runtimes. No runtime dependencies.
PythonsmtpfastPython 3.10+. Sync and async clients. Depends only on httpx.
Gogithub.com/smtpfast/smtpfast-goGo 1.24+. Standard library only.
PHPsmtpfast/smtpfast-phpPHP 8.2+ with the curl extension. No other dependencies.
Laravelsmtpfast/smtpfast-laravelLaravel 12 and 13. A mail driver: existing Mailables and Notifications send through the API.

Send an email

Create an API key, set it as SMTPFAST_API_KEY, and send from a verified domain:

import { SMTPfast } from "@smtpfast/sdk";

const smtpfast = new SMTPfast(); // reads SMTPFAST_API_KEY

const email = await smtpfast.emails.send({
  from: "Acme <[email protected]>",
  to: ["[email protected]"],
  subject: "Your receipt",
  html: "<p>Thanks for your order.</p>",
  category: "transactional",
});
console.log(email.id);

Email is marketing unless you set category to transactional. Marketing email gets a one-click unsubscribe header and is not sent to people who unsubscribed, so set transactional on receipts, password resets and account alerts.

What every SDK does

Every endpointEach SDK is generated from the OpenAPI document, so every API operation is a method, named after its path: emails.send, domains.verify, contacts.segments.add.
RetriesAfter a 429 (honouring Retry-After), a 408, a 5xx or a dropped connection. Reads, PUT and DELETE are retried after a 5xx; other POST and PATCH calls only after a per-second rate limit, which the API rejects before doing any work.
IdempotencyA send, reply or forward is retried with the same Idempotency-Key, so the API returns the first answer instead of sending twice. The SDK makes a key per call when you do not give one.
Typed errorsOne error type per status class (not found, rate limited, and so on), plus connection and timeout errors.
PaginationHelpers that walk every page of a list for you.
WebhooksSignature checks for incoming webhook requests, with the same rules as the webhook docs.

Each README has the full options, error classes and pagination examples for its language.

Other languages

  • Call the REST API from any HTTP client. The Quick Start has a curl example, and the OpenAPI document works with any code generator.
  • Already on a Resend SDK? Point it at SMTPfast. See Resend Compatibility.
  • Need SMTP? The SMTP bridge sends through the same account. See the SMTP Bridge section of Emails.