Get Started

Add AutoRelay to your app in a few calls.

Use one endpoint for transactional mail and one endpoint for event-driven automation. Keep the key in env, send JSON, and you are live.

Quick Path

Start in three steps

01

Create a key

Create a project-scoped key in the dashboard. Use Mail send for outbound email.

02

Store it in env

Keep the secret outside source code. Use environment variables in your app and deployment.

03

Call the endpoint

Send JSON to /v1/send for mail or /v1/events when you want flows to react.

Mail Send

Direct delivery

Use a Mail send key with POST https://relay.mlib.app/v1/send.

curl -X POST https://relay.mlib.app/v1/send \
  -H "Authorization: Bearer YOUR_MAIL_SEND_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "you@example.com",
    "subject": "AutoRelay test",
    "html": "<p>Hello from AutoRelay.</p>",
    "idempotency_key": "app-send-001"
  }'
const response = await fetch("https://relay.mlib.app/v1/send", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.AUTORELAY_MAIL_KEY}`,
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    to: "you@example.com",
    subject: "AutoRelay test",
    html: "<p>Hello from AutoRelay.</p>",
    idempotency_key: `app-${Date.now()}`
  })
});

const data = await response.json();
console.log(data);

Required fields

  • to for the recipient address
  • subject for the message subject
  • html for the rendered body
  • idempotency_key to prevent duplicate sends

Automation

Events

Use an Events key with POST https://relay.mlib.app/v1/events.

curl -X POST https://relay.mlib.app/v1/events \
  -H "Authorization: Bearer YOUR_EVENTS_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "event_name": "user_signed_up",
    "user_id": "user_123",
    "properties": {
      "email": "you@example.com"
    }
  }'
const response = await fetch("https://relay.mlib.app/v1/events", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.AUTORELAY_EVENTS_KEY}`,
    "Content-Type": "application/json"
  },
  body: JSON.stringify({
    event_name: "user_signed_up",
    user_id: "user_123",
    properties: {
      email: "you@example.com"
    }
  })
});

const data = await response.json();
console.log(data);

Typical event payload

  • event_name names the trigger
  • user_id identifies the actor or customer
  • properties carries flow context like email or plan

Notes

Operational basics

Keep keys separate

Use one key for direct delivery and another for events when you want cleaner access control.

Use idempotency

Send a stable idempotency_key when a retry might happen.

Start small

Begin with one project, one mail key, one test event, then expand flows after the first successful run.