Skip to main content
Version: v5.0

Notifications

Overview#

Notifications are read-only entities which are created when a notification is about to be sent to a given subscription.

Notification log#

The status of the notification is updated after the notification is sent, or if any error occurs. This information is stored in a notification log which is a history of the notifications sent.

Notification properties.#

A notification has the following properties:

  • _namespaces: A string array, which will contain a single item, which is the owning namespace for this notification. The user making the query must have the read permission in this namespace for the IRN: notificationsvc:notification:*
  • _subscription._id: The ID of the subscription to which the notification was sent.
  • _trigger._id: The ID of the trigger that caused the notification.
  • _owner._irn: The IRN of the owning user.
  • _template._id: The ID of the template that was used to generate the notification.
  • _sender._id: The ID of the sender that was used to send the notification.
  • _transport: The device transport type.
  • _requestId: The request ID that originated this notification.
  • _eventId: The event ID that originated this notification. This will only be present when the trigger is of type EVENT.
  • _status: The status of the notification, which is of the following values:
    • SENDING: The notification is about to be sent
    • SENT: The notification was sent, and no errors are reported
    • ERROR: The notification failed
    • SKIPPED: The notification was not sent, because it failed rate limiting (See Rate Limiting below.

Rate limiting#

There are limits to the number of notifications which can be sent within a given period. This is referred to as rate limiting.

Before a notification is sent, the recently sent notifications are first checked. If the rate limit is exceeded, a notification log entry is still created, but it is set to SKIPPED.

The following rate limit logic is applied (the lowest limit applies):

  • Each subscription can be notified 1000 times in one 24-hour period.
  • Each trigger can be invoked 10,000 times in one 24-hour period.
  • Each subscription can be notified by the same trigger 500 times in one 24-hour period.

These limits can be manually adjusted per environment.

API examples#

List notifications#

To list notifications, you must provide a query. The query must include at a minimum, a set of namespaces to which the user making the query has READ permission. Alternatively, the user must be the owner of the namespace.

The following query properties are supported:

  • namespaces
  • owner.irn
  • subscription.id
  • trigger.id
  • template.id
  • sender.id
  • transport
  • requestId
  • eventId

To query for notifications in your project, refer to the sample code below.

const notifications = await IafNotification.listNotifications({    namespaces: project._namespaces}, ctx);

To query for your own notifications, refer to the sample code below.

const notifications = await IafNotification.listNotifications({    owner: {        irn: "passportsvc:user:<user id>"    }}, ctx);