Skip to content

๐Ÿค– 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 โ€‹

EventFires When
๐Ÿ“ฆ order.createdNew order is placed
๐Ÿ”„ order.statusChangedOrder status is updated
๐Ÿ“… reservation.createdNew reservation is submitted
โญ review.submittedCustomer 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 โ€‹

ActionRequired Role
๐Ÿ“‹ List / get rulesManager, Super Admin
โž• Create / update rulesManager, Super Admin
๐Ÿ—‘๏ธ Delete rulesSuper Admin