Skip to content

API and SDK

Send from any language over HTTP.

A REST API for every language, a typed TypeScript SDK, and React, Next.js and Fastify packages on top. Retries are safe because sends carry idempotency keys.

One call to send

Create a client with your API key and the API base URL, then call emails.send. Keys come from your project in the dashboard or from devel key create.

import { DevelEmail } from '@develemail/sdk';

export async function sendWelcome() {
  const client = new DevelEmail({
    apiKey: process.env.DEVELEMAIL_API_KEY!,
    baseUrl: 'https://develemail.com/api',
  });

  const { id, status } = await client.emails.send({
    from: '[email protected]',
    to: '[email protected]',
    subject: 'Welcome aboard',
    text: 'Your account is ready.',
  });
  return { id, status };
}

Retries that do not duplicate mail

Every send carries an Idempotency-Key. The SDK generates one for you and retries server errors, rate limits and network failures. Pass your own when you want a retry from a different process to be recognised as the same send.

import { DevelEmail } from '@develemail/sdk';

export async function sendWelcomeOnce() {
  const client = new DevelEmail({
    apiKey: process.env.DEVELEMAIL_API_KEY!,
    baseUrl: 'https://develemail.com/api',
  });

  const { id, status } = await client.emails.send(
    {
      from: '[email protected]',
      to: '[email protected]',
      subject: 'Welcome aboard',
      text: 'Your account is ready.',
    },
    { idempotencyKey: 'welcome-user-42' },
  );
  return { id, status };
}

Batch send with per-item results

Send many emails in one request. Each item gets its own result, so one bad recipient does not fail the rest.

import { DevelEmail } from '@develemail/sdk';

export async function sendReceipts(recipients: string[]) {
  const client = new DevelEmail({
    apiKey: process.env.DEVELEMAIL_API_KEY!,
    baseUrl: 'https://develemail.com/api',
  });

  const { results, created, errors } = await client.emails.batch(
    recipients.map((to) => ({
      from: '[email protected]',
      to,
      subject: 'Your receipt',
      text: 'Thanks for your order.',
    })),
  );
  const failed = results.filter((item) => item.error);
  return { created, errors, failed };
}

Sandbox recipients

Any address at sandbox.develemail.com is accepted while you build. Those messages get the status sandboxed and are not metered against your quota.

import { DevelEmail } from '@develemail/sdk';

export async function sendToSandbox() {
  const client = new DevelEmail({
    apiKey: process.env.DEVELEMAIL_API_KEY!,
    baseUrl: 'https://develemail.com/api',
  });

  const { id, status } = await client.emails.send({
    from: '[email protected]',
    to: '[email protected]',
    subject: 'Sandbox test',
    text: 'Accepted and marked sandboxed.',
  });
  return { id, status };
}

React email components

Write the message as a React component. The React package renders it to HTML and a plain-text part before sending.

import { DevelEmail, Heading, Html, Text } from '@develemail/react';

function Welcome({ name }: { name: string }) {
  return (
    <Html>
      <Heading>Welcome, {name}</Heading>
      <Text>Your account is ready.</Text>
    </Html>
  );
}

export async function sendWelcome() {
  const client = new DevelEmail({
    apiKey: process.env.DEVELEMAIL_API_KEY!,
    baseUrl: 'https://develemail.com/api',
  });

  return client.emails.send({
    from: '[email protected]',
    to: '[email protected]',
    subject: 'Welcome aboard',
    react: <Welcome name="Ada" />,
  });
}

Fastify plugin

Register the plugin once and the client is available as app.develemail. Next.js gets a createClient helper that reads its settings from environment variables.

import Fastify from 'fastify';
import { develEmailPlugin } from '@develemail/fastify';

export async function buildApp() {
  const app = Fastify();

  await app.register(develEmailPlugin, {
    apiKey: process.env.DEVELEMAIL_API_KEY!,
    baseUrl: 'https://develemail.com/api',
  });

  app.post('/welcome', async () =>
    app.develemail.emails.send({
      from: '[email protected]',
      to: '[email protected]',
      subject: 'Welcome aboard',
      text: 'Your account is ready.',
    }),
  );
  return app;
}

Access is invite-only for now

Tell us what you are sending and we will review your request.