Autosend
Transports

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/email

Getting your API key

  1. Sign up or log in at autosend.com.
  2. Navigate to API Keys in your dashboard.
  3. Click Create API Key and copy the generated key — it starts with as_.

Store it as an environment variable:

AUTOSEND_API_KEY=as_xxxxxxxxxxxxxxxxxxxxxxxxx

Usage

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 statusBetter-Notify codeRetriable
400VALIDATIONNo
422VALIDATIONNo
401CONFIGNo
403CONFIGNo
429RATE_LIMITEDYes
5xxPROVIDERYes

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.

On this page