Send email with one request

Mailerjson is a small, predictable email API. One endpoint sends an email, every email costs one credit, and every error has the same shape.

Quick start

  1. Sign up at app.mailerjson.com. A workspace is created for you.
  2. Open Settings, API Keys and choose Create API Key. Copy the key right away, because it is shown only once.
  3. Send your first email. Put the key in an environment variable called MAILERJSON_API_KEY.

Send with curl

curl https://api.mailerjson.com/v1/send \
    -H "Authorization: Bearer $MAILERJSON_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
        "from": "Acme <hello@mailerjson.com>",
        "to": "customer@example.com",
        "subject": "Welcome to Acme",
        "html": "<p>Thanks for signing up.</p>",
        "text": "Thanks for signing up."
    }'

Send with Node.js

const res = await fetch('https://api.mailerjson.com/v1/send', {
    method: 'POST',
    headers: {
        Authorization: `Bearer ${process.env.MAILERJSON_API_KEY}`,
        'Content-Type': 'application/json',
    },
    body: JSON.stringify({
        from: 'Acme <hello@mailerjson.com>',
        to: 'customer@example.com',
        subject: 'Welcome to Acme',
        html: '<p>Thanks for signing up.</p>',
        text: 'Thanks for signing up.',
    }),
});

const data = await res.json();
if (!res.ok) throw new Error(`${data.error.code}: ${data.error.message}`);

console.log(data.id, data.credits_remaining);

Send with Python

import os
import requests

res = requests.post(
    "https://api.mailerjson.com/v1/send",
    headers={"Authorization": f"Bearer {os.environ['MAILERJSON_API_KEY']}"},
    json={
        "from": "Acme <hello@mailerjson.com>",
        "to": "customer@example.com",
        "subject": "Welcome to Acme",
        "html": "<p>Thanks for signing up.</p>",
        "text": "Thanks for signing up.",
    },
    timeout=15,
)

data = res.json()
if not res.ok:
    raise RuntimeError(f"{data['error']['code']}: {data['error']['message']}")

print(data["id"], data["credits_remaining"])

Response

{
    "id": "b0ab8e41-4701-4991-8610-5609e750149f",
    "message_id": "011001a124c47f3f-53ebfcc9-14ce-4010-bb48-5eb9af248c74-000000",
    "credits_remaining": 499
}

Authentication

Send your key in the Authorization header as a Bearer token. Keys start with mj_.

  • A key is shown once. We store only a fingerprint, so a lost key cannot be recovered. Create a new one and delete the old one.
  • Keep keys on your server. Never put one in a web page, a mobile app or a public repository.
  • Revoking is immediate. Delete a key in the dashboard and its next request is refused.
  • Each workspace has its own credits and its own keys, and a workspace can have up to 20 active keys.