Create a key
Create a project-scoped key in the dashboard. Use Mail send for outbound email.
Get Started
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
Create a project-scoped key in the dashboard. Use Mail send for outbound email.
Keep the secret outside source code. Use environment variables in your app and deployment.
Send JSON to /v1/send for mail or /v1/events when you want flows to react.
Mail Send
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 addresssubject for the message subjecthtml for the rendered bodyidempotency_key to prevent duplicate sendsAutomation
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 triggeruser_id identifies the actor or customerproperties carries flow context like email or planNotes
Use one key for direct delivery and another for events when you want cleaner access control.
Send a stable idempotency_key when a retry might happen.
Begin with one project, one mail key, one test event, then expand flows after the first successful run.