Home
Softono
onesignal-dotnet-api

onesignal-dotnet-api

Open source C#
24
Stars
18
Forks
0
Issues
32
Watchers
1 week
Last Commit

About onesignal-dotnet-api

The OneSignalApi .NET SDK is a C client library for interacting with the OneSignal platform. It enables .NET developers to send personalized push notifications, emails, and SMS messages at scale as part of customer engagement workflows. Key features include support for REST API and Organization API authentication using access tokens, methods for creating and managing push notifications targeted to user segments, email delivery with HTML body support, and SMS messaging from configured sender numbers. The library wraps OneSignal REST API version 5.6.0 and is distributed as a NuGet package via dotnet add package OneSignalApi. Typical use cases include integrating OneSignal messaging into .NET web applications, backend services, and console tools to notify users across multiple channels, managing subscriber segments, and automating marketing or transactional communications. Configuration requires setting a base path and access token through the Configuration class, with API keys ideally stored in environment vari

Platforms

Web Self-hosted Windows

Languages

C#

Links

OneSignalApi - the C# library for OneSignal

A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com

  • API version: 5.6.0
  • SDK version: 5.7.0

Installation

dotnet add package OneSignalApi

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.

Warning: Store your API keys in environment variables or a secrets manager. Never commit them to source control.

using OneSignalApi.Api;
using OneSignalApi.Client;

var config = new Configuration();
config.BasePath = "https://api.onesignal.com";
config.AccessToken = "YOUR_REST_API_KEY";

var client = new DefaultApi(config);

Send a push notification

using OneSignalApi.Model;

var notification = new Notification(appId: "YOUR_APP_ID")
{
    Contents = new StringMap(en: "Hello from OneSignal!"),
    Headings = new StringMap(en: "Push Notification"),
    IncludedSegments = new List<string> { "Subscribed Users" }
};

var response = client.CreateNotification(notification);
Console.WriteLine("Notification ID: " + response.Id);

Send an email

var notification = new Notification(appId: "YOUR_APP_ID")
{
    EmailSubject = "Important Update",
    EmailBody = "<h1>Hello!</h1><p>This is an HTML email.</p>",
    IncludedSegments = new List<string> { "Subscribed Users" },
    ChannelForExternalUserIds = "email"
};

var response = client.CreateNotification(notification);

Send an SMS

var notification = new Notification(appId: "YOUR_APP_ID")
{
    Contents = new StringMap(en: "Your SMS message content here"),
    IncludedSegments = new List<string> { "Subscribed Users" },
    ChannelForExternalUserIds = "sms",
    SmsFrom = "+15551234567"
};

var response = client.CreateNotification(notification);

Full API reference

The complete list of API endpoints and their parameters is available in the DefaultApi documentation.

For the underlying REST API, see the OneSignal API reference.