Skip to main content
API-Defined Hooks let you automate actions in response to events, on a schedule, or on demand — all configured through the REST API or Admin UI without writing backend code.
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:
  1. Trigger — When the hook fires (event, schedule, or manual)
  2. Condition — An optional rule expression that gates execution
  3. 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:
Supported events: The collection field is optional — omit it to match events across all collections.

Schedule Triggers

Fire on a cron schedule:
Standard 5-field cron syntax is supported:
When a scheduled hook is enabled, next_run_at is automatically calculated. Disabling clears it; re-enabling recalculates it.

Manual Triggers

Fire only when explicitly triggered via the API:
Trigger manually:

Condition Expressions

Add an optional condition to gate hook execution. The hook only fires if the expression evaluates to true:
Conditions use the same rule expression syntax as collection rules and webhook filters.
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 with partial 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:

Execution Logging

Every hook execution is logged with:

Execution Statuses

Limits

Comparison: Hooks vs Webhooks vs Workflows