Skip to main content
All OneSignal server SDKs are generated from the same OpenAPI specification, so they share a consistent interface regardless of language. Each SDK wraps the OneSignal REST API and provides typed models for requests and responses.

Available SDKs


Installation

npm install @onesignal/node-onesignal

Configuration

Every SDK requires authentication via API keys. Two key types are available:
  • REST API Key — required for most endpoints (sending notifications, managing users, etc.). Found in your app’s Settings > Keys & IDs.
  • Organization API Key — only required for organization-level endpoints like creating or listing apps. Found in Organization Settings.
const OneSignal = require('@onesignal/node-onesignal');

const configuration = OneSignal.createConfiguration({
  restApiKey: 'YOUR_REST_API_KEY',
  organizationApiKey: 'YOUR_ORGANIZATION_API_KEY',
});

const client = new OneSignal.DefaultApi(configuration);
Store your API keys in environment variables or a secrets manager. Never commit them to source control.

Send a push notification

Send push notifications to web and mobile Subscriptions by targeting a segment.
const notification = new OneSignal.Notification();
notification.app_id = 'YOUR_APP_ID';
notification.contents = { en: 'Hello from OneSignal!' };
notification.headings = { en: 'Push Notification' };
notification.included_segments = ['Subscribed Users'];

const response = await client.createNotification(notification);
console.log('Notification ID:', response.id);

Send an email

Send emails to Subscriptions with the email channel.
const notification = new OneSignal.Notification();
notification.app_id = 'YOUR_APP_ID';
notification.email_subject = 'Important Update';
notification.email_body = '<h1>Hello!</h1><p>This is an HTML email.</p>';
notification.included_segments = ['Subscribed Users'];
notification.channel_for_external_user_ids = 'email';

const response = await client.createNotification(notification);

Send an SMS

Send SMS text messages to Subscriptions with the sms channel.
const notification = new OneSignal.Notification();
notification.app_id = 'YOUR_APP_ID';
notification.contents = { en: 'Your SMS message content here' };
notification.included_segments = ['Subscribed Users'];
notification.channel_for_external_user_ids = 'sms';
notification.sms_from = '+15551234567';

const response = await client.createNotification(notification);

Full API reference

Each server SDK supports the same set of API endpoints. Refer to your SDK’s API documentation for the complete method list, including users, subscriptions, segments, templates, and more. For the underlying REST API, see the complete API reference.

FAQ

Which server SDK should I choose?

Use the SDK that matches your backend language. All server SDKs are generated from the same OpenAPI specification and support the same endpoints, so functionality is identical across languages.

What is the difference between the REST API Key and Organization API Key?

The REST API Key is scoped to a single app and is required for most operations like sending notifications and managing users. The Organization API Key is scoped to your organization and is only needed for creating or listing apps. Most integrations only need the REST API Key.

Can I use the REST API directly instead of an SDK?

Yes. The server SDKs are convenience wrappers around the OneSignal REST API. You can call the API directly using any HTTP client with Bearer token authentication.

Are these SDKs auto-generated?

Yes. All server SDKs are generated from the OneSignal OpenAPI specification using OpenAPI Generator. This ensures consistent API coverage across all languages.