This page covers API-Defined Hooks — hooks managed via the REST API with event, schedule, and manual triggers.
For the code-level Python hook system used to extend SnackBase internals, see the Hook System Reference.
Overview
An API-defined hook consists of three parts:- Trigger — When the hook fires (event, schedule, or manual)
- Condition — An optional rule expression that gates execution
- Actions — An ordered list of operations to perform
Key Features
- Three Trigger Types: Event-driven, cron-scheduled, or manual
- Conditional Execution: Gate hooks with rule expressions
- Action Pipelines: Chain multiple actions in sequence
- Execution Logging: Full history with status, duration, and errors
- Enable/Disable Toggle: Pause hooks without deleting them
Trigger Types
Event Triggers
Fire when a specific event occurs in your application:
The
collection field is optional — omit it to match events across all collections.
Schedule Triggers
Fire on a cron schedule:next_run_at is automatically calculated. Disabling clears it; re-enabling recalculates it.
Manual Triggers
Fire only when explicitly triggered via the API:Condition Expressions
Add an optionalcondition to gate hook execution. The hook only fires if the expression evaluates to true:
If a condition expression fails to evaluate, the hook fires anyway (fail-open design).
Actions
Actions are executed sequentially. If an action fails, execution stops and the hook is logged withpartial status.
Supported Action Types
Template Variables
Action configurations support template variables that resolve at execution time:
Example — send a webhook when a high-value order is created: