Headless Inbox API Reference
Novu
Novu
is the primary class used to interact with the Novu API client, enabling you to fetch and manage notifications and preferences within your custom Inbox implementation.
Constructor options
applicationIdentifier
is a unique identifier for the application. This is is
public credential that is used to authenticate the application with the Novu
API. applicationIdentifier
can be copied from API
Keys page.
subscriberId
is a unique identifier for the subscriber. Read more about
subscribers.
subscriberHash
is a unique identifier for the subscriber. It is used for
HMAC encryption. Read more about HMAC
Encryption.
Use https://eu.api.novu.co
value for EU region.
Use https://eu.ws.novu.co
value for EU region.
The field is used to enable/disable the cache for the notifications and preferences. By default, the cache is enabled.
Usage
Modules interface
Notifications
Methods
- list
- count
- read
- unread
- archive
- unarchive
- readAll
- archiveAll
- archiveAllRead
- completePrimary
- completeSecondary
- revertPrimary
- revertSecondary
Notification Interface
list
Method to fetch the list of notifications based on the provided filters.
By default the response is cached internally and stored by provided filters as a key.
The cache will be updated automatically with the subsequent response if the filters didn’t change.
All cached responses will be merged into a single list and returned as the result.
You can disable this behaviour and the cache by setting the useCache
parameter to false
in the Novu constructor options.
Params
Workflow tags can be used to filter notifications where at least one specified tag matches. Read more about how can you define workflow tags.
Filter notifications based on their read status. If not provided, all read/unread notifications will be returned.
Filter notifications based on their archived status. Archived notifications are also read at the same time. If not provided, all archived/unarchived notifications will be returned.
Limit the number of notifications to be fetched. It can take any number between 1 and 100. Default is 10.
after
can be used to fetch the next set of notifications after a specific notification. It can take notification.id
as value.Field value can be used to skip the first n
notifications. It can be used in
conjunction with limit
to paginate the notifications.
Returns
The returned object contains the data and error fields.
The data object contains the list of notifications and other metadata.
Error object if the request fails.
Usage
count
Method to fetch the count of read, unread, archived and unarchived notifications grouped by tags. You can also pass multiple filters to fetch the different notifications counts.
Params
Workflow tags can be used to count notifications where at least one specified tag matches. Read more about how can you define workflow tags.
Count notifications based on their read status. If not provided, all read/unread notifications will be counted.
Count notifications based on their archived status. Archived notifications are also read at the same time. If not provided, all archived/unarchived notifications will be counted.
Multiple filters can be used to count notifications. Each filter can have different tags, read and archived status.
Returns
The returned object contains the data and error fields.
The data object contains the count of notifications and other metadata.
Error object if the request fails.
Usage
read
Method marks a notification as read.
Params
Notification ID is a unique identifier for the notification. It can be taken from the notification object.
Notification object represents the message sent to the subscriber.
Usage
unread
Method marks a notification as unread.
Params
Notification ID is a unique identifier for the notification. It can be taken from the notification object.
Notification object represents the message sent to the subscriber.
Usage
archive
Method marks a notification as archived.
Params
Notification ID is a unique identifier for the notification. It can be taken from the notification object.
Notification object represents the message sent to the subscriber.
Usage
unarchive
Method marks a notification as unarchived.
Params
Notification ID is a unique identifier for the notification. It can be taken from the notification object.
Notification object represents the message sent to the subscriber.
Usage
readAll
Method marks all notifications as read. Notifications can be filtered by tags.
Params
Workflow tags can be used to filter notifications, and organize them into different groups. Read more about how can you define workflow tags.
Usage
archiveAll
Method marks all notifications as archived. Notifications can be filtered by tags.
Params
Workflow tags can be used to filter notifications, and organize them into different groups. Read more about how can you define workflow tags.
Usage
archiveAllRead
Method marks all read notifications as archived. Notifications can be filtered by tags.
Params
Workflow tags can be used to filter notifications, and organize them into different groups. Read more about how can you define workflow tags.
Usage
completePrimary
Method marks primary action of a notification as completed. It changes the isCompleted
field of primaryAction
to done from pending.
Params
Usage
completeSecondary
Method marks secondary action of a notification as completed. It changes the isCompleted
field of primaryAction
to done from pending.
Params
Usage
revertPrimary
Method marks primary action of a notification as pending. It changes the isCompleted
field of primaryAction
to pending from done.
Params
Usage
revertSecondary
Method marks secondary action of a notification as pending. It changes the isCompleted
field of secondaryAction
to pending from done.
Params
Usage
Preferences
Methods
Preference Interface
list
Method fetch the global and workflows channel preferences of the subscriber.
Usage
update
Method updates the channel preferences of the subscriber. It updates the channel preferences of the subscriber for the specific workflow if workflowId
is provided. If workflowId
is not provided, it updates the global channel preferences of the subscriber. Multiple channels can be updated at once.
Params
Usage
Events
Usage
Was this page helpful?