### Installation and Configuration Source: https://context7.com/onesignal/onesignal-dotnet-api/llms.txt Instructions on how to install the OneSignal C# SDK via NuGet and configure authentication using API keys. ```APIDOC ## Installation and Configuration Install the SDK via NuGet and configure authentication with your REST API key for app-level operations or Organization API key for organization-level endpoints. ```csharp // Install via .NET CLI // dotnet add package OneSignalApi using OneSignalApi.Api; using OneSignalApi.Client; using OneSignalApi.Model; // Configure with REST API Key (for most endpoints) var config = new Configuration(); config.BasePath = "https://api.onesignal.com"; config.AccessToken = "YOUR_REST_API_KEY"; // From Settings > Keys & IDs var client = new DefaultApi(config); // For organization-level endpoints (creating apps, etc.) var orgConfig = new Configuration(); orgConfig.BasePath = "https://api.onesignal.com"; orgConfig.AccessToken = "YOUR_ORGANIZATION_API_KEY"; // From Organization Settings var orgClient = new DefaultApi(orgConfig); ``` ``` -------------------------------- ### StartLiveActivitySuccessResponse Source: https://github.com/onesignal/onesignal-dotnet-api/blob/main/docs/StartLiveActivitySuccessResponse.md Represents a successful response when starting a live activity. ```APIDOC ## StartLiveActivitySuccessResponse ### Description This object represents a successful response from an API call to start a live activity. ### Properties #### NotificationId (string) - Optional - The unique identifier for the notification sent. ### Response Example ```json { "notification_id": "a1b2c3d4-e5f6-7890-1234-567890abcdef" } ``` ``` -------------------------------- ### View Template Example Source: https://github.com/onesignal/onesignal-dotnet-api/blob/main/docs/DefaultApi.md Demonstrates how to fetch a single template by its ID using the DefaultApi client. ```csharp using System.Collections.Generic; using System.Diagnostics; using OneSignalApi.Api; using OneSignalApi.Client; using OneSignalApi.Model; namespace Example { public class ViewTemplateExample { public static void Main() { Configuration config = new Configuration(); config.BasePath = "https://api.onesignal.com"; // Configure Bearer token for authorization: rest_api_key config.AccessToken = "YOUR_BEARER_TOKEN"; var apiInstance = new DefaultApi(config); var templateId = "templateId_example"; // string | var appId = "appId_example"; // string | try { // View template TemplateResource result = apiInstance.ViewTemplate(templateId, appId); Debug.WriteLine(result); } catch (ApiException e) { Debug.Print("Exception when calling DefaultApi.ViewTemplate: " + e.Message ); Debug.Print("Status Code: "+ e.ErrorCode); Debug.Print(e.StackTrace); } } } } ``` -------------------------------- ### Install OneSignal C# API Package Source: https://github.com/onesignal/onesignal-dotnet-api/blob/main/README.md Use the dotnet CLI to add the OneSignalApi package to your project. ```bash dotnet add package OneSignalApi ``` -------------------------------- ### GET /apps Source: https://context7.com/onesignal/onesignal-dotnet-api/llms.txt Lists all OneSignal apps in the organization. ```APIDOC ## GET /apps ### Description View all OneSignal apps in your organization. ``` -------------------------------- ### View API Keys Example Source: https://github.com/onesignal/onesignal-dotnet-api/blob/main/docs/DefaultApi.md Demonstrates how to retrieve API keys for a specific OneSignal app using the DefaultApi client. ```csharp using System.Collections.Generic; using System.Diagnostics; using OneSignalApi.Api; using OneSignalApi.Client; using OneSignalApi.Model; namespace Example { public class ViewApiKeysExample { public static void Main() { Configuration config = new Configuration(); config.BasePath = "https://api.onesignal.com"; // Configure Bearer token for authorization: organization_api_key config.AccessToken = "YOUR_BEARER_TOKEN"; var apiInstance = new DefaultApi(config); var appId = "appId_example"; // string | try { // View API keys ApiKeyTokensListResponse result = apiInstance.ViewApiKeys(appId); Debug.WriteLine(result); } catch (ApiException e) { Debug.Print("Exception when calling DefaultApi.ViewApiKeys: " + e.Message ); Debug.Print("Status Code: "+ e.ErrorCode); Debug.Print(e.StackTrace); } } } } ``` -------------------------------- ### View Templates Example in C# Source: https://github.com/onesignal/onesignal-dotnet-api/blob/main/docs/DefaultApi.md Demonstrates how to initialize the OneSignal API client with a bearer token and call the ViewTemplates method to retrieve app templates. ```csharp using System.Collections.Generic; using System.Diagnostics; using OneSignalApi.Api; using OneSignalApi.Client; using OneSignalApi.Model; namespace Example { public class ViewTemplatesExample { public static void Main() { Configuration config = new Configuration(); config.BasePath = "https://api.onesignal.com"; // Configure Bearer token for authorization: rest_api_key config.AccessToken = "YOUR_BEARER_TOKEN"; var apiInstance = new DefaultApi(config); var appId = "appId_example"; // string | Your OneSignal App ID in UUID v4 format. var limit = 50; // int? | Maximum number of templates. Default and max is 50. (optional) (default to 50) var offset = 0; // int? | Pagination offset. (optional) (default to 0) var channel = "push"; // string | Filter by delivery channel. (optional) try { // View templates TemplatesListResponse result = apiInstance.ViewTemplates(appId, limit, offset, channel); Debug.WriteLine(result); } catch (ApiException e) { Debug.Print("Exception when calling DefaultApi.ViewTemplates: " + e.Message ); Debug.Print("Status Code: "+ e.ErrorCode); Debug.Print(e.StackTrace); } } } } ``` -------------------------------- ### GET /apps Source: https://github.com/onesignal/onesignal-dotnet-api/blob/main/docs/DefaultApi.md Retrieves a list of all current OneSignal applications. ```APIDOC ## GET /apps ### Description View the details of all of your current OneSignal apps. ### Method GET ### Endpoint /apps ### Response #### Success Response (200) - **List** (array) - A list of application objects #### Error Handling - 400: Bad Request - 429: Rate Limit Exceeded ``` -------------------------------- ### View All Apps with OneSignal .NET API Source: https://github.com/onesignal/onesignal-dotnet-api/blob/main/docs/DefaultApi.md This example demonstrates how to fetch a list of all your OneSignal apps. It requires the organization API key for authentication. ```csharp using System.Collections.Generic; using System.Diagnostics; using OneSignalApi.Api; using OneSignalApi.Client; using OneSignalApi.Model; namespace Example { public class GetAppsExample { public static void Main() { Configuration config = new Configuration(); config.BasePath = "https://api.onesignal.com"; // Configure Bearer token for authorization: organization_api_key config.AccessToken = "YOUR_BEARER_TOKEN"; var apiInstance = new DefaultApi(config); try { // View apps List result = apiInstance.GetApps(); Debug.WriteLine(result); } catch (ApiException e) { Debug.Print("Exception when calling DefaultApi.GetApps: " + e.Message ); Debug.Print("Status Code: "+ e.ErrorCode); Debug.Print(e.StackTrace); } } } } ``` -------------------------------- ### Create Message Template Source: https://github.com/onesignal/onesignal-dotnet-api/blob/main/docs/DefaultApi.md This example demonstrates how to create a reusable message template for push, email, and SMS channels. Configure the Bearer token for authentication. ```csharp using System.Collections.Generic; using System.Diagnostics; using OneSignalApi.Api; using OneSignalApi.Client; using OneSignalApi.Model; namespace Example { public class CreateTemplateExample { public static void Main() { Configuration config = new Configuration(); config.BasePath = "https://api.onesignal.com"; // Configure Bearer token for authorization: rest_api_key config.AccessToken = "YOUR_BEARER_TOKEN"; var apiInstance = new DefaultApi(config); var createTemplateRequest = new CreateTemplateRequest(); // CreateTemplateRequest | try { // Create template TemplateResource result = apiInstance.CreateTemplate(createTemplateRequest); Debug.WriteLine(result); } catch (ApiException e) { Debug.Print("Exception when calling DefaultApi.CreateTemplate: " + e.Message ); Debug.Print("Status Code: "+ e.ErrorCode); Debug.Print(e.StackTrace); } } } } ``` -------------------------------- ### Transfer Subscription Example Source: https://github.com/onesignal/onesignal-dotnet-api/blob/main/docs/DefaultApi.md Demonstrates how to transfer a subscription to a user using the DefaultApi client. Requires a valid Bearer token for the rest_api_key authorization. ```csharp using System.Collections.Generic; using System.Diagnostics; using OneSignalApi.Api; using OneSignalApi.Client; using OneSignalApi.Model; namespace Example { public class TransferSubscriptionExample { public static void Main() { Configuration config = new Configuration(); config.BasePath = "https://api.onesignal.com"; // Configure Bearer token for authorization: rest_api_key config.AccessToken = "YOUR_BEARER_TOKEN"; var apiInstance = new DefaultApi(config); var appId = "appId_example"; // string | var subscriptionId = "subscriptionId_example"; // string | var transferSubscriptionRequestBody = new TransferSubscriptionRequestBody(); // TransferSubscriptionRequestBody | try { UserIdentityBody result = apiInstance.TransferSubscription(appId, subscriptionId, transferSubscriptionRequestBody); Debug.WriteLine(result); } catch (ApiException e) { Debug.Print("Exception when calling DefaultApi.TransferSubscription: " + e.Message ); Debug.Print("Status Code: "+ e.ErrorCode); Debug.Print(e.StackTrace); } } } } ``` -------------------------------- ### POST /apps/{app_id}/live_activities/{activity_type}/start Source: https://context7.com/onesignal/onesignal-dotnet-api/llms.txt Starts a new iOS Live Activity remotely via push notifications. ```APIDOC ## POST /apps/{app_id}/live_activities/{activity_type}/start ### Description Starts a Live Activity on iOS devices remotely via push notifications. ### Parameters #### Path Parameters - **appId** (string) - Required - The OneSignal App ID. - **activityType** (string) - Required - Matches your Swift ActivityAttributes name. #### Request Body - **Event** (string) - Required - The event type (e.g., "start"). - **EventAttributes** (Dictionary) - Optional - Attributes for the event. - **ContentState** (Dictionary) - Required - The initial content state of the activity. - **IncludeAliases** (Dictionary>) - Optional - Aliases to target specific users. ### Response #### Success Response (200) - **NotificationId** (string) - The ID of the notification triggered. ``` -------------------------------- ### POST /api/v1/live-activities Source: https://github.com/onesignal/onesignal-dotnet-api/blob/main/docs/StartLiveActivityRequest.md Initiates a live activity with the specified details. This endpoint requires authentication and is used to start a new live activity session. ```APIDOC ## POST /api/v1/live-activities ### Description Initiates a live activity with the specified details. This endpoint requires authentication and is used to start a new live activity session. ### Method POST ### Endpoint /api/v1/live-activities ### Request Body - **Name** (string) - Required - An internal name to assist with your campaign organization. This does not get displayed in the message itself. - **Event** (string) - Optional - The event type for the live activity. Defaults to 'start'. - **ActivityId** (string) - Required - Set a unique activity_id to track and manage the Live Activity. - **EventAttributes** (Object) - Optional - Default/static data to initialize the Live Activity upon start. - **EventUpdates** (Object) - Optional - Dynamic content used to update the running Live Activity at start. Must match the ContentState interface defined in your app. - **Contents** (LanguageStringMap) - Optional - Content for the live activity in different languages. - **Headings** (LanguageStringMap) - Optional - Headings for the live activity in different languages. - **StaleDate** (int) - Optional - Accepts Unix timestamp in seconds. When time reaches the configured stale date, the system considers the Live Activity out of date, and the ActivityState of the Live Activity changes to ActivityState.stale. - **Priority** (int) - Optional - Delivery priority through the push provider (APNs). Pass 10 for higher priority notifications, or 5 for lower priority notifications. Lower priority notifications are sent based on the power considerations of the end user's device. If not set, defaults to 10. - **IosRelevanceScore** (decimal?) - Optional - iOS 15+. A score to indicate how a notification should be displayed when grouped. Use a float between 0-1. - **IdempotencyKey** (string) - Optional - Correlation and idempotency key. A request received with this parameter will first look for another notification with the same idempotency key. If one exists, a notification will not be sent, and result of the previous operation will instead be returned. This key is only idempotent for 30 days. - **IncludeAliases** (Dictionary>) - Optional - Target specific users by aliases assigned via API. Not compatible with any other targeting parameters. REQUIRED: REST API Key Authentication. Limit of 2,000 entries per REST API call. - **IncludeSubscriptionIds** (List) - Optional - Specific subscription ids to target. Not compatible with other targeting parameters. - **IncludedSegments** (List) - Optional - Segment names to include. Only compatible with excluded_segments. - **ExcludedSegments** (List) - Optional - Segment names to exclude. Only compatible with included_segments. - **Filters** (List) - Optional - Filtering criteria for targeting users. ### Request Example ```json { "Name": "My Live Activity", "ActivityId": "unique-activity-123", "EventAttributes": { "status": "starting" }, "Contents": { "en": "Your order is on its way!" }, "Headings": { "en": "Order Update" } } ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier for the created live activity. - **activity_id** (string) - The activity ID provided in the request. - **status** (string) - The current status of the live activity. #### Response Example ```json { "id": "a1b2c3d4-e5f6-7890-1234-567890abcdef", "activity_id": "unique-activity-123", "status": "started" } ``` ``` -------------------------------- ### Start iOS Live Activity Source: https://context7.com/onesignal/onesignal-dotnet-api/llms.txt Initiates a Live Activity on iOS devices. Ensure the activityType matches the Swift ActivityAttributes name defined in your iOS project. ```csharp var liveActivityRequest = new StartLiveActivityRequest { Event = "start", EventAttributes = new Dictionary { { "orderNumber", "12345" }, { "estimatedDelivery", "30 minutes" } }, ContentState = new Dictionary { { "status", "preparing" }, { "progress", 0.25 } }, IncludeAliases = new Dictionary> { { "external_id", new List { "user_12345" } } } }; try { StartLiveActivitySuccessResponse result = client.StartLiveActivity( appId: "YOUR_APP_ID", activityType: "DeliveryTracker", // Matches your Swift ActivityAttributes name startLiveActivityRequest: liveActivityRequest ); Console.WriteLine($"Live Activity started: {result.NotificationId}"); } catch (ApiException e) { Console.WriteLine("Error: " + e.Message); } ``` -------------------------------- ### Live Activity API Source: https://github.com/onesignal/onesignal-dotnet-api/blob/main/docs/DefaultApi.md Endpoints for managing Live Activities, including starting and updating them. ```APIDOC ## POST /apps/{app_id}/activities/activity/{activity_type} ### Description Start Live Activity. ### Method POST ### Endpoint /apps/{app_id}/activities/activity/{activity_type} ## POST /apps/{app_id}/live_activities/{activity_id}/notifications ### Description Update a Live Activity via Push. ### Method POST ### Endpoint /apps/{app_id}/live_activities/{activity_id}/notifications ``` -------------------------------- ### Configure OneSignal API Client Source: https://github.com/onesignal/onesignal-dotnet-api/blob/main/README.md Initialize the OneSignal API client with your REST API key and base path. Store API keys securely, for example, in environment variables. ```csharp 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); ``` -------------------------------- ### CreateAliasBySubscription C# Example Source: https://github.com/onesignal/onesignal-dotnet-api/blob/main/docs/DefaultApi.md Upserts aliases for a user identified by their subscription ID. Ensure the subscription ID is valid before making the request. ```csharp using System.Collections.Generic; using System.Diagnostics; using OneSignalApi.Api; using OneSignalApi.Client; using OneSignalApi.Model; namespace Example { public class CreateAliasBySubscriptionExample { public static void Main() { Configuration config = new Configuration(); config.BasePath = "https://api.onesignal.com"; // Configure Bearer token for authorization: rest_api_key config.AccessToken = "YOUR_BEARER_TOKEN"; var apiInstance = new DefaultApi(config); var appId = "appId_example"; // string | var subscriptionId = "subscriptionId_example"; // string | var userIdentityBody = new UserIdentityBody(); // UserIdentityBody | try { UserIdentityBody result = apiInstance.CreateAliasBySubscription(appId, subscriptionId, userIdentityBody); Debug.WriteLine(result); } catch (ApiException e) { Debug.Print("Exception when calling DefaultApi.CreateAliasBySubscription: " + e.Message ); Debug.Print("Status Code: "+ e.ErrorCode); Debug.Print(e.StackTrace); } } } } ``` -------------------------------- ### Start Live Activity Source: https://github.com/onesignal/onesignal-dotnet-api/blob/main/docs/DefaultApi.md Initiate a Live Activity on iOS devices using OneSignal's REST API. Ensure your OneSignal app ID and activity type are correctly configured. ```csharp using System.Collections.Generic; using System.Diagnostics; using OneSignalApi.Api; using OneSignalApi.Client; using OneSignalApi.Model; namespace Example { public class StartLiveActivityExample { public static void Main() { Configuration config = new Configuration(); config.BasePath = "https://api.onesignal.com"; // Configure Bearer token for authorization: rest_api_key config.AccessToken = "YOUR_BEARER_TOKEN"; var apiInstance = new DefaultApi(config); var appId = "appId_example"; // string | Your OneSignal App ID in UUID v4 format. var activityType = "activityType_example"; // string | The name of the Live Activity defined in your app. This should match the attributes struct used in your app's Live Activity implementation. var startLiveActivityRequest = new StartLiveActivityRequest(); // StartLiveActivityRequest | try { // Start Live Activity StartLiveActivitySuccessResponse result = apiInstance.StartLiveActivity(appId, activityType, startLiveActivityRequest); Debug.WriteLine(result); } catch (ApiException e) { Debug.Print("Exception when calling DefaultApi.StartLiveActivity: " + e.Message ); Debug.Print("Status Code: "+ e.ErrorCode); Debug.Print(e.StackTrace); } } } } ``` -------------------------------- ### GetAliasesBySubscription C# Example Source: https://github.com/onesignal/onesignal-dotnet-api/blob/main/docs/DefaultApi.md Retrieves all aliases for a user identified by their subscription ID. Ensure the Bearer token is configured correctly in the client instance. ```csharp using System.Collections.Generic; using System.Diagnostics; using OneSignalApi.Api; using OneSignalApi.Client; using OneSignalApi.Model; namespace Example { public class GetAliasesBySubscriptionExample { public static void Main() { Configuration config = new Configuration(); config.BasePath = "https://api.onesignal.com"; // Configure Bearer token for authorization: rest_api_key config.AccessToken = "YOUR_BEARER_TOKEN"; var apiInstance = new DefaultApi(config); var appId = "appId_example"; // string | var subscriptionId = "subscriptionId_example"; // string | try { UserIdentityBody result = apiInstance.GetAliasesBySubscription(appId, subscriptionId); Debug.WriteLine(result); } catch (ApiException e) { Debug.Print("Exception when calling DefaultApi.GetAliasesBySubscription: " + e.Message ); Debug.Print("Status Code: "+ e.ErrorCode); Debug.Print(e.StackTrace); } } } } ``` -------------------------------- ### GET /users/by/{alias_label}/{alias_id} Source: https://context7.com/onesignal/onesignal-dotnet-api/llms.txt Retrieves user information including properties, aliases, and subscriptions. ```APIDOC ## GET /users/by/{alias_label}/{alias_id} ### Description Get a user's properties, aliases, and subscriptions by any alias. ### Method GET ### Parameters #### Path Parameters - **appId** (string) - Required - The unique identifier for the application. - **aliasLabel** (string) - Required - The label of the alias (e.g., external_id). - **aliasId** (string) - Required - The value of the alias. ``` -------------------------------- ### POST /apps/{appId}/live_activities/{activityType}/enter Source: https://github.com/onesignal/onesignal-dotnet-api/blob/main/docs/DefaultApi.md Remotely start a Live Activity on iOS devices via OneSignal’s REST API. ```APIDOC ## POST /apps/{appId}/live_activities/{activityType}/enter ### Description Remotely start a Live Activity on iOS devices via OneSignal’s REST API. ### Method POST ### Endpoint /apps/{appId}/live_activities/{activityType}/enter ### Parameters #### Path Parameters - **appId** (string) - Required - Your OneSignal App ID in UUID v4 format. - **activityType** (string) - Required - The name of the Live Activity defined in your app. #### Request Body - **startLiveActivityRequest** (StartLiveActivityRequest) - Required ### Response #### Success Response (200) - **StartLiveActivitySuccessResponse** (object) - Response indicating the Live Activity has started. ``` -------------------------------- ### GetAliases C# Example Source: https://github.com/onesignal/onesignal-dotnet-api/blob/main/docs/DefaultApi.md Retrieves all aliases for a user identified by a specific label and ID. Requires a valid Bearer token for the rest_api_key authorization. ```csharp using System.Collections.Generic; using System.Diagnostics; using OneSignalApi.Api; using OneSignalApi.Client; using OneSignalApi.Model; namespace Example { public class GetAliasesExample { public static void Main() { Configuration config = new Configuration(); config.BasePath = "https://api.onesignal.com"; // Configure Bearer token for authorization: rest_api_key config.AccessToken = "YOUR_BEARER_TOKEN"; var apiInstance = new DefaultApi(config); var appId = "appId_example"; // string | var aliasLabel = "aliasLabel_example"; // string | var aliasId = "aliasId_example"; // string | try { UserIdentityBody result = apiInstance.GetAliases(appId, aliasLabel, aliasId); Debug.WriteLine(result); } catch (ApiException e) { Debug.Print("Exception when calling DefaultApi.GetAliases: " + e.Message ); Debug.Print("Status Code: "+ e.ErrorCode); Debug.Print(e.StackTrace); } } } } ``` -------------------------------- ### CreateAlias C# Example Source: https://github.com/onesignal/onesignal-dotnet-api/blob/main/docs/DefaultApi.md Upserts aliases for a user identified by alias label and ID. Requires a configured DefaultApi instance with a valid Bearer token. ```csharp using System.Collections.Generic; using System.Diagnostics; using OneSignalApi.Api; using OneSignalApi.Client; using OneSignalApi.Model; namespace Example { public class CreateAliasExample { public static void Main() { Configuration config = new Configuration(); config.BasePath = "https://api.onesignal.com"; // Configure Bearer token for authorization: rest_api_key config.AccessToken = "YOUR_BEARER_TOKEN"; var apiInstance = new DefaultApi(config); var appId = "appId_example"; // string | var aliasLabel = "aliasLabel_example"; // string | var aliasId = "aliasId_example"; // string | var userIdentityBody = new UserIdentityBody(); // UserIdentityBody | try { UserIdentityBody result = apiInstance.CreateAlias(appId, aliasLabel, aliasId, userIdentityBody); Debug.WriteLine(result); } catch (ApiException e) { Debug.Print("Exception when calling DefaultApi.CreateAlias: " + e.Message ); Debug.Print("Status Code: "+ e.ErrorCode); Debug.Print(e.StackTrace); } } } } ``` -------------------------------- ### Update Live Activity via Push Notification Source: https://github.com/onesignal/onesignal-dotnet-api/blob/main/docs/DefaultApi.md This example demonstrates how to update a specific live activity using its app ID and activity ID. A valid REST API key is required for authentication. ```csharp using System.Collections.Generic; using System.Diagnostics; using OneSignalApi.Api; using OneSignalApi.Client; using OneSignalApi.Model; namespace Example { public class UpdateLiveActivityExample { public static void Main() { Configuration config = new Configuration(); config.BasePath = "https://api.onesignal.com"; // Configure Bearer token for authorization: rest_api_key config.AccessToken = "YOUR_BEARER_TOKEN"; var apiInstance = new DefaultApi(config); var appId = "appId_example"; // string | The OneSignal App ID for your app. Available in Keys & IDs. var activityId = "activityId_example"; // string | Live Activity record ID var updateLiveActivityRequest = new UpdateLiveActivityRequest(); // UpdateLiveActivityRequest | try { // Update a Live Activity via Push UpdateLiveActivitySuccessResponse result = apiInstance.UpdateLiveActivity(appId, activityId, updateLiveActivityRequest); Debug.WriteLine(result); } catch (ApiException e) { Debug.Print("Exception when calling DefaultApi.UpdateLiveActivity: " + e.Message ); Debug.Print("Status Code: "+ e.ErrorCode); Debug.Print(e.StackTrace); } } } } ``` -------------------------------- ### GET /apps/{appId}/users/by/{aliasLabel}/{aliasId} Source: https://github.com/onesignal/onesignal-dotnet-api/blob/main/docs/DefaultApi.md Retrieves a user's properties, aliases, and subscriptions based on their alias label and ID. ```APIDOC ## GET /apps/{appId}/users/by/{aliasLabel}/{aliasId} ### Description Returns the User’s properties, Aliases, and Subscriptions. ### Method GET ### Endpoint /apps/{appId}/users/by/{aliasLabel}/{aliasId} ### Parameters #### Path Parameters - **appId** (string) - Required - The OneSignal App ID. - **aliasLabel** (string) - Required - The alias label. - **aliasId** (string) - Required - The alias ID. ### Response #### Success Response (200) - **User** (object) - The user object containing properties, aliases, and subscriptions. ``` -------------------------------- ### Get Notification History using .NET SDK Source: https://github.com/onesignal/onesignal-dotnet-api/blob/main/docs/DefaultApi.md This example demonstrates how to retrieve the history of devices that received a specific notification. Note that this feature requires a OneSignal Paid Plan and must be called within 7 days of the message being sent. ```csharp using System.Collections.Generic; using System.Diagnostics; using OneSignalApi.Api; using OneSignalApi.Client; using OneSignalApi.Model; namespace Example { public class GetNotificationHistoryExample { public static void Main() { Configuration config = new Configuration(); config.BasePath = "https://api.onesignal.com"; // Configure Bearer token for authorization: rest_api_key config.AccessToken = "YOUR_BEARER_TOKEN"; var apiInstance = new DefaultApi(config); var notificationId = "notificationId_example"; // string | The "id" of the message found in the Notification object var getNotificationHistoryRequestBody = new GetNotificationHistoryRequestBody(); // GetNotificationHistoryRequestBody | try { // Notification History NotificationHistorySuccessResponse result = apiInstance.GetNotificationHistory(notificationId, getNotificationHistoryRequestBody); Debug.WriteLine(result); } catch (ApiException e) { Debug.Print("Exception when calling DefaultApi.GetNotificationHistory: " + e.Message ); Debug.Print("Status Code: "+ e.ErrorCode); Debug.Print(e.StackTrace); } } } } ``` -------------------------------- ### GET /notifications/{notificationId} - View Single Notification Source: https://context7.com/onesignal/onesignal-dotnet-api/llms.txt Get detailed information about a specific notification including delivery statistics and outcomes. ```APIDOC ## GET /notifications/{notificationId} - View Single Notification ### Description Get detailed information about a specific notification including delivery statistics and outcomes. ### Method GET ### Endpoint /notifications/{notificationId} ### Parameters #### Path Parameters - **notificationId** (string) - Required - The unique ID of the notification. #### Query Parameters - **appId** (string) - Required - The application ID. ### Request Example ```csharp NotificationWithMeta notification = client.GetNotification( appId: "YOUR_APP_ID", notificationId: "notification-uuid-here" ); ``` ### Response #### Success Response (200) - **Id** (string) - The notification ID. - **Contents** (LanguageStringMap) - The notification content. - **Headings** (LanguageStringMap) - The notification headings. - **Successful** (int) - The number of successful deliveries. - **Failed** (int) - The number of failed deliveries. - **Remaining** (int) - The number of notifications remaining to be delivered. - **QueuedAt** (DateTime) - The timestamp when the notification was queued. - **CompletedAt** (DateTime) - The timestamp when the notification delivery was completed. #### Response Example ```json { "id": "notification-uuid-here", "contents": {"en": "Your notification content"}, "headings": {"en": "Notification Heading"}, "successful": 99, "failed": 1, "remaining": 0, "queuedAt": "2023-10-27T10:00:00Z", "completedAt": "2023-10-27T10:05:00Z" } ``` ``` -------------------------------- ### Build Release Configuration Source: https://github.com/onesignal/onesignal-dotnet-api/blob/main/RELEASE_INSTRUCTIONS.md Builds the project in Release configuration. Ensure you are in the project root directory. ```bash dotnet build --configuration Release ``` -------------------------------- ### GET /notifications/{notificationId}/history Source: https://github.com/onesignal/onesignal-dotnet-api/blob/main/docs/DefaultApi.md Retrieve the history of a specific notification. ```APIDOC ## GET /notifications/{notificationId}/history ### Description Retrieve the history of a specific notification by its ID. ### Method GET ### Endpoint /notifications/{notificationId}/history ### Parameters #### Path Parameters - **notificationId** (string) - Required - The "id" of the message found in the Notification object #### Request Body - **getNotificationHistoryRequestBody** (GetNotificationHistoryRequestBody) - Required - Request body containing history parameters ### Response #### Success Response (200) - **NotificationHistorySuccessResponse** (object) - Returns the notification history details. ``` -------------------------------- ### GET /notifications Source: https://github.com/onesignal/onesignal-dotnet-api/blob/main/docs/DefaultApi.md View the details of multiple notifications for a specific app. ```APIDOC ## GET /notifications ### Description View the details of multiple notifications. ### Method GET ### Endpoint /notifications ### Parameters #### Query Parameters - **appId** (string) - Required - The app ID that you want to view notifications from - **limit** (int?) - Optional - How many notifications to return. Max is 50. Default is 50. - **offset** (int?) - Optional - Page offset. Default is 0. Results are sorted by queued_at in descending order. - **kind** (int?) - Optional - Kind of notifications returned: * unset - All notification types (default) * 0 - Dashboard only * 1 - API only * 3 - Automated only ### Response #### Success Response (200) - **NotificationSlice** (object) - Returns a slice of notification data. #### Response Example { "example": "NotificationSlice object" } ``` -------------------------------- ### GET /apps/{appId} Source: https://github.com/onesignal/onesignal-dotnet-api/blob/main/docs/DefaultApi.md Retrieves the details of a single OneSignal application. ```APIDOC ## GET /apps/{appId} ### Description View the details of a single OneSignal app. ### Method GET ### Endpoint /apps/{appId} ### Parameters #### Path Parameters - **appId** (string) - Required - An app id ### Response #### Success Response (200) - **App** (object) - The application details object #### Error Handling - 400: Bad Request - 429: Rate Limit Exceeded ``` -------------------------------- ### GET /templates Source: https://context7.com/onesignal/onesignal-dotnet-api/llms.txt Retrieves all message templates with optional channel filtering. ```APIDOC ## GET /templates ### Description Retrieve all message templates with optional channel filtering. ### Parameters #### Path Parameters - **appId** (string) - Required - The application ID. #### Query Parameters - **limit** (int) - Optional - Number of templates to return. - **offset** (int) - Optional - Pagination offset. - **channel** (string) - Optional - Filter by channel (push, email, sms). ``` -------------------------------- ### Create NuGet Package Source: https://github.com/onesignal/onesignal-dotnet-api/blob/main/RELEASE_INSTRUCTIONS.md Creates a NuGet package for the project in Release configuration. This command generates a .nupkg file in the output directory. ```bash dotnet pack --configuration Release ``` -------------------------------- ### GET /segments Source: https://context7.com/onesignal/onesignal-dotnet-api/llms.txt Retrieves a list of all segments defined in the application with pagination support. ```APIDOC ## GET /segments ### Description Retrieve all segments defined in your app with pagination support. ### Parameters #### Path Parameters - **appId** (string) - Required - The application ID. #### Query Parameters - **offset** (int) - Optional - Pagination offset. - **limit** (int) - Optional - Number of segments to return (max 300). ``` -------------------------------- ### GET /apps/{appId}/segments Source: https://github.com/onesignal/onesignal-dotnet-api/blob/main/docs/DefaultApi.md Retrieves an array of segments for a specific OneSignal application. ```APIDOC ## GET /apps/{appId}/segments ### Description Returns an array of segments from an app. ### Method GET ### Endpoint /apps/{appId}/segments ### Parameters #### Path Parameters - **appId** (string) - Required - The OneSignal App ID for your app. #### Query Parameters - **offset** (int?) - Optional - Segments are listed in ascending order of created_at date. offset will omit that number of segments from the beginning of the list. - **limit** (int?) - Optional - The amount of Segments in the response. Maximum 300. ### Response #### Success Response (201) - **GetSegmentsSuccessResponse** (object) - The list of segments. ``` -------------------------------- ### Create or Update a User in C# Source: https://context7.com/onesignal/onesignal-dotnet-api/llms.txt Initializes a new user or updates an existing one if the provided aliases match. Includes configuration for identity, properties, and multiple subscription types. ```csharp var newUser = new User { Identity = new Dictionary { { "external_id", "user_12345" }, { "customer_id", "cust_abc123" } }, Properties = new PropertiesObject { Tags = new Dictionary { { "account_type", "premium" }, { "signup_date", "2024-01-15" } }, Language = "en", Timezone = -18000, // UTC offset in seconds (EST = -5 hours) Country = "US" }, Subscriptions = new List { new Subscription { Type = "Email", Token = "user@example.com", Enabled = true }, new Subscription { Type = "SMS", Token = "+15551234567", Enabled = true } } }; try { User createdUser = client.CreateUser( appId: "YOUR_APP_ID", user: newUser ); Console.WriteLine("User created/updated successfully"); Console.WriteLine($"OneSignal ID: {createdUser.Identity?["onesignal_id"]}"); } catch (ApiException e) { Console.WriteLine("Error: " + e.Message); } ``` -------------------------------- ### GET /apps/{appId}/notifications/{notificationId} Source: https://github.com/onesignal/onesignal-dotnet-api/blob/main/docs/DefaultApi.md Retrieves the details of a specific notification by its ID. ```APIDOC ## GET /apps/{appId}/notifications/{notificationId} ### Description View notification details. ### Method GET ### Endpoint /apps/{appId}/notifications/{notificationId} ### Parameters #### Path Parameters - **appId** (string) - Required - The ID of the application. - **notificationId** (string) - Required - The ID of the notification. ### Response #### Success Response (200) - **NotificationWithMeta** (object) - The notification details. #### Error Responses - **400** - Bad Request - **404** - Not Found - **429** - Rate Limit Exceeded ``` -------------------------------- ### GET /api/v1/users/{appId}/aliases/{subscriptionId} Source: https://github.com/onesignal/onesignal-dotnet-api/blob/main/docs/DefaultApi.md Lists all Aliases for the User identified by subscriptionId. ```APIDOC ## GET /api/v1/users/{appId}/aliases/{subscriptionId} ### Description Lists all Aliases for the User identified by subscriptionId. ### Method GET ### Endpoint /api/v1/users/{appId}/aliases/{subscriptionId} ### Parameters #### Path Parameters - **appId** (string) - Required - The application ID. - **subscriptionId** (string) - Required - The subscription ID. ### Request Example ```csharp // C# example provided in the source text ``` ### Response #### Success Response (200) - **UserIdentityBody** (object) - Contains user identity information. #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### GET /api/v1/users/{appId}/aliases Source: https://github.com/onesignal/onesignal-dotnet-api/blob/main/docs/DefaultApi.md Lists all Aliases for the User identified by aliasLabel and aliasId. ```APIDOC ## GET /api/v1/users/{appId}/aliases ### Description Lists all Aliases for the User identified by aliasLabel and aliasId. ### Method GET ### Endpoint /api/v1/users/{appId}/aliases ### Parameters #### Path Parameters - **appId** (string) - Required - The application ID. - **aliasLabel** (string) - Required - The label of the alias. - **aliasId** (string) - Required - The ID of the alias. ### Request Example ```csharp // C# example provided in the source text ``` ### Response #### Success Response (200) - **UserIdentityBody** (object) - Contains user identity information. #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### GET /apps/{appId}/notifications/{notificationId} Source: https://github.com/onesignal/onesignal-dotnet-api/blob/main/docs/DefaultApi.md Retrieves the details of a single notification and its associated outcomes. ```APIDOC ## GET /apps/{appId}/notifications/{notificationId} ### Description View the details of a single notification and outcomes associated with it. ### Method GET ### Endpoint /apps/{appId}/notifications/{notificationId} ### Parameters #### Path Parameters - **appId** (string) - Required - An app id - **notificationId** (string) - Required - A notification id ### Response #### Success Response (200) - **NotificationWithMeta** (object) - The notification details and metadata #### Error Handling - 400: Bad Request - 404: Not Found ``` -------------------------------- ### Add a Subscription to a User in C# Source: https://context7.com/onesignal/onesignal-dotnet-api/llms.txt Registers a new subscription (email, SMS, or push) for an existing user. ```csharp var subscriptionBody = new SubscriptionBody { Subscription = new Subscription { Type = "Email", Token = "newemail@example.com", Enabled = true } }; try { SubscriptionBody result = client.CreateSubscription( appId: "YOUR_APP_ID", aliasLabel: "external_id", aliasId: "user_12345", subscriptionBody: subscriptionBody ); Console.WriteLine($"Subscription created with ID: {result.Subscription?.Id}"); } catch (ApiException e) { Console.WriteLine("Error: " + e.Message); } ``` -------------------------------- ### Create App - C# Source: https://github.com/onesignal/onesignal-dotnet-api/blob/main/docs/DefaultApi.md Creates a new OneSignal app. Ensure your Bearer token is configured for organization API key authorization. ```csharp using System.Collections.Generic; using System.Diagnostics; using OneSignalApi.Api; using OneSignalApi.Client; using OneSignalApi.Model; namespace Example { public class CreateAppExample { public static void Main() { Configuration config = new Configuration(); config.BasePath = "https://api.onesignal.com"; // Configure Bearer token for authorization: organization_api_key config.AccessToken = "YOUR_BEARER_TOKEN"; var apiInstance = new DefaultApi(config); var app = new App(); // App | try { // Create an app App result = apiInstance.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 OneSignal API Client Source: https://context7.com/onesignal/onesignal-dotnet-api/llms.txt Initialize the API client using REST API keys for app-level or organization-level operations. ```csharp // Install via .NET CLI // dotnet add package OneSignalApi using OneSignalApi.Api; using OneSignalApi.Client; using OneSignalApi.Model; // Configure with REST API Key (for most endpoints) var config = new Configuration(); config.BasePath = "https://api.onesignal.com"; config.AccessToken = "YOUR_REST_API_KEY"; // From Settings > Keys & IDs var client = new DefaultApi(config); // For organization-level endpoints (creating apps, etc.) var orgConfig = new Configuration(); orgConfig.BasePath = "https://api.onesignal.com"; orgConfig.AccessToken = "YOUR_ORGANIZATION_API_KEY"; // From Organization Settings var orgClient = new DefaultApi(orgConfig); ``` -------------------------------- ### GET /notifications - View Notifications Source: https://context7.com/onesignal/onesignal-dotnet-api/llms.txt Retrieve a paginated list of notifications sent from your app with optional filtering by kind. ```APIDOC ## GET /notifications - View Notifications ### Description Retrieve a paginated list of notifications sent from your app with optional filtering by kind. ### Method GET ### Endpoint /notifications ### Parameters #### Query Parameters - **appId** (string) - Required - The application ID. - **limit** (int) - Optional - The maximum number of notifications to return per request (max 50). - **offset** (int) - Optional - The page offset for pagination. - **kind** (int) - Optional - Filter notifications by kind: 0=Dashboard, 1=API, 3=Automated, null=All. ### Request Example ```csharp NotificationSlice notifications = client.GetNotifications( appId: "YOUR_APP_ID", limit: 50, offset: 0, kind: 1 ); ``` ### Response #### Success Response (200) - **TotalCount** (int) - The total number of notifications. - **Notifications** (List) - A list of notification objects. - **Id** (string) - The notification ID. - **Contents** (LanguageStringMap) - The notification content. - **Successful** (int) - The number of successful deliveries. - **Failed** (int) - The number of failed deliveries. #### Response Example ```json { "totalCount": 100, "notifications": [ { "id": "notification-uuid-1", "contents": {"en": "Notification content 1"}, "successful": 95, "failed": 5 }, { "id": "notification-uuid-2", "contents": {"en": "Notification content 2"}, "successful": 98, "failed": 2 } ] } ``` ``` -------------------------------- ### POST /apps Source: https://github.com/onesignal/onesignal-dotnet-api/blob/main/docs/DefaultApi.md Creates a new OneSignal application. ```APIDOC ## POST /apps ### Description Creates a new OneSignal app. ### Method POST ### Endpoint /apps ### Parameters #### Request Body - **app** (App) - Required ### Response #### Success Response (200) - **App** (object) - The created application object. #### Error Responses - **400** (Bad Request) - **429** (Rate Limit Exceeded) ``` -------------------------------- ### GET /apps/{app_id}/outcomes Source: https://context7.com/onesignal/onesignal-dotnet-api/llms.txt Retrieves analytics outcomes data including clicks, session duration, and custom outcomes. ```APIDOC ## GET /apps/{app_id}/outcomes ### Description Retrieve analytics outcomes data including clicks, session duration, and custom outcomes. ### Parameters #### Query Parameters - **outcomeNames** (string) - Required - Comma-separated list of outcome names. - **outcomeTimeRange** (string) - Required - Time range (1h, 1d, or 1mo). - **outcomePlatforms** (string) - Optional - Platform filters (0=iOS, 1=Android). - **outcomeAttribution** (string) - Optional - Attribution type (direct, influenced, or unattributed). ``` -------------------------------- ### List Organization Apps Source: https://context7.com/onesignal/onesignal-dotnet-api/llms.txt Retrieves a list of all applications associated with the organization. ```csharp try { List apps = orgClient.GetApps(); foreach (var app in apps) { Console.WriteLine($"App ID: {app.Id}"); Console.WriteLine($"Name: {app.Name}"); Console.WriteLine($"Players: {app.Players}"); Console.WriteLine("---"); } } catch (ApiException e) { Console.WriteLine("Error: " + e.Message); } ```