๐ค Automation API โ
๐ List Rules โ
GET /api/automation-rules
Authorization: Bearer <manager-token>Returns all automation rules.
Response:
json
{
"success": true,
"data": [
{
"id": "cuid",
"name": "Order Confirmation Email",
"event": "order.statusChanged",
"conditions": { "status": "CONFIRMED" },
"actions": [
{
"type": "email",
"template": "orderConfirmation",
"to": "customer"
}
],
"isActive": true
}
]
}๐ Get Rule โ
GET /api/automation-rules/:id
Authorization: Bearer <manager-token>โ Create Rule โ
POST /api/automation-rules
Authorization: Bearer <manager-token>Request:
json
{
"name": "New Order Webhook",
"event": "order.created",
"conditions": null,
"actions": [
{
"type": "webhook",
"url": "https://hooks.example.com/new-order",
"method": "POST"
}
],
"isActive": true
}โ๏ธ Update Rule โ
PATCH /api/automation-rules/:id
Authorization: Bearer <manager-token>๐๏ธ Delete Rule โ
DELETE /api/automation-rules/:id
Authorization: Bearer <super-admin-token>๐ก Event Reference โ
| Event | Fires When |
|---|---|
๐ฆ order.created | New order is placed |
๐ order.statusChanged | Order status is updated |
๐
reservation.created | New reservation is submitted |
โญ review.submitted | Customer submits a review |
โก Action Reference โ
๐ง Email Action โ
json
{
"type": "email",
"to": "customer",
"subject": "Your order is confirmed",
"template": "orderConfirmation"
}๐ Webhook Action โ
json
{
"type": "webhook",
"url": "https://example.com/hook",
"method": "POST"
}The full event data is sent as the request body.
๐ฑ SMS Action โ
json
{
"type": "sms",
"to": "customer",
"message": "Your order #{{order.orderNumber}} is ready!"
}๐ Permissions Summary โ
| Action | Required Role |
|---|---|
| ๐ List / get rules | Manager, Super Admin |
| โ Create / update rules | Manager, Super Admin |
| ๐๏ธ Delete rules | Super Admin |