entities.hooks
Lifecycle hooks.
Guide: Before-hooks
The entities block spans these pages: entities · entities · fields · entities · computed & rollups · entities · rules · entities · hooks · entities · indexes.
entities.<name>.hooks
Section titled “entities.<name>.hooks”Lifecycle hooks. before* = in-transaction, no network, may reject/mutate; after* = post-commit from the outbox.
- Type:
object - Required: no
entities.<name>.hooks.beforeCreate
Section titled “entities.<name>.hooks.beforeCreate”Before-hooks, run in declaration order inside the write’s transaction: each may reject the write or mutate the row about to be written (mutate is refused on beforeDelete). No network access.
- Type:
array of object - Required: no
entities.<name>.hooks.beforeCreate[].condition
Section titled “entities.<name>.hooks.beforeCreate[].condition”Condition in the CEL subset. Context: @user, @tenant; hooks/events additionally expose old, new, changed(field). Compiled fail-fast at apply time.
- Type:
string - Required: no
entities.<name>.hooks.beforeCreate[].action
Section titled “entities.<name>.hooks.beforeCreate[].action”Before-actions run in-transaction: reject or mutate only. No network, no external calls.
- Type:
object - Required: yes
entities.<name>.hooks.beforeCreate[].action.reject
Section titled “entities.<name>.hooks.beforeCreate[].action.reject”Cancels the operation; the text becomes the detail of the RFC 7807 error.
- Type:
string - Required: yes (in its variant)
- Exactly one of
reject,mutate.
entities.<name>.hooks.beforeCreate[].action.mutate
Section titled “entities.<name>.hooks.beforeCreate[].action.mutate”Payload patch before write: field -> literal value or tagged {“$cel”: ”…”} expression.
- Type:
map of any - Required: yes (in its variant)
- Exactly one of
reject,mutate. - Each entry: A literal JSON value, or a tagged CEL expression object {“$cel”: ”…”}.
entities.<name>.hooks.beforeCreate[].action.mutate.<name>.$cel
Section titled “entities.<name>.hooks.beforeCreate[].action.mutate.<name>.$cel”A CEL expression whose result becomes the value, in place of a JSON literal (e.g. now(), @user.id).
- Type:
string - Required: yes
entities.<name>.hooks.beforeUpdate
Section titled “entities.<name>.hooks.beforeUpdate”Before-hooks, run in declaration order inside the write’s transaction: each may reject the write or mutate the row about to be written (mutate is refused on beforeDelete). No network access.
- Type:
array of object - Required: no
- Same shape as
entities.<name>.hooks.beforeCreate.
entities.<name>.hooks.beforeDelete
Section titled “entities.<name>.hooks.beforeDelete”Before-hooks, run in declaration order inside the write’s transaction: each may reject the write or mutate the row about to be written (mutate is refused on beforeDelete). No network access.
- Type:
array of object - Required: no
- Same shape as
entities.<name>.hooks.beforeCreate.
entities.<name>.hooks.afterCreate
Section titled “entities.<name>.hooks.afterCreate”After-hooks, delivered post-commit from the outbox with retries; a condition filters which writes trigger them.
- Type:
array of object - Required: no
entities.<name>.hooks.afterCreate[].condition
Section titled “entities.<name>.hooks.afterCreate[].condition”Condition in the CEL subset. Context: @user, @tenant; hooks/events additionally expose old, new, changed(field). Compiled fail-fast at apply time.
- Type:
string - Required: no
entities.<name>.hooks.afterCreate[].action
Section titled “entities.<name>.hooks.afterCreate[].action”After-side action (post-commit, durable, retries). Payload transformations = JSONata; {{…}} is sugar.
- Type:
object - Required: yes
entities.<name>.hooks.afterCreate[].action.type
Section titled “entities.<name>.hooks.afterCreate[].action.type”Selects the variant.
- Type:
string - Required: yes
- Values:
"webhook","email","function","entity.update","http.call"
entities.<name>.hooks.afterCreate[].action.endpoint
Section titled “entities.<name>.hooks.afterCreate[].action.endpoint”The name of an endpoint declared under the top-level webhooks.endpoints.
- Type:
string - Required: yes (in its variant)
- Pattern:
^[a-z][a-z0-9_-]{0,62}$ - Only when
typeis"webhook".
entities.<name>.hooks.afterCreate[].action.payload
Section titled “entities.<name>.hooks.afterCreate[].action.payload”Depends on the variant; see the notes below.
- Type:
string or map of any - Required: depends on the variant
- Only when
typeis"webhook","entity.update"or"http.call". - When
typeis"webhook"or"http.call":string, optional — JSONata transformation expression (JSON -> JSON). Runs strictly post-commit (after-side), with depth/time limits. {{…}} templates are syntactic sugar. - When
typeis"entity.update":map of any, required — Field -> literal value or tagged {“$cel”: ”…”} expression; {{…}} sugar allowed in string values. Each entry: A literal JSON value, or a tagged CEL expression object {“$cel”: ”…”}. - When
typeis"entity.update": Same shape asentities.<name>.hooks.beforeCreate[].action.mutate.<name>.
entities.<name>.hooks.afterCreate[].action.template
Section titled “entities.<name>.hooks.afterCreate[].action.template”The name of a template declared in the top-level templates block.
- Type:
string - Required: yes (in its variant)
- Pattern:
^[a-z][a-z0-9_-]{0,62}$ - Only when
typeis"email".
entities.<name>.hooks.afterCreate[].action.to
Section titled “entities.<name>.hooks.afterCreate[].action.to”Address or a {{…}} template.
- Type:
string - Required: yes (in its variant)
- Only when
typeis"email".
entities.<name>.hooks.afterCreate[].action.data
Section titled “entities.<name>.hooks.afterCreate[].action.data”JSONata transformation expression (JSON -> JSON). Runs strictly post-commit (after-side), with depth/time limits. {{…}} templates are syntactic sugar.
- Type:
string - Required: no
- Only when
typeis"email".
entities.<name>.hooks.afterCreate[].action.name
Section titled “entities.<name>.hooks.afterCreate[].action.name”The name of a function declared in the top-level functions block.
- Type:
string - Required: yes (in its variant)
- Pattern:
^[a-z][a-z0-9_-]{0,62}$ - Only when
typeis"function".
entities.<name>.hooks.afterCreate[].action.input
Section titled “entities.<name>.hooks.afterCreate[].action.input”JSONata transformation expression (JSON -> JSON). Runs strictly post-commit (after-side), with depth/time limits. {{…}} templates are syntactic sugar.
- Type:
string - Required: no
- Only when
typeis"function".
entities.<name>.hooks.afterCreate[].action.entity
Section titled “entities.<name>.hooks.afterCreate[].action.entity”The entity whose record is created or updated.
- Type:
string - Required: yes (in its variant)
- Pattern:
^[a-z][a-z0-9_-]{0,62}$ - Only when
typeis"entity.update".
entities.<name>.hooks.afterCreate[].action.recordId
Section titled “entities.<name>.hooks.afterCreate[].action.recordId”Id or {{…}} template; omit to create a new record.
- Type:
string - Required: no
- Only when
typeis"entity.update".
entities.<name>.hooks.afterCreate[].action.url
Section titled “entities.<name>.hooks.afterCreate[].action.url”Absolute URL to call.
- Type:
string - Required: yes (in its variant)
- Only when
typeis"http.call".
entities.<name>.hooks.afterCreate[].action.method
Section titled “entities.<name>.hooks.afterCreate[].action.method”HTTP method.
- Type:
string - Required: no
- Values:
"GET","POST","PUT","PATCH","DELETE" - Default:
"POST" - Only when
typeis"http.call".
entities.<name>.hooks.afterCreate[].action.headersSecretRef
Section titled “entities.<name>.hooks.afterCreate[].action.headersSecretRef”Secret name in ISecretStore holding request headers (e.g. auth token); never the value itself.
- Type:
string - Required: no
- Only when
typeis"http.call".
entities.<name>.hooks.afterUpdate
Section titled “entities.<name>.hooks.afterUpdate”After-hooks, delivered post-commit from the outbox with retries; a condition filters which writes trigger them.
- Type:
array of object - Required: no
- Same shape as
entities.<name>.hooks.afterCreate.
entities.<name>.hooks.afterDelete
Section titled “entities.<name>.hooks.afterDelete”After-hooks, delivered post-commit from the outbox with retries; a condition filters which writes trigger them.
- Type:
array of object - Required: no
- Same shape as
entities.<name>.hooks.afterCreate.