AANCER Developers

Event hooks

Start AANCER workflows or agents when platform events happen. The hook format, event catalog, filters, delivery, retries and replay.

Event hooks

A hook is a small JSON object, data and never code, that says: "when platform event X happens in this workspace, and these filter clauses all match, start workflow W or agent A". Events come from a fixed catalog of ten, such as run.failed, approval.decided and dataset.rows.published. Delivery is reliable: each event is recorded, the hook is evaluated, and the handler is started once per hook and event, with retries, dead letters, manual retry and replay. Hooks belong to a workspace, at most 100 per workspace. You create them under Automations > Hooks, with the REST API, or ship them in a signed pack as kind: "hook".

Hooks do not call URLs. To notify an external system, let the handler workflow do it with a connector step.

Quick start

Start a workflow when an approval is rejected.

{
  "id": "rejected_approvals",
  "title": "Rejected approvals",
  "event": { "name": "approval.decided", "version": 1 },
  "filter": [
    { "path": "payload.outcome", "op": "eq", "value": "rejected" }
  ],
  "handler": { "type": "workflow", "ref": "flow_notify_requester" }
}

The workflow flow_notify_requester must be published with the AANCER Event trigger set to the event approval.decided. In its steps, use {{trigger.payload.approvalId}}, {{trigger.payload.note}} and so on.

File layout

acme-approval-alerts/
  manifest.json          # one hook item, workspace scope
  content/
    hook.json            # the hook spec

Manifest item:

{ "kind": "hook", "schemaVersion": 1, "id": "rejected_approvals", "scope": "workspace",
  "workspace": "{{param.target_workspace}}", "spec": { "$ref": "content/hook.json" } }

A pack hook must have a workspace. The workflow or agent it names must already exist in that workspace.

Field reference

JSON Schema: hook.schema.json

Hook spec

FieldTypeRequiredRules
idstringyes^[a-z0-9][a-z0-9._-]{0,63}$, unique per workspace
workspacestringnoa workspace id or {{param.<id>}}
titlestringnoat most 120 characters. Default: the id
event.namestringyesone of the ten event names below
event.versionintegerno1
filterarraynoup to 8 clauses { path, op, value? }. All must match. For "or", write two hooks
handler.typestringyesworkflow or agent
handler.refstringyesa workflow id, or an agent reference such as agent:digest
delivery.atLeastOncebooleanno
delivery.maxConcurrencyintegerno1 to 20, default 1
delivery.retry.maxintegerno0 to 10, applied up to the installation's setting (default 3)
delivery.retry.backoffSecondsinteger[]noup to 10 values, each 1 to 86400. Default [30, 120, 480]. The last value repeats
enabledbooleannodefault true

With the REST API you can also send dataClassification (sovereign, internal or permitted): the data class for agent handler runs. Leave it out of pack specs. For a pack hook, a workspace admin sets it after install.

Filter clauses

  • path: actor.role, or a dot path starting with payload. or resource..
  • op: eq, neq, in, gt, gte, lt, lte, contains, exists.
  • value: required for every op except exists. in needs an array. exists with value: false means "absent".
  • Types are strict: "5" does not equal 5. gt, gte, lt, lte compare numbers only. contains is a case-insensitive substring match on text, or an element match on arrays. A type mismatch is simply false.

Event catalog

Every handler receives this envelope:

{
  "id": "evt_01",
  "name": "approval.decided",
  "version": 1,
  "workspaceId": "ws-finance",
  "occurredAt": "2026-11-20T10:00:00Z",
  "actor": { "sub": "u_admin", "role": "admin" },
  "resource": { "type": "approval", "id": "apr_01" },
  "payload": { "approvalId": "apr_01", "runId": "run_03", "flowId": "flow_invoices", "outcome": "rejected", "decidedBy": "u_admin", "note": "Amount exceeds budget" },
  "dataCategories": ["CONTACT"]
}
EventPayload fields (always)Payload fields (sometimes)
run.completedrunId, flowIdflowName, durationMs, stepCount, triggeredBy
run.failedrunId, flowId, status (FAILED, INTERNAL_ERROR, TIMEOUT)flowName, errorRef
approval.decidedapprovalId, runId, outcome (approved, rejected), decidedByflowId, note, via (web, teams, slack)
approval.requestedapprovalId, runId, toolId, surface, expiresAtconversationId
dataset.rows.publisheddatasetId, mode (append, upsert, replace), inserted, rowCount, sourceupdated, runId
dashboard.publisheddashboardId, version, publishedBy
document.ingestedknowledgeSetId, documentIdfileType, bytes, ocr
user.provisionedsub, roleName, via (invite, scim, sso, admin)
workspace.member.changedworkspaceId, sub, change (added, removed, role_changed)roleName
schedule.run.completedtaskId, runId, trigger (schedule, manual)conversationId, agentId

Events never carry document content or raw error text. GET /api/events/catalog returns the live catalog with schemas and sample events.

What the handler gets

  • Workflow: the workflow must be published with the AANCER Event trigger. If the trigger names an event, it must be the hook's event. The trigger output is { event, eventName, eventId, workspaceId, occurredAt, payload }, so steps use {{trigger.event}} or {{trigger.payload.datasetId}}.
  • Agent: a governed agent run. The task text holds the event name, time, workspace, resource and the payload as JSON.

A delivery counts as delivered when the run starts. If the run fails later, the failure is shown on the delivery, but it is not retried automatically.

Full examples

Alert when a dataset receives new rows

{
  "id": "orders_alert",
  "title": "New orders alert",
  "event": { "name": "dataset.rows.published", "version": 1 },
  "filter": [
    { "path": "payload.datasetId", "op": "eq", "value": "sales_orders" },
    { "path": "payload.inserted", "op": "gt", "value": 0 }
  ],
  "handler": { "type": "workflow", "ref": "flow_orders_alert" },
  "delivery": { "maxConcurrency": 1, "retry": { "max": 3, "backoffSeconds": [30, 120, 480] } },
  "enabled": true
}

An agent digest after every completed run, as a pack

{
  "v": 2, "kind": "bundle", "id": "acme.run-digest", "version": "1.0.0", "title": "Run digest",
  "publisher": { "name": "Acme Example Ltd", "keyId": "pub-0123456789ab" },
  "requires": { "platform": ">=1.0.0" },
  "parameters": [ { "id": "target_workspace", "type": "workspace", "label": "Workspace", "required": true } ],
  "items": [
    { "kind": "hook", "schemaVersion": 1, "id": "run_digest", "scope": "workspace", "workspace": "{{param.target_workspace}}",
      "spec": { "id": "run_digest", "title": "Digest", "event": { "name": "run.completed" }, "handler": { "type": "agent", "ref": "agent:digest" } } }
  ]
}

Failed runs of one workflow, with its own retry schedule

{
  "id": "invoice_run_failed",
  "event": { "name": "run.failed" },
  "filter": [
    { "path": "payload.flowId", "op": "in", "value": ["flow_invoices", "flow_invoices_eu"] },
    { "path": "payload.status", "op": "neq", "value": "TIMEOUT" }
  ],
  "handler": { "type": "workflow", "ref": "flow_open_ticket" },
  "delivery": { "retry": { "max": 3, "backoffSeconds": [60, 300, 900] } }
}

Install and test

Test the filter first

POST /api/event-hooks/test checks a hook against a sample event. It never starts the handler. It needs hooks.manage_own.

POST /api/event-hooks/test
Content-Type: application/json

{ "workspaceId": "ws-finance",
  "hook": { "id": "rejected_approvals", "event": { "name": "approval.decided" },
            "filter": [ { "path": "payload.outcome", "op": "eq", "value": "rejected" } ],
            "handler": { "type": "workflow", "ref": "flow_notify_requester" } },
  "sampleEvent": { "id": "evt_1", "name": "approval.decided", "version": 1, "workspaceId": "ws-finance",
                   "occurredAt": "2026-11-20T10:00:00Z", "actor": { "sub": "u_admin", "role": "admin" },
                   "resource": { "type": "approval", "id": "apr_01" },
                   "payload": { "approvalId": "apr_01", "runId": "run_03", "outcome": "rejected", "decidedBy": "u_admin" },
                   "dataCategories": ["CONTACT"] } }

Answer: {"matches": true, "clauses": [{"path": "payload.outcome", "op": "eq", "matched": true}], "errors": []}. In the UI, the hook editor has a Test filter button.

Create it

CallPermissionNotes
GET /api/events/catalogsigned inevents, schemas, samples
POST /api/event-hookshooks.manage_own{workspaceId, definition}, returns 201
GET /api/event-hooks?workspaceId=&event=hooks.view_own
PUT /api/event-hooks/{id}hooks.manage_ownnot for pack hooks
POST /api/event-hooks/{id}/enable, /disablehooks.manage_ownenable checks the handler again
DELETE /api/event-hooks/{id}hooks.manage_ownretire
GET /api/event-hooks/{id}/deliveries?state=hooks.view_ownpending, delivered, failed, dead_lettered
POST /api/event-hooks/{id}/deliveries/{deliveryId}/retryhooks.manage_ownfailed or dead-lettered only
POST /api/event-hooks/{id}/replay {from, to, dryRun?}hooks.manage_ownup to 30 days and 1000 events
PUT /api/event-hooks/{id}/data-classificationworkspaces.manage_settings_own{workspaceId, dataClassification}

As a pack

Sign, import and activate the pack (see Packs). Activation creates or updates the hook. Retiring the pack retires it. A pack hook can only be changed with a new pack version, except for its data class.

If the handler workflow is not yet published with an Event trigger, the hook is saved disabled with a warning. Publish the workflow, then enable the hook.

Common errors

CodeStatusMessageFix
VALIDATION400definition is requiredWrap the hook in {"definition": ...}
HOOK_FILTER_INVALID400/id: must match ^[a-z0-9][a-z0-9._-]{0,63}$Lower-case id
HOOK_FILTER_INVALID400/id: a hook with this id already existsChoose another id, or use PUT
HOOK_EVENT_UNKNOWN400/event/name: unknown event '...'Use a catalog name
HOOK_FILTER_INVALID400/filter: at most 8 clauses (OR = two hooks)Split into two hooks
HOOK_FILTER_INVALID400/filter/0/path: path must start with payload., resource. or be actor.role
HOOK_FILTER_INVALID400/filter/0/value: in needs an array value / value is required
HOOK_LIMIT_EXCEEDED422At most 100 hooks per workspace.Retire unused hooks
HOOK_HANDLER_NOT_FOUND422Workflow '...' does not exist. / Agent '...' does not exist.Create it first
HOOK_HANDLER_FORBIDDEN422Workflow '...' belongs to another workspace.Use a handler in the hook's workspace
HOOK_HANDLER_INACTIVE422the workflow is not published with an Event triggerPublish it with the AANCER Event trigger, then enable
HOOK_INVALID400/dataClassification: sovereign, internal or permittedUse one of the three values
warning HANDLER_INACTIVEthe workflow is not published with an Event trigger; deliveries will fail until it is.Publish it with the AANCER Event trigger, then enable
HOOK_MANAGED_BY_PACK409This hook is managed by pack '...'; edit the pack.Ship a new pack version
DELIVERY_NOT_RETRYABLEA '...' delivery cannot be retried.Only failed or dead-lettered deliveries
HOOK_DISABLED409A disabled hook cannot replay; enable it first.
HOOK_REPLAY_WINDOW_INVALID400The replay window is limited to 30 days.Choose from and to within 30 days
HOOK_REPLAY_TOO_LARGE400More than 1000 events match; narrow the window.Narrow the window
delivery lastErrorHANDLER_INACTIVE: Workflow '...' listens to '...', not '...'.Make the trigger event and the hook event match
PACK_SCHEMA_INVALID422/items/.../spec: must NOT have additional propertiesFor example dataClassification in a pack spec. Remove it

Limits and editions

  • 100 hooks per workspace, 8 filter clauses per hook, 20 concurrent deliveries per hook.
  • Replay reaches events the installation still keeps, up to 30 days per replay.
  • Hooks are controlled by permissions: hooks.view_own, hooks.manage_own. Firing a workflow also needs the workflow to be allowed to run.
  • Check your edition on aancer.ai/pricing.