Events and Triggers
Events decide when a workflow starts. The events array registers the workflow with Brezel, while the matching event/* element is the actual entry node in the graph.
Webhooks
Section titled “Webhooks”Use webhook events for explicit user actions, resource-table buttons, detail-view buttons, or calls from another workflow.
{ "identifier": "createProjectTask", "type": "webhook", "module": "projects"}{ "name": "createProjectTask", "type": "event/webhook", "options": { "module": "projects", "public": false, "refresh_prototype": true }, "set": { "project": "default:", "data": "input:" }}Use a webhook when the action has a clear command name: create, publish, assign, export, approve, reject, regenerate.
Resource lifecycle events
Section titled “Resource lifecycle events”Use lifecycle events when behavior must happen automatically after or before a resource change.
| Event type | Use for |
|---|---|
create | Initialize related records after creation. |
update | Recalculate derived state after save. |
delete | Clean up related records after deletion. |
beforeCreate | Validate or block creation; value edits are not persisted by normal saves. |
beforeUpdate | Validate or block updates. |
beforeSave | Validate or block a save; value edits are not persisted by normal saves. |
beforeDelete | Prevent deletion or prepare cleanup. |
Keep lifecycle workflows narrow. They may run more often than expected because every save operation can trigger them.
UI events
Section titled “UI events”Use on_click for layout buttons where the layout component emits the event directly.
{ "identifier": "calculateTaskPreview", "type": "on_click", "module": "tasks"}Use on_change when a field change should set other fields, load options, or validate a small part of the form.
{ "identifier": "customer", "type": "select", "options": { "references": "customers", "events": { "on_change": ["setProjectDefaults"] } }}on_change workflows usually receive the current prototype, the original resource, and the selector of the changed field. See Data Flow and UI Integration.
Cron events
Section titled “Cron events”Use cron for scheduled maintenance, reminders, status checks, and batch synchronization.
{ "identifier": "sendTaskReminders", "type": "cron", "frequency": [[{"schedule": "cron", "parameters": ["0 8 * * 1-5"]}]]}Set frequency on the events registration, not only the event element options. Each outer group creates a scheduled job (OR); scheduler calls within a group are chained (AND). For example weekdays plus at 08:30 can be one group; a second cron group adds another time. Names must be Laravel scheduler methods. In tests use dispatch_sync with the cron entry instead of waiting for the scheduler.
Cron workflows should usually be async: true, log their work, and avoid client-only actions such as action/response, action/set, or action/modal.
Policy and query events
Section titled “Policy and query events”Use policy events to constrain access dynamically.
{ "identifier": "projectPolicy", "type": "policy", "module": "projects", "roles": ["employee"], "operations": ["read", "update"], "allow": ["admin", "manager"], "roleKey": "slug"}Policy workflows typically continue into query/where elements. See Policies and Access.
Use scope or options-style events for reusable query restrictions and dynamic select options. Keep them deterministic and fast because they are often called while the UI is loading.
Choosing a trigger
Section titled “Choosing a trigger”- Choose
webhookfor explicit commands. - Choose
on_changeoron_clickfor UI-local interactions. - Choose lifecycle events for automatic reactions to resource persistence.
- Choose
cronfor time-based work. - Choose
policyfor access constraints. - Choose
action/runfrom another workflow when orchestration is clearer than exposing a new UI event.
Lifecycle value changes
Section titled “Lifecycle value changes”Normal UI/REST saves calculate the persisted values before beforeCreate/beforeUpdate/beforeSave. Changes made by op/set there are not saved. Use these hooks for validation/blocking; use field recipes or a deliberate post-save action/save path to persist values. action/save with triggerEvents reads attributes after beforeSave and differs from the normal save path.
Event catalog
Section titled “Event catalog”See the generated events for all registered event types, including event/ocrReady (case-sensitive), subscription events, agent_tool and fieldPolicy.