Core
Framework v2.x
2

API Events #

All API actions, without exception, trigger two of these three events:

  • before the action starts
  • after it succeeds
  • after it fails

before #

Arguments Type Description
request
KuzzleRequest
The normalized API request

A before event is triggered before an API request starts.

Naming Template #

The before event name is built using the following template:

<controller>:before<Action>

  • controller: API controller name
  • Action: controller action, camel cased

Example #

API action Before event name
auth:login auth:beforeLogin`
document:createOrReplace document:beforeCreateOrReplace

after #

Arguments Type Description
request
KuzzleRequest
The normalized API request

An after event is triggered after an API request succeeds.

Naming Template #

The after event name is built using the following template:

<controller>:after<Action>

  • controller: API controller name
  • Action: controller action, camel cased

Example #

API action After event name
auth:login auth:afterLogin
document:createOrReplace document:afterCreateOrReplace

error #

Arguments Type Description
request
KuzzleRequest
The normalized API request

An error event is triggered after an API request fails.

Naming Template #

The error event name is built using the following template:

<controller>:error<Action>

  • controller: API controller name
  • Action: controller action, camel cased

Example #

API action After event name
auth:login auth:errorLogin
document:createOrReplace document:errorCreateOrReplace