A powerful way to send personalized messages at scale and build effective customer engagement strategies. Learn more at onesignal.com
- API version: 5.3.0
- SDK version: 5.4.0-beta1
- Build package: org.openapitools.codegen.languages.CSharpNetCoreClientCodegen For more information, please visit https://onesignal.com
- .NET Core >=1.0
- .NET Framework >=4.6
- Mono/Xamarin >=vNext
- RestSharp - 106.13.0 or later
- Json.NET - 12.0.3 or later
- JsonSubTypes - 1.8.0 or later
- System.ComponentModel.Annotations - 5.0.0 or later
The DLLs included in the package may not be the latest version. We recommend using NuGet to obtain the latest version of the packages:
Install-Package RestSharp
Install-Package Newtonsoft.Json
Install-Package JsonSubTypes
Install-Package System.ComponentModel.Annotations
NOTE: RestSharp versions greater than 105.1.0 have a bug which causes file uploads to fail. See RestSharp#742. NOTE: RestSharp for .Net Core creates a new socket for each api call, which can lead to a socket exhaustion problem. See RestSharp#1406.
Generate the DLL using your preferred tool (e.g. dotnet build)
Then include the DLL (under the bin folder) in the C# project, and use the namespaces:
using OneSignalApi.Api;
using OneSignalApi.Client;
using OneSignalApi.Model;To use the API client with a HTTP proxy, setup a System.Net.WebProxy
Configuration c = new Configuration();
System.Net.WebProxy webProxy = new System.Net.WebProxy("http://myProxyUrl:80/");
webProxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
c.Proxy = webProxy;using System.Collections.Generic;
using System.Diagnostics;
using OneSignalApi.Api;
using OneSignalApi.Client;
using OneSignalApi.Model;
namespace Example
{
public class Example
{
public static void Main()
{
// Configure configuration with organization_api_key Bearer token for authorization to access endpoints
// that require the OneSignal Organization API Key.
var orgConfig = new Configuration();
orgConfig.BasePath = "https://api.onesignal.com";
orgConfig.AccessToken = "YOUR_ORGANIZATION_API_KEY"; // Organization key is only required for creating new apps and other top-level endpoints
var userInstance = new DefaultApi(orgConfig);
try
{
// Create a new app
var app = new App(name: "Sample App");
var result = userInstance.CreateApp(app);
Debug.WriteLine(result);
}
catch (ApiException e)
{
Debug.Print("Exception when calling DefaultApi.CreateApp: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
}
// Configure configuration with rest_api_key Bearer token for authorization to access endpoints
// that require the OneSignal App REST API Key.
var appConfig = new Configuration();
appConfig.BasePath = "https://api.onesignal.com";
appConfig.AccessToken = "YOUR_REST_API_KEY"; // App REST API key required for most endpoints
var appInstance = new DefaultApi(appConfig);
var appId = "appId_example"; // string |
var notificationId = "notificationId_example"; // string |
try
{
// Stop a scheduled or currently outgoing notification
var result = appInstance.CancelNotification(appId, notificationId);
Debug.WriteLine(result);
}
catch (ApiException e)
{
Debug.Print("Exception when calling DefaultApi.CancelNotification: " + e.Message );
Debug.Print("Status Code: "+ e.ErrorCode);
Debug.Print(e.StackTrace);
}
}
}
}All URIs are relative to https://api.onesignal.com
| Class | Method | HTTP request | Description |
|---|---|---|---|
| DefaultApi | CancelNotification | DELETE /notifications/{notification_id} | Stop a scheduled or currently outgoing notification |
| DefaultApi | CopyTemplateToApp | POST /templates/{template_id}/copy_to_app | Copy template to another app |
| DefaultApi | CreateAlias | PATCH /apps/{app_id}/users/by/{alias_label}/{alias_id}/identity | |
| DefaultApi | CreateAliasBySubscription | PATCH /apps/{app_id}/subscriptions/{subscription_id}/user/identity | |
| DefaultApi | CreateApiKey | POST /apps/{app_id}/auth/tokens | Create API key |
| DefaultApi | CreateApp | POST /apps | Create an app |
| DefaultApi | CreateCustomEvents | POST /apps/{app_id}/integrations/custom_events | Create custom events |
| DefaultApi | CreateNotification | POST /notifications | Create notification |
| DefaultApi | CreateSegment | POST /apps/{app_id}/segments | Create Segment |
| DefaultApi | CreateSubscription | POST /apps/{app_id}/users/by/{alias_label}/{alias_id}/subscriptions | |
| DefaultApi | CreateTemplate | POST /templates | Create template |
| DefaultApi | CreateUser | POST /apps/{app_id}/users | |
| DefaultApi | DeleteAlias | DELETE /apps/{app_id}/users/by/{alias_label}/{alias_id}/identity/{alias_label_to_delete} | |
| DefaultApi | DeleteApiKey | DELETE /apps/{app_id}/auth/tokens/{token_id} | Delete API key |
| DefaultApi | DeleteSegment | DELETE /apps/{app_id}/segments/{segment_id} | Delete Segment |
| DefaultApi | DeleteSubscription | DELETE /apps/{app_id}/subscriptions/{subscription_id} | |
| DefaultApi | DeleteTemplate | DELETE /templates/{template_id} | Delete template |
| DefaultApi | DeleteUser | DELETE /apps/{app_id}/users/by/{alias_label}/{alias_id} | |
| DefaultApi | ExportEvents | POST /notifications/{notification_id}/export_events?app_id={app_id} | Export CSV of Events |
| DefaultApi | ExportSubscriptions | POST /players/csv_export?app_id={app_id} | Export CSV of Subscriptions |
| DefaultApi | GetAliases | GET /apps/{app_id}/users/by/{alias_label}/{alias_id}/identity | |
| DefaultApi | GetAliasesBySubscription | GET /apps/{app_id}/subscriptions/{subscription_id}/user/identity | |
| DefaultApi | GetApp | GET /apps/{app_id} | View an app |
| DefaultApi | GetApps | GET /apps | View apps |
| DefaultApi | GetNotification | GET /notifications/{notification_id} | View notification |
| DefaultApi | GetNotificationHistory | POST /notifications/{notification_id}/history | Notification History |
| DefaultApi | GetNotifications | GET /notifications | View notifications |
| DefaultApi | GetOutcomes | GET /apps/{app_id}/outcomes | View Outcomes |
| DefaultApi | GetSegments | GET /apps/{app_id}/segments | Get Segments |
| DefaultApi | GetUser | GET /apps/{app_id}/users/by/{alias_label}/{alias_id} | |
| DefaultApi | RotateApiKey | POST /apps/{app_id}/auth/tokens/{token_id}/rotate | Rotate API key |
| DefaultApi | StartLiveActivity | POST /apps/{app_id}/activities/activity/{activity_type} | Start Live Activity |
| DefaultApi | TransferSubscription | PATCH /apps/{app_id}/subscriptions/{subscription_id}/owner | |
| DefaultApi | UnsubscribeEmailWithToken | POST /apps/{app_id}/notifications/{notification_id}/unsubscribe | Unsubscribe with token |
| DefaultApi | UpdateApiKey | PATCH /apps/{app_id}/auth/tokens/{token_id} | Update API key |
| DefaultApi | UpdateApp | PUT /apps/{app_id} | Update an app |
| DefaultApi | UpdateLiveActivity | POST /apps/{app_id}/live_activities/{activity_id}/notifications | Update a Live Activity via Push |
| DefaultApi | UpdateSubscription | PATCH /apps/{app_id}/subscriptions/{subscription_id} | |
| DefaultApi | UpdateSubscriptionByToken | PATCH /apps/{app_id}/subscriptions_by_token/{token_type}/{token} | Update subscription by token |
| DefaultApi | UpdateTemplate | PATCH /templates/{template_id} | Update template |
| DefaultApi | UpdateUser | PATCH /apps/{app_id}/users/by/{alias_label}/{alias_id} | |
| DefaultApi | ViewApiKeys | GET /apps/{app_id}/auth/tokens | View API keys |
| DefaultApi | ViewTemplate | GET /templates/{template_id} | View template |
| DefaultApi | ViewTemplates | GET /templates | View templates |
- Model.ApiKeyToken
- Model.ApiKeyTokensListResponse
- Model.App
- Model.BasicNotification
- Model.BasicNotificationAllOf
- Model.BasicNotificationAllOfAndroidBackgroundLayout
- Model.Button
- Model.CopyTemplateRequest
- Model.CreateApiKeyRequest
- Model.CreateApiKeyResponse
- Model.CreateNotificationSuccessResponse
- Model.CreateSegmentConflictResponse
- Model.CreateSegmentSuccessResponse
- Model.CreateTemplateRequest
- Model.CreateUserConflictResponse
- Model.CreateUserConflictResponseErrorsInner
- Model.CreateUserConflictResponseErrorsItemsMeta
- Model.CustomEvent
- Model.CustomEventsRequest
- Model.DeliveryData
- Model.ExportEventsSuccessResponse
- Model.ExportSubscriptionsRequestBody
- Model.ExportSubscriptionsSuccessResponse
- Model.Filter
- Model.FilterExpression
- Model.GenericError
- Model.GenericSuccessBoolResponse
- Model.GetNotificationHistoryRequestBody
- Model.GetSegmentsSuccessResponse
- Model.LanguageStringMap
- Model.Notification
- Model.NotificationAllOf
- Model.NotificationHistorySuccessResponse
- Model.NotificationSlice
- Model.NotificationTarget
- Model.NotificationWithMeta
- Model.NotificationWithMetaAllOf
- Model.Operator
- Model.OutcomeData
- Model.OutcomesData
- Model.PlatformDeliveryData
- Model.PlatformDeliveryDataEmailAllOf
- Model.PlatformDeliveryDataSmsAllOf
- Model.PropertiesBody
- Model.PropertiesDeltas
- Model.PropertiesObject
- Model.Purchase
- Model.RateLimitError
- Model.Segment
- Model.SegmentData
- Model.SegmentNotificationTarget
- Model.StartLiveActivityRequest
- Model.StartLiveActivitySuccessResponse
- Model.Subscription
- Model.SubscriptionBody
- Model.SubscriptionNotificationTarget
- Model.TemplateResource
- Model.TemplatesListResponse
- Model.TransferSubscriptionRequestBody
- Model.UpdateApiKeyRequest
- Model.UpdateLiveActivityRequest
- Model.UpdateLiveActivitySuccessResponse
- Model.UpdateTemplateRequest
- Model.UpdateUserRequest
- Model.User
- Model.UserIdentityBody
- Model.WebButton
- Type: Bearer Authentication
- Type: Bearer Authentication