PadiMail Docs
Get started

cURL quickstart

Send an email and look it up, straight from your terminal.

NeedsAny accountTest keys work as soon as you sign up. Nothing is delivered.

1. Set your key

Create a test key under API keys in the dashboard, then:

export PADIMAIL_API_KEY=pm_test_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

2. Send

curl -X POST https://api.padimail.app/v1/emails \
  -H "Authorization: Bearer $PADIMAIL_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: first-email-1" \
  -d '{
    "from": "Acme Store <onboarding@sandbox.padimail.app>",
    "to": "delivered@test.padimail.app",
    "subject": "Hello from PadiMail",
    "html": "<p>It works.</p>"
  }'

The response is the email's ID: { "id": "em_01JB…" }. It means the email was accepted, not yet delivered. Sending the same request with the same Idempotency-Key again within 24 hours returns the same ID instead of sending twice.

3. Look it up

curl https://api.padimail.app/v1/emails/em_01JB... \
  -H "Authorization: Bearer $PADIMAIL_API_KEY"

status moves from queued through sent to delivered within a few seconds. The timeline is at /v1/emails/{id}/events.

The same in Node

import { PadiMail } from "@padimail/node";

const pm = new PadiMail(process.env.PADIMAIL_API_KEY);
const { id } = await pm.emails.send({ from: "Acme Store <onboarding@sandbox.padimail.app>", to: "delivered@test.padimail.app", subject: "Hello from PadiMail", html: "<p>It works.</p>" });
console.log((await pm.emails.get(id)).status);

When something's wrong

Errors come back with a code and a link to what to do about it:

{
  "error": {
    "type": "authentication_error",
    "code": "invalid_api_key",
    "message": "That API key isn't valid.",
    "doc_url": "https://padimail.dev/errors#invalid_api_key",
    "request_id": "req_01JB…"
  }
}

Every code is explained on the Errors page.

Was this page helpful?

On this page