Core
API v2.x
2

Notifications #

Document Notification #

The following notifications are sent by Kuzzle whenever one of the following event matches the subscription filters:

  • A real-time message is sent
  • A new document has been created
  • A document has been updated or replaced

Real-time notifications are also sent when documents, previously in the subscription scope, are leaving it because of the following events:

  • document is deleted
  • document is updated/replaced and its new content do not match the subscription filters anymore

Format #

A document notification contains the following fields:

PropertyTypeDescription
actionstringAPI controller's action
collectionstringCollection name
controllerstringAPI controller
eventstringEvent type (write, delete or publish)
indexstringIndex name
nodestringUnique identifier of the node who generated the notification
protocolstringNetwork protocol used to modify the document
resultobjectNotification content
roomstringSubscription channel identifier. Can be used to link a notification to its corresponding subscription
scopestringin: document enters (or stays) in the scope
out: document leaves the scope
timestampnumberTimestamp of the event, in Epoch-millis format
typestringdocument: the notification type
volatileobjectKuzzleRequest volatile data

The result object is the notification content, and it has the following structure:

PropertyTypeDescription
_idstringDocument unique ID
null if the notification is from a real-time message
_sourceobjectThe message or full document content.
_updatedFieldsstring[]List of fields that have been updated (only available on document partial updates)

Example #

{
  "index": "foo",
  "collection": "bar",
  "controller": "document",
  "action": "create",
  "protocol": "http",
  "timestamp": 1497513122738,
  "volatile": null,
  "scope": "in",
  "node": "knode-nasty-author-4242",
  "result":{
    "_source":{
      "some": "document content",
      "_kuzzle_info": {
        "author": "<author kuid>",
        "createdAt": 1497866996975
      }
    },
    "_id": "<document identifier>"
  },
  "room":"893e183fc7acceb5-7a90af8c8bdaac1b"
}

User Notification #

User notifications are triggered by the following events:

  • A user subscribes to the same room
  • A user leaves that room

These notifications are sent only if the users argument is set to any other value than the default none one (see subscription request).

Format #

PropertyTypeDescription
actionstringAPI controller's action
collectionstringData collection
controllerstringAPI controller
indexstringData index
nodestringUnique identifier of the node who generated the notification
protocolstringNetwork protocol used by the entering/leaving user
resultobjectNotification content
roomstringSubscription channel identifier. Can be used to link a notification to its corresponding subscription
timestampnumberTimestamp of the event, in Epoch-millis format
typestringuser: the notification type
userstringin: a new user has subscribed to the same filters
out: a user cancelled a shared subscription
volatileobjectKuzzleRequest volatile data

The result object is the notification content, and it has the following structure:

PropertyTypeDescription
countnumberUpdated users count sharing that same subscription

Example #

{
  "index": "<index name>",
  "collection": "<collection name>",
  "controller": "realtime",
  "action": "subscribe",
  "protocol": "websocket",
  "timestamp": 1497517009931,
  "user": "in",
  "node": "knode-nasty-author-4242",
  "result": {
    "count": 42
  },
  "volatile": {
    "fullname": "John Snow",
    "favourite season": "winter",
    "goal in life": "knowing something"
  }
}

Server Notification #

Server notifications are triggered by global events, and they are sent to all of a client's subscriptions at the same time.

Currently, the only event generating a server notification is when an authentication token has expired, closing the subscription.

Other events may be added in the future.

Format #

PropertyTypeValue
messagestringServer message explaining why this notification has been triggered
typestringTokenExpired: notification type

Example #

{
  "message": "Authentication Token Expired",
  "type": "TokenExpired"
}

Debugger Notification #

Debugger notifications are triggered by the Debug Controller only when the debugger is enabled. Those notifications are sent to every connections currently listening to events from the Debug Controller using the action debug:addListener.

Format #

PropertyTypeDescription
eventstringName of the event that triggered the notification
resultobjectNotification content
roomstringSubscription channel identifier. Will always be kuzzle-debugger-event

Example #

{
  "room": "kuzzle-debugger-event",
  "event": "HeapProfiler.reportHeapSnapshotProgress",
  "result": {
      "method": "HeapProfiler.reportHeapSnapshotProgress",
      "params": {
          "done": 238276,
          "total": 238276,
          "finished": true
      }
  }
}