Admin API
This endpoint requires admin-level roles (platform_admin, tenant_admin, or system_admin). Accessible via the API gateway at /v1/platform/*.
Automation Rules API
Business rule automation for triggers, actions, conditions, and workflow orchestration.
Overview
| Attribute | Value |
|---|---|
| Base Path | /api/v1/automation |
| Authentication | Bearer Token |
| Required Roles | JWT authentication required (no specific role restriction) |
Rules Management
List Rules
Retrieve all automation rules.
GET /api/v1/automation/rules
Query Parameters
| Parameter | Type | Description |
|---|---|---|
status | string | active, paused, draft |
category | string | Rule category |
trigger_type | string | Filter by trigger type |
Response
{
"rules": [
{
"id": "rule_001",
"name": "Low Inventory Alert",
"description": "Send alert when inventory drops below threshold",
"category": "inventory",
"status": "active",
"trigger": {
"type": "event",
"event": "inventory.updated",
"conditions": [
{"field": "quantity", "operator": "lt", "value": "${item.reorder_point}"}
]
},
"actions": [
{
"type": "notification",
"channel": "slack",
"template": "low_inventory_alert"
},
{
"type": "create_task",
"assignee": "inventory_manager"
}
],
"stats": {
"executions_24h": 15,
"last_executed": "2026-01-24T18:45:00Z",
"success_rate": 0.98
},
"created_at": "2025-06-01T00:00:00Z",
"updated_at": "2026-01-20T10:00:00Z"
},
{
"id": "rule_002",
"name": "VIP Customer Welcome",
"description": "Auto-assign best server when VIP customer checks in",
"category": "customer_service",
"status": "active",
"trigger": {
"type": "event",
"event": "reservation.checked_in",
"conditions": [
{"field": "customer.tags", "operator": "contains", "value": "vip"}
]
},
"actions": [
{
"type": "assign_server",
"criteria": "highest_rating"
},
{
"type": "notification",
"channel": "staff_app",
"recipients": ["host", "manager"],
"message": "VIP ${customer.name} has arrived"
}
]
}
],
"total": 25
}
Create Rule
POST /api/v1/automation/rules
Request Body
{
"name": "Auto-Reply to Reviews",
"description": "Automatically respond to 5-star reviews",
"category": "reputation",
"trigger": {
"type": "event",
"event": "review.received",
"conditions": [
{"field": "rating", "operator": "eq", "value": 5},
{"field": "platform", "operator": "in", "value": ["google", "yelp"]}
]
},
"actions": [
{
"type": "ai_generate",
"action": "generate_review_response",
"parameters": {
"tone": "grateful",
"include_name": true,
"max_length": 280
}
},
{
"type": "post_response",
"delay_minutes": 30,
"requires_approval": false
}
],
"schedule": {
"enabled": false
},
"rate_limit": {
"max_per_hour": 10
}
}
Response
{
"id": "rule_003",
"name": "Auto-Reply to Reviews",
"status": "draft",
"created_at": "2026-01-24T19:30:00Z",
"validation": {
"valid": true,
"warnings": [
"Consider adding approval workflow for AI-generated responses"
]
}
}
Get Rule
GET /api/v1/automation/rules/{rule_id}
Response
{
"id": "rule_001",
"name": "Low Inventory Alert",
"description": "Send alert when inventory drops below threshold",
"category": "inventory",
"status": "active",
"trigger": {
"type": "event",
"event": "inventory.updated",
"conditions": [
{
"field": "quantity",
"operator": "lt",
"value": "${item.reorder_point}",
"description": "Quantity below reorder point"
}
],
"debounce_minutes": 60
},
"actions": [
{
"id": "action_001",
"type": "notification",
"channel": "slack",
"template": "low_inventory_alert",
"parameters": {
"channel": "#inventory-alerts",
"mention": "@inventory-team"
}
},
{
"id": "action_002",
"type": "create_task",
"parameters": {
"title": "Reorder ${item.name}",
"assignee": "inventory_manager",
"priority": "high",
"due_hours": 24
}
},
{
"id": "action_003",
"type": "api_call",
"condition": "${item.auto_reorder_enabled}",
"parameters": {
"method": "POST",
"endpoint": "/api/v1/purchase-orders",
"body": {
"vendor_id": "${item.preferred_vendor}",
"items": [{"item_id": "${item.id}", "quantity": "${item.reorder_quantity}"}]
}
}
}
],
"error_handling": {
"on_failure": "retry",
"max_retries": 3,
"notify_on_failure": true
},
"audit_log": [
{
"timestamp": "2026-01-24T18:45:00Z",
"action": "executed",
"trigger_data": {"item_id": "item_123", "quantity": 5},
"result": "success"
}
]
}
Update Rule
PUT /api/v1/automation/rules/{rule_id}
Request Body
{
"name": "Updated Rule Name",
"actions": [
{
"type": "notification",
"channel": "email",
"recipients": ["manager@example.com"]
}
]
}
Delete Rule
DELETE /api/v1/automation/rules/{rule_id}
Activate/Pause Rule
POST /api/v1/automation/rules/{rule_id}/activate
POST /api/v1/automation/rules/{rule_id}/pause
Triggers
Available Trigger Types
| Type | Description |
|---|---|
event | React to system events |
schedule | Time-based execution |
webhook | External webhook trigger |
condition | Condition-based monitoring |
Available Events
GET /api/v1/automation/triggers/events
Response
{
"events": [
{
"name": "order.created",
"category": "orders",
"description": "New order placed",
"available_fields": ["order_id", "total", "items", "customer", "channel"]
},
{
"name": "order.completed",
"category": "orders",
"available_fields": ["order_id", "total", "duration_minutes", "server"]
},
{
"name": "inventory.updated",
"category": "inventory",
"available_fields": ["item_id", "quantity", "previous_quantity", "location"]
},
{
"name": "reservation.checked_in",
"category": "reservations",
"available_fields": ["reservation_id", "customer", "party_size", "table"]
},
{
"name": "review.received",
"category": "reputation",
"available_fields": ["platform", "rating", "text", "customer_name"]
},
{
"name": "employee.clocked_in",
"category": "workforce",
"available_fields": ["employee_id", "location", "scheduled_time", "actual_time"]
},
{
"name": "payment.processed",
"category": "payments",
"available_fields": ["payment_id", "amount", "method", "tip_amount"]
}
]
}
Actions
Available Action Types
GET /api/v1/automation/actions/types
Response
{
"actions": [
{
"type": "notification",
"description": "Send notification",
"channels": ["email", "sms", "slack", "teams", "staff_app", "push"],
"parameters": ["channel", "recipients", "template", "message"]
},
{
"type": "create_task",
"description": "Create a task",
"parameters": ["title", "description", "assignee", "due_date", "priority"]
},
{
"type": "api_call",
"description": "Call internal or external API",
"parameters": ["method", "endpoint", "headers", "body"]
},
{
"type": "update_record",
"description": "Update a database record",
"parameters": ["entity_type", "entity_id", "fields"]
},
{
"type": "ai_generate",
"description": "Generate content using AI",
"parameters": ["action", "prompt", "tone", "max_length"]
},
{
"type": "assign_server",
"description": "Assign server to table",
"parameters": ["criteria", "fallback"]
},
{
"type": "send_promo",
"description": "Send promotional offer",
"parameters": ["promo_id", "channel", "personalize"]
},
{
"type": "escalate",
"description": "Escalate to manager",
"parameters": ["reason", "urgency", "notify"]
}
]
}
Execution
Execute Rule Manually
Test or manually trigger a rule.
POST /api/v1/automation/rules/{rule_id}/execute
Request Body
{
"test_mode": true,
"trigger_data": {
"item_id": "item_123",
"quantity": 5,
"item": {
"name": "Ground Beef",
"reorder_point": 10,
"reorder_quantity": 20,
"preferred_vendor": "vendor_sysco"
}
}
}
Response
{
"execution_id": "exec_001",
"rule_id": "rule_001",
"test_mode": true,
"status": "completed",
"results": [
{
"action_id": "action_001",
"type": "notification",
"status": "success",
"output": {
"message_id": "msg_123",
"channel": "slack"
}
},
{
"action_id": "action_002",
"type": "create_task",
"status": "success",
"output": {
"task_id": "task_456"
}
},
{
"action_id": "action_003",
"type": "api_call",
"status": "skipped",
"reason": "Condition not met: auto_reorder_enabled is false"
}
],
"duration_ms": 450,
"executed_at": "2026-01-24T19:30:00Z"
}
Get Execution History
GET /api/v1/automation/rules/{rule_id}/executions
Query Parameters
| Parameter | Type | Description |
|---|---|---|
status | string | success, failed, partial |
start_date | datetime | Period start |
end_date | datetime | Period end |
limit | integer | Results limit |
Get Execution Details
GET /api/v1/automation/executions/{execution_id}
Templates
List Notification Templates
GET /api/v1/automation/templates
Response
{
"templates": [
{
"id": "low_inventory_alert",
"name": "Low Inventory Alert",
"category": "inventory",
"channels": ["slack", "email"],
"variables": ["item.name", "item.quantity", "item.reorder_point"],
"content": {
"slack": ":warning: *Low Inventory Alert*\n${item.name} is below reorder point\nCurrent: ${item.quantity} | Reorder at: ${item.reorder_point}",
"email": {
"subject": "Low Inventory: ${item.name}",
"body": "..."
}
}
}
]
}
Create Template
POST /api/v1/automation/templates
Request Body
{
"id": "vip_arrival",
"name": "VIP Customer Arrival",
"category": "customer_service",
"channels": ["staff_app", "slack"],
"content": {
"staff_app": "VIP Alert: ${customer.name} has arrived for their ${time} reservation",
"slack": ":star: VIP ${customer.name} checked in at Table ${table.number}"
}
}
Conditions & Operators
Available Operators
| Operator | Description | Example |
|---|---|---|
eq | Equals | rating eq 5 |
ne | Not equals | status ne 'cancelled' |
gt | Greater than | total gt 100 |
gte | Greater or equal | party_size gte 6 |
lt | Less than | quantity lt 10 |
lte | Less or equal | wait_time lte 15 |
in | In list | platform in ['google', 'yelp'] |
not_in | Not in list | status not_in ['draft', 'cancelled'] |
contains | Contains value | tags contains 'vip' |
starts_with | Starts with | email starts_with 'vip' |
is_empty | Is null/empty | notes is_empty |
is_not_empty | Has value | phone is_not_empty |
Analytics
Get Automation Analytics
GET /api/v1/automation/analytics
Query Parameters
| Parameter | Type | Description |
|---|---|---|
period | string | day, week, month |
Response
{
"period": "week",
"summary": {
"total_rules": 25,
"active_rules": 22,
"total_executions": 1250,
"successful_executions": 1225,
"failed_executions": 25,
"success_rate": 0.98
},
"by_category": [
{"category": "inventory", "executions": 450, "success_rate": 0.99},
{"category": "customer_service", "executions": 380, "success_rate": 0.97},
{"category": "reputation", "executions": 220, "success_rate": 0.95}
],
"top_rules": [
{
"rule_id": "rule_001",
"name": "Low Inventory Alert",
"executions": 180,
"success_rate": 1.0
}
],
"actions_taken": {
"notifications_sent": 850,
"tasks_created": 125,
"api_calls_made": 95,
"records_updated": 180
},
"estimated_time_saved_hours": 45.5
}
Webhooks
| Event | Description |
|---|---|
automation.rule_executed | Rule was executed |
automation.rule_failed | Rule execution failed |
automation.rule_created | New rule created |
automation.rule_updated | Rule was modified |
Error Responses
| Status | Code | Description |
|---|---|---|
| 400 | invalid_condition | Condition syntax invalid |
| 400 | invalid_action | Action configuration invalid |
| 404 | rule_not_found | Rule ID not found |
| 409 | rule_conflict | Conflicting rule exists |
| 422 | execution_failed | Rule execution failed |
Related Documentation
- Webhooks Guide - Webhook setup
- Notifications API - Notification system
- AI Agents - AI-powered actions