Skip to content

Hook Contract

Input payload

Hook input includes:

  • event: lifecycle event string
  • collection: collection name for collection-scoped events
  • record: current record payload
  • previous_record: previous row state when applicable
  • auth: auth context (user_id, roles)
  • meta: request metadata (request_id, timestamp, resource)

Output payload

Hook result shape:

  • ok: boolean
  • record?: object (used mainly by before_* hooks to mutate payload)
  • errors?: [{ code, message, hint? }]
  • warnings?: [{ code, message }]
  • meta_patch?: object

Behavioral semantics

  • before_* + ok: false: request is rejected.
  • after_* + ok: false: request succeeds; warning is collected in meta.hook_warnings.
  • before_* + record set: Zeptoz continues with mutated record.

Capability APIs (JS/TS runtime)

Available in ctx:

  • ctx.auth.hasRole(role)
  • ctx.db.findOne/create/update/delete(...)
  • ctx.log.info/warn/error(...)

Use only these capability APIs from hook code.