{"id":14766,"library":"notificationapi-node-server-sdk","title":"NotificationAPI Node.js Server SDK","description":"The NotificationAPI Node.js Server SDK provides a streamlined interface for integrating real-time and multi-channel notifications into server-side applications. This SDK allows developers to send various types of notifications, including in-app, email, SMS, and push notifications, by interacting with the NotificationAPI platform. Currently at version 2.8.0, the package appears to be actively maintained with frequent updates, indicated by its publishing history on npm. It abstracts the complexity of notification delivery, enabling developers to focus on application logic rather than the intricacies of different communication channels or provider APIs. The SDK ships with built-in TypeScript types, ensuring a robust development experience and improved code quality for TypeScript users. Key differentiators lie in the comprehensive notification platform it connects to, offering a centralized solution for notification management, templating, and delivery across multiple channels.","status":"active","version":"2.8.0","language":"javascript","source_language":"en","source_url":"https://github.com/notificationapi-com/notificationapi-node-server-sdk","tags":["javascript","notificationapi","node","server","typescript"],"install":[{"cmd":"npm install notificationapi-node-server-sdk","lang":"bash","label":"npm"},{"cmd":"yarn add notificationapi-node-server-sdk","lang":"bash","label":"yarn"},{"cmd":"pnpm add notificationapi-node-server-sdk","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The SDK primarily uses ES Modules. While Node.js has CJS-ESM interop, direct `require` statements for this package can lead to `ERR_REQUIRE_ESM` errors in certain configurations, especially with TypeScript or modern build setups. Prefer ESM `import`.","wrong":"const NotificationAPI = require('notificationapi-node-server-sdk');","symbol":"NotificationAPI","correct":"import { NotificationAPI } from 'notificationapi-node-server-sdk';"},{"note":"The main class is typically exported as a named export. A default import might not be available or could lead to undefined behavior if the package structure changes. Be mindful of casing for 'NotificationAPI' (PascalCase).","wrong":"import { NotificationApi } from 'notificationapi-node-server-sdk';","symbol":"NotificationAPI","correct":"import NotificationAPI from 'notificationapi-node-server-sdk';"},{"note":"For type-checking configuration objects without importing the runtime value, use `import type` for better tree-shaking and to avoid accidental runtime imports.","symbol":"NotificationAPIClientConfig","correct":"import type { NotificationAPIClientConfig } from 'notificationapi-node-server-sdk';"}],"quickstart":{"code":"import { NotificationAPI } from 'notificationapi-node-server-sdk';\n\nconst CLIENT_ID = process.env.NOTIFICATIONAPI_CLIENT_ID ?? '';\nconst CLIENT_SECRET = process.env.NOTIFICATIONAPI_CLIENT_SECRET ?? '';\n\nif (!CLIENT_ID || !CLIENT_SECRET) {\n  console.error('Environment variables NOTIFICATIONAPI_CLIENT_ID and NOTIFICATIONAPI_CLIENT_SECRET must be set.');\n  process.exit(1);\n}\n\nconst notificationapi = new NotificationAPI({\n  clientId: CLIENT_ID,\n  clientSecret: CLIENT_SECRET,\n});\n\nasync function sendExampleNotification() {\n  try {\n    const response = await notificationapi.send({\n      notificationId: 'user_welcome',\n      user: {\n        id: 'test-user-123',\n        email: 'test@example.com',\n        // Additional user properties like 'name', 'phone_number' can be added\n      },\n      mergeTags: {\n        firstName: 'John',\n        lastName: 'Doe',\n        welcomeMessage: 'Welcome to our service!',\n      },\n    });\n    console.log('Notification sent successfully:', response);\n  } catch (error) {\n    console.error('Failed to send notification:', error);\n  }\n}\n\nsendExampleNotification();\n","lang":"typescript","description":"Demonstrates initializing the NotificationAPI SDK with environment variables and sending a basic welcome notification to a user with merge tags."},"warnings":[{"fix":"Ensure your Node.js runtime environment meets the minimum version specified in the SDK's `package.json` or release notes before upgrading the SDK. Consider using Node.js LTS versions for production.","message":"Future major versions of this SDK may drop support for older Node.js LTS versions (e.g., Node.js 16 or 18 as Node.js 20+ becomes prevalent). Always check the release notes for minimum Node.js requirements before upgrading to a new major SDK version.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Store API keys as environment variables (e.g., `process.env.NOTIFICATIONAPI_CLIENT_ID`) and inject them securely at runtime. For serverless functions, use secrets management services provided by your cloud provider.","message":"API Keys (ClientId and ClientSecret) should never be hardcoded directly into your application's source code, especially in client-side bundles. Exposure of these keys can lead to unauthorized access to your NotificationAPI account.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Consult the official NotificationAPI documentation and SDK release notes for specific migration steps when upgrading across major versions. Update your payload structures and method calls accordingly.","message":"Changes in the NotificationAPI platform's API or data models may necessitate updates to the SDK, potentially introducing breaking changes in method signatures or response structures. Always review the migration guide when upgrading major SDK versions.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Refer to the NotificationAPI documentation for exact payload schemas for each notification type. Implement thorough input validation on your backend before constructing and sending payloads via the SDK.","message":"Incorrectly formatted notification payloads (e.g., missing required fields, invalid types) will result in API errors. The SDK may perform basic validation, but robust server-side validation is still essential.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Use ES Module `import` syntax: `import { NotificationAPI } from 'notificationapi-node-server-sdk';` ensure your `package.json` has `\"type\": \"module\"` if using ESM for your project, or configure your TypeScript/bundler appropriately.","cause":"Attempting to import the NotificationAPI SDK using CommonJS `require()` syntax in an environment configured for ES Modules, or if the SDK is ESM-only.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module ... not supported"},{"fix":"Verify that `new NotificationAPI({ clientId, clientSecret })` is called with valid credentials and that the `notificationapi` object is available in scope before attempting to call its methods.","cause":"The NotificationAPI client was not correctly initialized, or `clientId`/`clientSecret` were missing, leading to an undefined or improperly constructed object.","error":"TypeError: Cannot read properties of undefined (reading 'send')"},{"fix":"Double-check your `NOTIFICATIONAPI_CLIENT_ID` and `NOTIFICATIONAPI_CLIENT_SECRET` environment variables. Ensure they match the keys from your NotificationAPI dashboard and have the required permissions.","cause":"The provided `clientId` or `clientSecret` are incorrect, expired, or lack the necessary permissions to perform the requested operation.","error":"API Error: Invalid credentials"}],"ecosystem":"npm"}