Skip to main content

Server SDKs (Back-end)

The server-side SDKs allow you to trigger sending notifications. Supported environments:

  • Node.js official
  • Python official
  • PHP official
  • Go official
  • C# documented
  • Ruby documented
  • Any environment that supports HTTP calls

If you don't see your language/framework documented here, just ping us on support and we will provide samples and docs.


npm install notificationapi-node-server-sdk
# Or using Yarn:
yarn add notificationapi-node-server-sdk


Used to send a notification to the specified user.

import notificationapi from 'notificationapi-node-server-sdk';

notificationapi.init('CLIENT_ID', 'CLIENT_SECRET', 'BASE_URL');
notificationId: 'hello_world',
user: {
id: '123',
email: '',
number: '+15005550006'
mergeTags: {
firstName: 'test'


CLIENT_ID (required)

Type: string

Your NotificationAPI account clientId. You can get it from here.

CLIENT_SECRET (required)

Type: string

Your NotificationAPI account client secret. You can get it from here.

BASE_URL (optional)

Type: string

To choose a different region than default (US). Pass to access the Canada region.

notificationId (required)

Type: string

The ID of the notification you wish to send. You can find this value from the dashboard.

user (required)

Type: object

The user to send the notification to. Fields:

  • id: The ID of the user in your system. Required.
  • email: Required for sending email notifications, otherwise optional.
  • number: Required for SMS/CALL notifications, otherwise optional. Valid format: +15005550006. Unformatted US/Canada numbers are also accepted, e.g., (415) 555-1212, 415-555-1212, or 4155551212.
mergeTags (optional)

Type: object

Used to pass in dynamic values into the notification design. Read more: Merge Tags

replace (optional)

Type: object, string key/value pair

Similar to mergeTags, but more flexible. Like the programmatic string replace function, this parameter will replace any string in the notification templates with another string. This operation happens on the fly when sending the notification and does not actually modify the templates.

This operation is case-sensitive and happens after mergeTags are injected.

replace: {
"Dollars": "Euros",
"#ff0000": "#0000ff"

In the example above:

  • The word "Dollars" will be replaced with "Euros" in all the templates used for this notification.
  • The HTML red color code #ff0000 will be replaced with the blue color code 0000ff, making it possible to dynamically brand the email content.
forceChannels (optional)

type: string[]

Used to override the channels which are used for the notification. Read more: forceChannels: Dynamically setting channels

options (optional)

type: object

For additional features such as: attachments, custom replyTo address, BCC, CC. Read more: Options

subNotificationId (optional)

type: string

To break down your notification into multiple categories or groups. Read more: subNotificationId

templateId (optional)

type: string

By default, notifications are sent using the default template of each channel. You can permanently change the default template from the dashboard. However, you can also use this parameter to force using a specific template. This is useful in multiple situations:

  • Design variation: using different wording and design, e.g. "You have new updates" vs. "You don't have any updates"
  • White-labeling: using a specific template that you designed for a white-labeled customer
  • Language: creating and using multiple templates for multiple languages

If the provided templateId does not exist for a channel, the default template will be used, and a warning message will be generated.

Retract: unsending or deleting notifications

Sometimes you need older notifications to be deleted for a certain user. For example when a notification is not valid anymore. The retract function helps you do this.

notificationId: 'hello_world',
userId: '123'

This function deletes all notifications that were generated from the hello_world notification type for user 123. Optionally, you can filter notifications down to secondaryId.


  • notificationId (string)
  • userId (string)
  • secondaryId (string/optional): when used, only notifications are deleted that were given this secondaryId at send

Please note that this only works with: push, inapp, browser notifications. There is no way to undo emails/sms/voice notifications.


forceChannels: Dynamically overriding the channels

By default, notifications are sent over the channels that you specify in the dashboard. This allows you to turn channels on/off without any code changes.

However, you may wish to override these settings dynamically at run-time. That is where you would use the forceChannels field:

notificationId: 'hello_world',
user: { id: '123', email: '' },
forceChannels: ['EMAIL', 'INAPP_WEB']

The code above sends the notification over email and in-app regardless of what channels are active/inactive in the dashboard.


forceChannels field does not override the notification itself being inactive. For it to work, the notification must be in active mode.

options: Additional customization

You can dynamically modify certain notification behavior by passing in options. Example:

notificationId: 'hello_world',
user: { id: '123', email: '', number: '+15005550006' },
options: {
email: {
replyToAddresses: [''],
attachments: [
filename: 'sample.pdf',
url: ''
apn: {
expiry: 1685983222,
priority: 10

Available options:

  • (string[]): An array of email addresses to be used in the reply-to field of emails notifications.
  • (string[]): An array of emails to be CC'ed on the email notifications.
  • (string[]): An array of emails to be BCC'ed on the email notifications.
  • ({ filename: string; url: string }[]): An array of publicly accessible URLs and filenames pointing to files that you wish to include as attachments. The URLs only need to be valid for a few minutes after calling the SDK method. After that, the public URLs can be disabled for privacy. The maximum email size (including the content and all attachments) is 10MB. File extensions in the filename property are necessary for the file to show up nicely in the recipient's device.
  • options.apn.expiry (number): The UNIX timestamp representing when the notification should expire. This does not contribute to the 2048 byte payload size limit. An expiry of 0 indicates that the notification expires immediately.
  • options.apn.priority (number): The priority of the notification. If you omit this header, APNs sets the notification priority to 10. Specify 10 to send the notification immediately. Specify 5 to send the notification based on power considerations on the user’s device. Specify 1 to prioritize the device’s power considerations over all other factors for delivery, and prevent awakening the device.
  • options.apn.collapseId (string): An identifier you use to merge multiple notifications into a single notification for the user. Typically, each notification request displays a new notification on the user’s device. When sending the same notification more than once, use the same value in this header to merge the requests. The value of this key must not exceed 64 bytes.
  • options.apn.threadId (string): Provide this key with a string value that represents the app-specific identifier for grouping notifications. If you provide a Notification Content app extension, you can use this value to group your notifications together. For local notifications, this key corresponds to the threadIdentifier property of the UNNotificationContent object.
  • options.apn.badge (number): Include this key when you want the system to modify the badge of your app icon. If this key is not included in the dictionary, the badge is not changed. To remove the badge, set the value of this key to 0.
  • options.apn.sound (string): Include this key when you want the system to play a sound. The value of this key is the name of a sound file in your app’s main bundle or in the Library/Sounds folder of your app’s data container. If the sound file cannot be found, or if you specify default for the value, the system plays the default alert sound. For details about providing sound files for notifications; see here
  • options.apn.contentAvailable (boolean): Include this key with a value of 1 to configure a background update notification. When this key is present, the system wakes up your app in the background and delivers the notification to its app delegate. For information about configuring and handling background update notifications, see here

subNotificationId: Categorizing notifications of the same type

The subNotificationId is used to specify further subcategories within a notification.

Example 1: Facebook generates "new post from group" notifications. These notifications look and work exactly the same, however they are generated from different groups which notify different users. subNotificationId allows you to specify which group the "new post from group" notification belongs to. This allows the users to subscribe/unsubscribe to groups individually.

Example 2: In a project management tool, there will be notifications such as "task completed" for every project. However, not every user is involved in every project. subNotificationId allows you to subscribe users to "task completed" notifications of some projects, but not others.



notificationId: 'hello_world',
user: { id: '123', email: '', number: '+15005550006' },
subNotificationId: 'abc'