Workflows API Overview
Automate multi-channel messaging sequences with event-driven workflows. Send coordinated campaigns across Email, SMS, and WhatsApp with custom timing, conditions, and personalization.
What are Workflows?โ
Workflows are automated, multi-step messaging sequences that execute when triggered. They allow you to:
- ๐ง Multi-Channel Campaigns - Coordinate Email, SMS, and WhatsApp in one workflow
- โฐ Timed Sequences - Add delays between steps (e.g., email โ wait 1 day โ SMS)
- ๐ฏ Smart Targeting - Send to specific contacts, tags, or all users
- ๐ Event-Driven - Trigger automatically based on user actions or API calls
- ๐ Track Performance - Monitor delivery, engagement, and costs across all channels
- ๐งช Channel-Specific Variables - Use different OTPs or content per channel
How Workflows Workโ
โโโโโโโโโโโโโโโโโโโ
โ 1. Trigger โ API call or event triggers workflow
โโโโโโโโโโฌโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโ
โ 2. Load Steps โ Workflow steps execute in sequence
โโโโโโโโโโฌโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโ
โ 3. Execute โ Send messages across channels
โ Steps โ Email โ delay โ SMS โ delay โ WhatsApp
โโโโโโโโโโฌโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโ
โ 4. Track & โ Monitor delivery, engagement, costs
โ Report โ
โโโโโโโโโโโโโโโโโโโ
Available Endpointsโ
| Endpoint | Method | Description |
|---|---|---|
/api/v1/workflows/trigger | POST | Trigger workflow - Simple API to trigger a workflow for contacts |
/api/v1/workflows/send | POST | Send workflow - Advanced workflow trigger with full control |
/api/v1/workflows | POST | Create a new event-driven workflow |
/api/v1/workflows | GET | List all workflows with filtering |
/api/v1/workflows/:id | GET | Get workflow details with statistics |
/api/v1/workflows/:id | PATCH | Update workflow configuration |
/api/v1/workflows/:id | DELETE | Delete a workflow |
/api/v1/workflows/:id/executions | GET | Get execution history for a workflow |
Core Conceptsโ
1. Workflow Triggerโ
Triggers determine when a workflow executes. Two methods:
- API Trigger - Manually trigger via API call (most common)
- Event Trigger - Automatically trigger based on user events (coming soon)
2. Recipient Typesโ
Choose who receives the workflow:
| Type | Description | Use Case |
|---|---|---|
contact | Single contact by external ID | Verify specific user |
tag | All contacts with specific tags (AND logic) | Send to "premium" + "beta" users |
all | All contacts in your account | Newsletters, announcements |
3. Workflow Stepsโ
Each workflow consists of steps that execute sequentially:
{
"step_order": 1,
"channel_type": "email",
"configuration": {
"template_id": "welcome-email",
"delay_minutes": 0,
"variables": {
"welcome_bonus": "$10"
}
}
}
Step delay: Steps can have delays (e.g., wait 24 hours before next step)
4. Variables & Channel Variablesโ
General Variables apply to all steps:
{
"variables": {
"user_name": "John",
"company": "Acme Inc"
}
}
Channel-Specific Variables override per channel (perfect for different OTPs):
{
"channel_variables": {
"email": { "otp": "123456" },
"sms": { "otp": "654321" },
"whatsapp": { "otp": "789012" }
}
}
5. Workflow Executionโ
When you trigger a workflow:
- Trigger created - Request accepted, trigger ID returned
- Steps queued - Workflow steps added to processing queue
- Messages sent - Each step sends to appropriate channel
- Tracking updated - Delivery, engagement, and costs tracked
Execution Status:
PENDING- Waiting to startPROCESSING- Currently executingCOMPLETED- All steps finishedFAILED- Execution failedSCHEDULED- Delayed for future execution
Quick Startโ
1. Trigger a Simple Workflowโ
curl -X POST https://api.sendmator.com/api/v1/workflows/trigger \
-H "X-API-Key: sk_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"workflow_id": "your-workflow-uuid",
"recipient_type": "contact",
"contact_external_id": "user_123",
"variables": {
"user_name": "John Doe"
}
}'
2. Trigger with Channel-Specific OTPsโ
curl -X POST https://api.sendmator.com/api/v1/workflows/trigger \
-H "X-API-Key: sk_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"workflow_name": "OTP Verification",
"recipient_type": "contact",
"contact_external_id": "user_123",
"variables": {
"user_name": "John Doe"
},
"channel_variables": {
"email": { "otp": "123456" },
"sms": { "otp": "654321" },
"whatsapp": { "otp": "789012" }
}
}'
3. Schedule for Laterโ
curl -X POST https://api.sendmator.com/api/v1/workflows/trigger \
-H "X-API-Key: sk_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"workflow_id": "your-workflow-uuid",
"recipient_type": "all",
"trigger_at": "2024-12-25T10:00:00Z"
}'
Common Use Casesโ
1. User Onboarding Sequenceโ
Day 0: Welcome Email
Day 1: Getting Started Guide (Email)
Day 3: Feature Highlights (SMS)
Day 7: Success Stories (WhatsApp)
2. Multi-Channel OTP Verificationโ
Send different OTP codes to Email, SMS, and WhatsApp for maximum security.
3. Abandoned Cart Recoveryโ
1 Hour: Reminder Email
24 Hours: SMS with discount code
48 Hours: WhatsApp with limited offer
4. Event Announcementsโ
Trigger workflow to send immediate notifications across all channels.
Best Practicesโ
1. Variable Organizationโ
- General variables - User info, order details, common data
- Channel variables - Channel-specific OTPs, URLs, formatting
2. Error Handlingโ
Always handle response codes:
201- Success, trigger created400- Invalid request404- Workflow not found401- Authentication error
3. Testingโ
Use a test workflow with a single contact before sending to all users.
4. Rate Limitingโ
Workflows respect rate limits per channel. Large campaigns may take time to complete.
5. Monitoringโ
Check workflow execution status:
GET /api/v1/workflows/:workflow_id
Next Stepsโ
- Trigger Workflow - Learn the simplified trigger API
- Create Workflow - Build custom workflows
- List Workflows - Query and filter workflows
- Get Workflow Details - View execution statistics
Authenticationโ
All workflow endpoints require authentication via API Key:
X-API-Key: sk_live_your_api_key
Get your API key from your Sendmator dashboard.