Automations
Create and manage event-driven transactional automations with a Bearer rnl_… API key (or dashboard session).
Base URL: https://api.ranla.ai
You can also build flows visually in the dashboard canvas under Automations.
Authentication
Authorization: Bearer rnl_…Create an automation
POST /automations
Creates a draft. Activate it before events will match.
{
"name": "Welcome email",
"trigger": {
"type": "event",
"event": "user.created"
},
"steps": [
{
"type": "send_email",
"email": {
"from": "[email protected]",
"to": "{{event.email}}",
"subject": "Welcome",
"html": "<p>Hi {{event.data.name}}</p>"
}
}
]
}Examples below are generated from src/lib/dx/snippets.ts (same source as the dashboard).
curl
curl -X POST https://api.ranla.ai/automations \
-H "Authorization: Bearer rnl_…" \
-H "Content-Type: application/json" \
-d '{"name":"Welcome email","trigger":{"type":"event","event":"user.created"},"steps":[{"type":"send_email","email":{"from":"[email protected]","to":"{{event.email}}","subject":"Welcome","html":"<p>Hi {{event.data.name}}</p>"}}]}'npm
npm install @supersend/ranla
import { Ranla } from '@supersend/ranla'
const client = new Ranla('rnl_…')
const { automation } = await client.automations.create({
name: 'Welcome email',
trigger: { type: 'event', event: 'user.created' },
steps: [
{
type: 'send_email',
email: {
from: '[email protected]',
to: '{{event.email}}',
subject: 'Welcome',
html: '<p>Hi {{event.data.name}}</p>',
},
},
],
})
await client.automations.activate(automation.id)CLI
RANLA_API_KEY=rnl_… npx -y --package=ranla-cli -- ranla automations create --file ./welcome.json
RANLA_API_KEY=rnl_… npx -y --package=ranla-cli -- ranla automations activate --id "$AUTOMATION_ID"welcome.json should match the request body above.
Endpoints
| Method | Path | Notes |
|---|---|---|
GET |
/automations |
List |
POST |
/automations |
Create draft |
GET |
/automations/{id} |
Get |
PATCH |
/automations/{id} |
Update name/trigger/steps |
DELETE |
/automations/{id} |
Delete |
POST |
/automations/{id} |
{ "action": "activate" | "pause" } |
GET |
/automations/runs |
Optional ?automation_id= |
GET |
/automations/runs/{id} |
Run detail |
POST |
/automations/runs/{id} |
{ "action": "cancel" | "retry" } |
Step types
| Type | Purpose |
|---|---|
send_email |
Send via the same transactional send path as POST /emails — inline subject/html or a published email.template |
send_sms |
Send SMS via Twilio — requires a connected integration and sms.to + sms.body |
delay |
Wait seconds before the next step |
condition |
Continue only if true; false stops the run (not if/else branching) |
wait_for_event |
Pause until another event arrives (optional timeout_seconds; on_timeout continue or fail, default fail) |
Trigger options: cancel_on_events — array of event names that cancel active runs for the same recipient when fired.
Placeholders in email and SMS steps: {{event.email}}, {{event.user_id}}, {{event.data.foo}}.
SMS example (send_sms)
Connect Twilio first (integrations twilio connect), then create an automation:
{
"name": "Auth OTP (SMS)",
"trigger": { "type": "event", "event": "auth.code_requested" },
"steps": [
{
"type": "send_sms",
"sms": {
"to": "{{event.data.phone}}",
"body": "Your code is {{event.data.code}}. Expires in 10 min."
}
}
]
}RANLA_API_KEY=rnl_… npx -y --package=ranla-cli -- ranla integrations twilio connect \
--account-sid AC… --auth-token … --from +15551234567
RANLA_API_KEY=rnl_… npx -y --package=ranla-cli -- ranla automations create --file ./otp-sms.json
RANLA_API_KEY=rnl_… npx -y --package=ranla-cli -- ranla automations activate --id "$AUTOMATION_ID"Template example (mutually exclusive with inline subject / html / text):
{
"type": "send_email",
"email": {
"from": "[email protected]",
"to": "{{event.email}}",
"template": {
"id": "welcome",
"variables": { "name": "{{event.data.name}}" }
}
}
}Trigger the flow
After activate, send events with POST /events or:
supersendtx events send --name user.created --email [email protected] --data '{"name":"Ada"}'