Subscribers. Each subscriber is unique and identified by a unique subscriberId.
subscriberId is a unique identifier used by Novu to keep track of a specific subscriber.
We recommend using the internal unique id your application uses for a specific user.- User Data - Data stored in the subscriber object that you can easily access in your notification templates. This contains basic info such as first name, last name, avatar, locale, email, and phone. This data is fixed and structured.
- Custom Data - Apart from the above fixed structured user data, any unstructured custom data such as user’s address, nationality, height, etc can also be stored in the
datafield using key-value pairs. - Channel Specific Credentials -
deviceTokensrequired to send push notifications andwebhookUrlfor chat channel providers can also be stored.
Subscriber attributes
Subscriber response schema
Novu subscriber objectCreate a subscriber
You can create a subscriber in Novu using theidentify method provided in Novu’s SDK.
It is possible for two subscribers to have the same email address in our system. This is because the
subscriberId is the unique identifier that distinguishes one subscriber from another.phone, avatar, and data.
Remember, all user IDs added to Novu need to be unique.
subscriberId, this subscriber cannot be deleted later.
We support creating new subscriber using two ways, Ahead of Trigger means adding subscribers before triggering notification or Inline of Trigger means sending complete subscriber data in to field while triggering.
1. Ahead of Trigger
Create the subscriber and then trigger the notification to this subscriber. HeresubscriberId is the required field and other fields are optional.
- Node.js
- PHP
identify payload. You can call this function during registration or signup to make sure the subscriber data is up-to-date, if you wish to save additional attributes with a subscriber, you can pass additional custom data in the data field as key-value pairs.
2. Inline of Trigger
A non-existing subscriber can be added by sending subscriber data into field of the trigger method. If any subscriber with provided subscriberId does not exists, a new subscriber will be created. In this case, subscriber will be created first and then the trigger will be executed synchronously.
- Node.js
- PHP
Bulk Subscriber Creation
You can create subscribers in bulk (up to 500 at once) via the SDKs or API. The bulk subscriber creation feature is only available in v0.19.0 and above.
- Node.js
Import subscribers
Here,mock_data.csv file is a CSV file having mock data. The below script will read this CSV file and create a new subscriber in Novu. Change example variables values like API_KEY value with your valid values. Download mock_data.csv file from here.
mock_data.csv file should be in the same directory of script - Export your user details in CSV format.
- Clean this exported CSV file. Keep only relevant fields.
- Move this CSV file to the script directory.
- Change the file name in the script with your file name.
- Run the script. (Make script.sh executable before using)
- Shell
- Node.js
Delete a subscriber
To stop a subscriber from receiving notifications, you can delete the subscriber. This will hard delete the subscriber and means you will not be able to access this subscriber later. You will have to create this subscriber again.- Node.js
- PHP
Update a subscriber
In some cases, you want to access a subscriber to update a specific user data field or custom data field. For example, when the users change their email address or personal details.- Node.js
- PHP
Find a subscriber
Any subscriber can be retrieved using a unique subscriber identifiersubscriberId. Check the returned subscriber schema here.
- Node.js
- PHP