API Events #

Executed API actions trigger two of these three events:

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

Requests rejected before reaching their action (failed rights check, rate limit, overload protection) trigger none of these events. See request:afterExecution to observe every request.

Requests executed with the EmbeddedSDK only trigger these events when the triggerEvents option is set.

For the memoryStorage controller, event names use the ms prefix instead of the controller name: for instance, ms:beforeGet and ms:afterGet.


before #

ArgumentsTypeDescription
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 actionBefore event name
auth:loginauth:beforeLogin
document:createOrReplacedocument:beforeCreateOrReplace

after #

ArgumentsTypeDescription
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 actionAfter event name
auth:loginauth:afterLogin
document:createOrReplacedocument:afterCreateOrReplace

error #

ArgumentsTypeDescription
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 actionError event name
auth:loginauth:errorLogin
document:createOrReplacedocument:errorCreateOrReplace