Autosend
Send emails via the Autosend HTTP API
The Autosend transport is an official Better-Notify package that sends email through the Autosend HTTP API. It uses plain fetch() with zero external dependencies, so it works in Node.js, Bun, Cloudflare Workers, and any runtime with a global fetch.
Install
npm install @betternotify/autosend @betternotify/core @betternotify/emailGetting your API key
- Sign up or log in at autosend.com.
- Navigate to API Keys in your dashboard.
- Click Create API Key and copy the generated key — it starts with
as_.
Store it as an environment variable:
AUTOSEND_API_KEY=as_xxxxxxxxxxxxxxxxxxxxxxxxxUsage
import { createNotify, createClient } from '@betternotify/core';
import { emailChannel } from '@betternotify/email';
import { autosendTransport } from '@betternotify/autosend';
const email = emailChannel({
defaults: { from: { name: 'My App', email: 'noreply@example.com' } },
});
const rpc = createNotify({ channels: { email } });
const catalog = rpc.catalog({
/* routes */
});
const mail = createClient({
catalog,
transportsByChannel: {
email: autosendTransport({
apiKey: process.env.AUTOSEND_API_KEY!,
}),
},
});Options
Prop
Type
Error handling
The transport maps HTTP status codes to Better-Notify error codes using the shared mapHttpStatus utility:
| HTTP status | Better-Notify code | Retriable |
|---|---|---|
| 400 | VALIDATION | No |
| 422 | VALIDATION | No |
| 401 | CONFIG | No |
| 403 | CONFIG | No |
| 429 | RATE_LIMITED | Yes |
| 5xx | PROVIDER | Yes |
Network failures and unparseable responses are wrapped as PROVIDER errors. Timeouts are wrapped as TIMEOUT errors.
Multiple recipients
Autosend's API accepts a single recipient per request. When you send to multiple recipients, the transport fires one request per recipient in parallel and aggregates the results — accepted recipients are reported in accepted, failed ones in rejected. If all recipients fail, the transport returns the first error.