OneSignal Notifications API
The Notifications API from OneSignal — 4 operation(s) for notifications.
The Notifications API from OneSignal — 4 operation(s) for notifications.
Every API here is available over the APIs.io API and to AI agents over MCP.
One button, every client — Claude, Cursor, VS Code and the rest.
https://apis.io/mcp
find_apisBrowse and filter every API in the catalog.get_api_artifactsOne API's artifacts, grouped by type.get_openapiThe primary OpenAPI for this API.find_similar_apisAPIs that look like this one.apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.resolveTurn a domain, URL or GitHub org into the provider it belongs to.find_cohortsEvery scored population of providers in the catalog.curl "https://apis.io/api/v1/apis/onesignal-notifications-api"
curl "https://apis.io/api/v1/apis?limit=25"
Discovery needs no key. Ratings and market analysis are Pro.
Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.
A second provider on the same verified email joins the account you already have.
openapi: 3.2.0
info:
title: Onesignal Notifications API
version: '1.0'
description: 'Operations tagged Notifications across 2 of this provider''s published API definitions: onesignal-api-openapi.json, onesignal-openapi.yml. Each path carries the servers of the definition it was published in.'
servers:
- url: https://api.onesignal.com
tags:
- name: Notifications
paths:
/notifications/{message_id}/history:
x-mcp:
enabled: true
post:
summary: Message history
description: View which subscriptions received a particular message
operationId: message-history
x-codeSamples:
- lang: typescript
label: Node.js SDK
source: "import Onesignal from '@onesignal/node-onesignal';\n\nconst configuration = Onesignal.createConfiguration({\n restApiKey: 'YOUR_REST_API_KEY',\n});\nconst apiInstance = new Onesignal.DefaultApi(configuration);\n\n// string | The \\\"id\\\" of the message found in the Notification object\nconst notificationId: string = \"b3a0c8bd-3a4c-4b22-9a73-3f1a8c2d1b88\";\n// GetNotificationHistoryRequestBody\nconst getNotificationHistoryRequestBody: Onesignal.GetNotificationHistoryRequestBody = {\n events: \"sent\",\n email: \"email_example\",\n app_id: \"app_id_example\",\n };\n\ntry {\n const response = await apiInstance.getNotificationHistory(notificationId, getNotificationHistoryRequestBody);\n console.log(response);\n} catch (e) {\n if (e instanceof Onesignal.ApiException) {\n // `e.errorMessages` flattens any error-envelope shape to a `string[]`;\n // the raw parsed body remains on `e.body`.\n console.error(\"getNotificationHistory failed: HTTP \" + e.code, e.errorMessages);\n } else {\n throw e;\n }\n}"
- lang: python
label: Python SDK
source: "import onesignal\nfrom onesignal.api import default_api\nfrom onesignal.models import *\nfrom pprint import pprint\n\n# See configuration.py for a list of all supported configuration parameters.\n# Some of the OneSignal endpoints require ORGANIZATION_API_KEY token for authorization, while others require REST_API_KEY.\n# We recommend adding both of them in the configuration page so that you will not need to figure it out yourself.\nconfiguration = onesignal.Configuration(\n rest_api_key = \"YOUR_REST_API_KEY\", # App REST API key required for most endpoints\n organization_api_key = \"YOUR_ORGANIZATION_API_KEY\" # Organization key is only required for creating new apps and other top-level endpoints\n)\n\n\n# Enter a context with an instance of the API client\nwith onesignal.ApiClient(configuration) as api_client:\n # Create an instance of the API class\n api_instance = default_api.DefaultApi(api_client)\n notification_id = \"b3a0c8bd-3a4c-4b22-9a73-3f1a8c2d1b88\" # The \\\"id\\\" of the message found in the Notification object \n get_notification_history_request_body = GetNotificationHistoryRequestBody(\n events=\"sent\",\n email=\"email_example\",\n app_id=\"app_id_example\",\n ) \n\n try:\n # Notification History\n api_response = api_instance.get_notification_history(notification_id, get_notification_history_request_body)\n pprint(api_response)\n except onesignal.ApiException as e:\n print(\"Exception when calling DefaultApi->get_notification_history: %s\\n\" % e)\n print(\"Status Code: %s\" % e.status)\n print(\"Response Body: %s\" % e.body)"
- lang: php
label: PHP SDK
source: "<?php\nrequire_once(__DIR__ . '/vendor/autoload.php');\n\n\n// Configure Bearer authorization: rest_api_key\n$config = onesignal\\client\\Configuration::getDefaultConfiguration()\n ->setRestApiKeyToken('YOUR_REST_API_KEY')\n ->setOrganizationApiKeyToken('YOUR_ORGANIZATION_API_KEY');\n\n\n\n$apiInstance = new onesignal\\client\\Api\\DefaultApi(\n // If you want use custom http client, pass your client which implements `GuzzleHttp\\ClientInterface`.\n // This is optional, `GuzzleHttp\\Client` will be used as default.\n new GuzzleHttp\\Client(),\n $config\n);\n$notification_id = 'b3a0c8bd-3a4c-4b22-9a73-3f1a8c2d1b88'; // string | The \\\"id\\\" of the message found in the Notification object\n$get_notification_history_request_body = new \\onesignal\\client\\model\\GetNotificationHistoryRequestBody(); // \\onesignal\\client\\model\\GetNotificationHistoryRequestBody\n\ntry {\n $result = $apiInstance->getNotificationHistory($notification_id, $get_notification_history_request_body);\n print_r($result);\n} catch (\\onesignal\\client\\ApiException $e) {\n echo 'Exception when calling DefaultApi->getNotificationHistory: ', $e->getMessage(), PHP_EOL;\n echo 'Status Code: ', $e->getCode(), PHP_EOL;\n // getErrorMessages() flattens any error-envelope shape to a string[];\n // the raw body remains on getResponseBody().\n echo 'Error Messages: ', implode(', ', $e->getErrorMessages()), PHP_EOL;\n echo 'Response Body: ', $e->getResponseBody(), PHP_EOL;\n} catch (\\Exception $e) {\n echo 'Exception when calling DefaultApi->getNotificationHistory: ', $e->getMessage(), PHP_EOL;\n}"
- lang: go
label: Go SDK
source: "package main\n\nimport (\n \"context\"\n \"fmt\"\n \"os\"\n\n \"github.com/OneSignal/onesignal-go-api/v5\"\n)\n\nfunc main() {\n notificationId := \"b3a0c8bd-3a4c-4b22-9a73-3f1a8c2d1b88\" // string | The \\\"id\\\" of the message found in the Notification object\n getNotificationHistoryRequestBody := *onesignal.NewGetNotificationHistoryRequestBody() // GetNotificationHistoryRequestBody | \n\n configuration := onesignal.NewConfiguration()\n apiClient := onesignal.NewAPIClient(configuration)\n\n restAuth := context.WithValue(context.Background(), onesignal.RestApiKey, \"YOUR_REST_API_KEY\") // App REST API key required for most endpoints\n\n resp, r, err := apiClient.DefaultApi.GetNotificationHistory(restAuth, notificationId).GetNotificationHistoryRequestBody(getNotificationHistoryRequestBody).Execute()\n\n if err != nil {\n fmt.Fprintf(os.Stderr, \"Error when calling `DefaultApi.GetNotificationHistory``: %v\\n\", err)\n fmt.Fprintf(os.Stderr, \"Full HTTP response: %v\\n\", r)\n if apiErr, ok := err.(*onesignal.GenericOpenAPIError); ok {\n // ErrorMessages() flattens any error-envelope shape to a []string;\n // the raw body remains on Body().\n fmt.Fprintf(os.Stderr, \"Error Messages: %v\\n\", apiErr.ErrorMessages())\n fmt.Fprintf(os.Stderr, \"Response Body: %s\\n\", apiErr.Body())\n }\n }\n // response from `GetNotificationHistory`: NotificationHistorySuccessResponse\n fmt.Fprintf(os.Stdout, \"Response from `DefaultApi.GetNotificationHistory`: %v\\n\", resp)\n}"
- lang: ruby
label: Ruby SDK
source: "require 'onesignal'\n# setup authorization\nOneSignal.configure do |config|\n # Configure Bearer authorization: rest_api_key\n config.rest_api_key = 'YOUR_REST_API_KEY'\n\nend\n\napi_instance = OneSignal::DefaultApi.new\nnotification_id = 'b3a0c8bd-3a4c-4b22-9a73-3f1a8c2d1b88' # String | The \\\"id\\\" of the message found in the Notification object\nget_notification_history_request_body = OneSignal::GetNotificationHistoryRequestBody.new # GetNotificationHistoryRequestBody | \n\nbegin\n # Notification History\n result = api_instance.get_notification_history(notification_id, get_notification_history_request_body)\n p result\nrescue OneSignal::ApiError => e\n puts \"Error when calling DefaultApi->get_notification_history: #{e}\"\n puts \"Status Code: #{e.code}\"\n # `e.error_messages` flattens any error-envelope shape to an Array<String>;\n # the raw body remains on `e.response_body`.\n puts \"Error Messages: #{e.error_messages}\"\n puts \"Response Body: #{e.response_body}\"\nend"
- lang: java
label: Java SDK
source: "// Import classes:\nimport com.onesignal.client.ApiClient;\nimport com.onesignal.client.ApiException;\nimport com.onesignal.client.Configuration;\nimport com.onesignal.client.auth.*;\nimport com.onesignal.client.model.*;\nimport com.onesignal.client.api.DefaultApi;\n\npublic class Example {\n public static void main(String[] args) {\n ApiClient defaultClient = Configuration.getDefaultApiClient();\n defaultClient.setBasePath(\"https://api.onesignal.com\");\n \n // Configure HTTP bearer authorization: rest_api_key\n HttpBearerAuth rest_api_key = (HttpBearerAuth) defaultClient.getAuthentication(\"rest_api_key\");\n rest_api_key.setBearerToken(\"YOUR_REST_API_KEY\");\n\n DefaultApi apiInstance = new DefaultApi(defaultClient);\n String notificationId = \"b3a0c8bd-3a4c-4b22-9a73-3f1a8c2d1b88\"; // String | The \\\"id\\\" of the message found in the Notification object\n GetNotificationHistoryRequestBody getNotificationHistoryRequestBody = new GetNotificationHistoryRequestBody(); // GetNotificationHistoryRequestBody | \n try {\n NotificationHistorySuccessResponse result = apiInstance.getNotificationHistory(notificationId, getNotificationHistoryRequestBody);\n System.out.println(result);\n } catch (ApiException e) {\n System.err.println(\"Exception when calling DefaultApi#getNotificationHistory\");\n System.err.println(\"Status code: \" + e.getCode());\n // getErrorMessages() flattens any error-envelope shape to a List<String>;\n // the raw body remains on getResponseBody().\n System.err.println(\"Error messages: \" + e.getErrorMessages());\n System.err.println(\"Reason: \" + e.getResponseBody());\n System.err.println(\"Response headers: \" + e.getResponseHeaders());\n e.printStackTrace();\n }\n }\n}"
- lang: csharp
label: C# SDK
source: "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing OneSignalApi.Api;\nusing OneSignalApi.Client;\nusing OneSignalApi.Model;\n\nnamespace Example\n{\n public class GetNotificationHistoryExample\n {\n public static void Main()\n {\n Configuration config = new Configuration();\n config.BasePath = \"https://api.onesignal.com\";\n // Configure Bearer token for authorization: rest_api_key\n config.AccessToken = \"YOUR_REST_API_KEY\";\n\n var apiInstance = new DefaultApi(config);\n var notificationId = \"b3a0c8bd-3a4c-4b22-9a73-3f1a8c2d1b88\"; // string | The \\\"id\\\" of the message found in the Notification object\n var getNotificationHistoryRequestBody = new GetNotificationHistoryRequestBody(); // GetNotificationHistoryRequestBody | \n\n try\n {\n // Notification History\n NotificationHistorySuccessResponse result = apiInstance.GetNotificationHistory(notificationId, getNotificationHistoryRequestBody);\n Debug.WriteLine(result);\n }\n catch (ApiException e)\n {\n Debug.Print(\"Exception when calling DefaultApi.GetNotificationHistory: \" + e.Message );\n Debug.Print(\"Status Code: \"+ e.ErrorCode);\n // e.ErrorMessages flattens any error-envelope shape to an IReadOnlyList<string>;\n // the raw body remains on e.ErrorContent.\n Debug.Print(\"Error Messages: \" + string.Join(\", \", e.ErrorMessages));\n Debug.Print(\"Response Body: \" + e.ErrorContent);\n Debug.Print(e.StackTrace);\n }\n }\n }\n}"
- lang: rust
label: Rust SDK
source: "use onesignal_rust_api::apis::configuration::Configuration;\nuse onesignal_rust_api::apis::default_api;\n\nuse onesignal_rust_api::models;\n\n\n#[tokio::main]\nasync fn main() {\n let mut configuration = Configuration::new();\n configuration.rest_api_key_token = Some(\"YOUR_REST_API_KEY\".to_string());\n\n\n // Realistic values are pulled from the spec's `example:` fields where present.\n let notification_id: &str = \"b3a0c8bd-3a4c-4b22-9a73-3f1a8c2d1b88\";\n let get_notification_history_request_body: models::GetNotificationHistoryRequestBody = todo!();\n\n match default_api::get_notification_history(&configuration, notification_id, get_notification_history_request_body).await {\n Ok(resp) => println!(\"{:?}\", resp),\n Err(e @ onesignal_rust_api::apis::Error::ResponseError(_)) => {\n // `e.error_messages()` flattens any error-envelope shape to a Vec<String>;\n // the raw response remains on the ResponseError variant.\n eprintln!(\"get_notification_history failed: {:?}\", e.error_messages());\n }\n Err(e) => eprintln!(\"get_notification_history failed: {:?}\", e),\n }\n}"
parameters:
- name: message_id
in: path
description: The identifier of the message in UUID v4 format. Get this `id` in the response of your Create Message API request, the [View Messages API](/reference/view-messages), and in your OneSignal dashboard Message Reports.
schema:
type: string
required: true
- name: Authorization
in: header
description: Your App API key with prefix `Key `. See [Keys & IDs](/docs/en/keys-and-ids).
required: true
schema:
type: string
default: Key YOUR_APP_API_KEY
requestBody:
content:
application/json:
schema:
type: object
required:
- app_id
- events
properties:
app_id:
type: string
description: Your OneSignal App ID in UUID v4 format. See [Keys & IDs](/docs/en/keys-and-ids).
default: YOUR_APP_ID
events:
type: string
description: 'Specifies the type of event to retrieve. `sent` — retrieves all subscriptions sent the specified message. Note: sent events are not recorded for messages targeting fewer than 1,000 recipients. `clicked` — retrieves all subscriptions that interacted with the message. Note: There isn''t a recipient count threshold for tracking clicked event.'
default: sent
email:
type: string
description: The email address in which to deliver the report.
responses:
'202':
description: Accepted. The history-export job was enqueued. The export is delivered asynchronously to the configured S3 destination.
content:
application/json:
examples:
Result:
value:
success: true
destination_url: https://onesignal-aws-link.csv
schema:
type: object
properties:
success:
type: boolean
example: true
default: true
destination_url:
type: string
example: https://onesignal-aws-link.csv
'400':
description: '400'
content:
application/json:
examples:
Result:
value:
errors:
- param `email` must be a valid email
success: false
schema:
$ref: '#/components/schemas/BasicErrorResponse'
'429':
description: Rate limit exceeded. Wait the number of seconds in the `Retry-After` header before retrying.
headers:
Retry-After:
description: Number of seconds to wait before retrying the request. Always emitted on 429 responses.
schema:
type: integer
minimum: 0
content:
application/json:
schema:
$ref: '#/components/schemas/BasicErrorResponse'
example:
errors:
- API rate limit exceeded
'503':
description: Service temporarily unavailable. Retry after a short backoff. The body may be empty or non-JSON in some failure modes.
headers:
Retry-After:
description: Number of seconds to wait before retrying. Optional — may be absent when the response is generated upstream.
schema:
type: integer
minimum: 0
content:
application/json:
schema:
$ref: '#/components/schemas/BasicErrorResponse'
example:
errors:
- Service temporarily unavailable
deprecated: false
tags:
- Notifications
security:
- {}
servers:
- url: https://api.onesignal.com
/notifications/{message_id}/export_events:
post:
summary: Export audience activity CSV
description: Export a compressed CSV report of audience-level delivery and engagement data for a specific message. This includes sent, delivered, clicked, failed, and unsubscribed events across Push, Email, and SMS channels.
operationId: export-csv-of-events
x-codeSamples:
- lang: typescript
label: Node.js SDK
source: "import Onesignal from '@onesignal/node-onesignal';\n\nconst configuration = Onesignal.createConfiguration({\n restApiKey: 'YOUR_REST_API_KEY',\n});\nconst apiInstance = new Onesignal.DefaultApi(configuration);\n\n// string | The ID of the notification to export events from.\nconst notificationId: string = \"b3a0c8bd-3a4c-4b22-9a73-3f1a8c2d1b88\";\n// string | The ID of the app that the notification belongs to.\nconst appId: string = \"YOUR_APP_ID\";\n\ntry {\n const response = await apiInstance.exportEvents(notificationId, appId);\n console.log(response);\n} catch (e) {\n if (e instanceof Onesignal.ApiException) {\n // `e.errorMessages` flattens any error-envelope shape to a `string[]`;\n // the raw parsed body remains on `e.body`.\n console.error(\"exportEvents failed: HTTP \" + e.code, e.errorMessages);\n } else {\n throw e;\n }\n}"
- lang: python
label: Python SDK
source: "import onesignal\nfrom onesignal.api import default_api\nfrom onesignal.models import *\nfrom pprint import pprint\n\n# See configuration.py for a list of all supported configuration parameters.\n# Some of the OneSignal endpoints require ORGANIZATION_API_KEY token for authorization, while others require REST_API_KEY.\n# We recommend adding both of them in the configuration page so that you will not need to figure it out yourself.\nconfiguration = onesignal.Configuration(\n rest_api_key = \"YOUR_REST_API_KEY\", # App REST API key required for most endpoints\n organization_api_key = \"YOUR_ORGANIZATION_API_KEY\" # Organization key is only required for creating new apps and other top-level endpoints\n)\n\n\n# Enter a context with an instance of the API client\nwith onesignal.ApiClient(configuration) as api_client:\n # Create an instance of the API class\n api_instance = default_api.DefaultApi(api_client)\n notification_id = \"b3a0c8bd-3a4c-4b22-9a73-3f1a8c2d1b88\" # The ID of the notification to export events from. \n app_id = \"YOUR_APP_ID\" # The ID of the app that the notification belongs to. \n\n try:\n # Export CSV of Events\n api_response = api_instance.export_events(notification_id, app_id)\n pprint(api_response)\n except onesignal.ApiException as e:\n print(\"Exception when calling DefaultApi->export_events: %s\\n\" % e)\n print(\"Status Code: %s\" % e.status)\n print(\"Response Body: %s\" % e.body)"
- lang: php
label: PHP SDK
source: "<?php\nrequire_once(__DIR__ . '/vendor/autoload.php');\n\n\n// Configure Bearer authorization: rest_api_key\n$config = onesignal\\client\\Configuration::getDefaultConfiguration()\n ->setRestApiKeyToken('YOUR_REST_API_KEY')\n ->setOrganizationApiKeyToken('YOUR_ORGANIZATION_API_KEY');\n\n\n\n$apiInstance = new onesignal\\client\\Api\\DefaultApi(\n // If you want use custom http client, pass your client which implements `GuzzleHttp\\ClientInterface`.\n // This is optional, `GuzzleHttp\\Client` will be used as default.\n new GuzzleHttp\\Client(),\n $config\n);\n$notification_id = 'b3a0c8bd-3a4c-4b22-9a73-3f1a8c2d1b88'; // string | The ID of the notification to export events from.\n$app_id = 'YOUR_APP_ID'; // string | The ID of the app that the notification belongs to.\n\ntry {\n $result = $apiInstance->exportEvents($notification_id, $app_id);\n print_r($result);\n} catch (\\onesignal\\client\\ApiException $e) {\n echo 'Exception when calling DefaultApi->exportEvents: ', $e->getMessage(), PHP_EOL;\n echo 'Status Code: ', $e->getCode(), PHP_EOL;\n // getErrorMessages() flattens any error-envelope shape to a string[];\n // the raw body remains on getResponseBody().\n echo 'Error Messages: ', implode(', ', $e->getErrorMessages()), PHP_EOL;\n echo 'Response Body: ', $e->getResponseBody(), PHP_EOL;\n} catch (\\Exception $e) {\n echo 'Exception when calling DefaultApi->exportEvents: ', $e->getMessage(), PHP_EOL;\n}"
- lang: go
label: Go SDK
source: "package main\n\nimport (\n \"context\"\n \"fmt\"\n \"os\"\n\n \"github.com/OneSignal/onesignal-go-api/v5\"\n)\n\nfunc main() {\n notificationId := \"b3a0c8bd-3a4c-4b22-9a73-3f1a8c2d1b88\" // string | The ID of the notification to export events from.\n appId := \"YOUR_APP_ID\" // string | The ID of the app that the notification belongs to.\n\n configuration := onesignal.NewConfiguration()\n apiClient := onesignal.NewAPIClient(configuration)\n\n restAuth := context.WithValue(context.Background(), onesignal.RestApiKey, \"YOUR_REST_API_KEY\") // App REST API key required for most endpoints\n\n resp, r, err := apiClient.DefaultApi.ExportEvents(restAuth, notificationId).AppId(appId).Execute()\n\n if err != nil {\n fmt.Fprintf(os.Stderr, \"Error when calling `DefaultApi.ExportEvents``: %v\\n\", err)\n fmt.Fprintf(os.Stderr, \"Full HTTP response: %v\\n\", r)\n if apiErr, ok := err.(*onesignal.GenericOpenAPIError); ok {\n // ErrorMessages() flattens any error-envelope shape to a []string;\n // the raw body remains on Body().\n fmt.Fprintf(os.Stderr, \"Error Messages: %v\\n\", apiErr.ErrorMessages())\n fmt.Fprintf(os.Stderr, \"Response Body: %s\\n\", apiErr.Body())\n }\n }\n // response from `ExportEvents`: ExportEventsSuccessResponse\n fmt.Fprintf(os.Stdout, \"Response from `DefaultApi.ExportEvents`: %v\\n\", resp)\n}"
- lang: ruby
label: Ruby SDK
source: "require 'onesignal'\n# setup authorization\nOneSignal.configure do |config|\n # Configure Bearer authorization: rest_api_key\n config.rest_api_key = 'YOUR_REST_API_KEY'\n\nend\n\napi_instance = OneSignal::DefaultApi.new\nnotification_id = 'b3a0c8bd-3a4c-4b22-9a73-3f1a8c2d1b88' # String | The ID of the notification to export events from.\napp_id = 'YOUR_APP_ID' # String | The ID of the app that the notification belongs to.\n\nbegin\n # Export CSV of Events\n result = api_instance.export_events(notification_id, app_id)\n p result\nrescue OneSignal::ApiError => e\n puts \"Error when calling DefaultApi->export_events: #{e}\"\n puts \"Status Code: #{e.code}\"\n # `e.error_messages` flattens any error-envelope shape to an Array<String>;\n # the raw body remains on `e.response_body`.\n puts \"Error Messages: #{e.error_messages}\"\n puts \"Response Body: #{e.response_body}\"\nend"
- lang: java
label: Java SDK
source: "// Import classes:\nimport com.onesignal.client.ApiClient;\nimport com.onesignal.client.ApiException;\nimport com.onesignal.client.Configuration;\nimport com.onesignal.client.auth.*;\nimport com.onesignal.client.model.*;\nimport com.onesignal.client.api.DefaultApi;\n\npublic class Example {\n public static void main(String[] args) {\n ApiClient defaultClient = Configuration.getDefaultApiClient();\n defaultClient.setBasePath(\"https://api.onesignal.com\");\n \n // Configure HTTP bearer authorization: rest_api_key\n HttpBearerAuth rest_api_key = (HttpBearerAuth) defaultClient.getAuthentication(\"rest_api_key\");\n rest_api_key.setBearerToken(\"YOUR_REST_API_KEY\");\n\n DefaultApi apiInstance = new DefaultApi(defaultClient);\n String notificationId = \"b3a0c8bd-3a4c-4b22-9a73-3f1a8c2d1b88\"; // String | The ID of the notification to export events from.\n String appId = \"YOUR_APP_ID\"; // String | The ID of the app that the notification belongs to.\n try {\n ExportEventsSuccessResponse result = apiInstance.exportEvents(notificationId, appId);\n System.out.println(result);\n } catch (ApiException e) {\n System.err.println(\"Exception when calling DefaultApi#exportEvents\");\n System.err.println(\"Status code: \" + e.getCode());\n // getErrorMessages() flattens any error-envelope shape to a List<String>;\n // the raw body remains on getResponseBody().\n System.err.println(\"Error messages: \" + e.getErrorMessages());\n System.err.println(\"Reason: \" + e.getResponseBody());\n System.err.println(\"Response headers: \" + e.getResponseHeaders());\n e.printStackTrace();\n }\n }\n}"
- lang: csharp
label: C# SDK
source: "using System;\nusing System.Collections.Generic;\nusing System.Diagnostics;\nusing OneSignalApi.Api;\nusing OneSignalApi.Client;\nusing OneSignalApi.Model;\n\nnamespace Example\n{\n public class ExportEventsExample\n {\n public static void Main()\n {\n Configuration config = new Configuration();\n config.BasePath = \"https://api.onesignal.com\";\n // Configure Bearer token for authorization: rest_api_key\n config.AccessToken = \"YOUR_REST_API_KEY\";\n\n var apiInstance = new DefaultApi(config);\n var notificationId = \"b3a0c8bd-3a4c-4b22-9a73-3f1a8c2d1b88\"; // string | The ID of the notification to export events from.\n var appId = \"YOUR_APP_ID\"; // string | The ID of the app that the notification belongs to.\n\n try\n {\n // Export CSV of Events\n ExportEventsSuccessResponse result = apiInstance.ExportEvents(notificationId, appId);\n Debug.WriteLine(result);\n }\n catch (ApiException e)\n {\n Debug.Print(\"Exception when calling DefaultApi.ExportEvents: \" + e.Message );\n Debug.Print(\"Status Code: \"+ e.ErrorCode);\n // e.ErrorMessages flattens any error-envelope shape to an IReadOnlyList<string>;\n // the raw body remains on e.ErrorContent.\n Debug.Print(\"Error Messages: \" + string.Join(\", \", e.ErrorMessages));\n Debug.Print(\"Response Body: \" + e.ErrorContent);\n Debug.Print(e.StackTrace);\n }\n }\n }\n}"
- lang: rust
label: Rust SDK
source: "use onesignal_rust_api::apis::configuration::Configuration;\nuse onesignal_rust_api::apis::default_api;\n\n\n#[tokio::main]\nasync fn main() {\n let mut configuration = Configuration::new();\n configuration.rest_api_key_token = Some(\"YOUR_REST_API_KEY\".to_string());\n\n\n // Realistic values are pulled from the spec's `example:` fields where present.\n let notification_id: &str = \"b3a0c8bd-3a4c-4b22-9a73-3f1a8c2d1b88\";\n let app_id: &str = \"YOUR_APP_ID\";\n\n match default_api::export_events(&configuration, notification_id, app_id).await {\n Ok(resp) => println!(\"{:?}\", resp),\n Err(e @ onesignal_rust_api::apis::Error::ResponseError(_)) => {\n // `e.error_messages()` flattens any error-envelope shape to a Vec<String>;\n // the raw response remains on the ResponseError variant.\n eprintln!(\"export_events failed: {:?}\", e.error_messages());\n }\n Err(e) => eprintln!(\"export_events failed: {:?}\", e),\n }\n}"
parameters:
- name: message_id
in: path
description: The identifier of the message in UUID v4 format. Get this `id` in the response of your Create Message API request, the [View Messages API](/reference/view-messages), and in your OneSignal dashboard Message Reports.
schema:
type: string
default: YOUR_NOTIFICATION_ID
required: true
- name: app_id
in: query
description: Your OneSignal App ID in UUID v4 format. See [Keys & IDs](/docs/en/keys-and-ids).
required: true
schema:
type: string
default: YOUR_APP_ID
- name: Authorization
in: header
description: Your App API key with prefix `Key `. See [Keys & IDs](/docs/en/keys-and-ids).
required: true
schema:
type: string
default: Key YOUR_APP_API_KEY
responses:
'200':
description: '200'
content:
application/json:
schema:
type: object
properties:
csv_file_url:
type: string
description: The URL to download the CSV file. The file is available for 3 days after generation.
'400':
description: '400'
content:
application/json:
schema:
$ref: '#/components/schemas/BasicErrorResponse'
example:
errors:
- The reason for the error. Usually an invalid `message_id` format or missing required path parameter.
'401':
description: '401'
content:
application/json:
schema:
$ref: '#/components/schemas/BasicErrorResponse'
example:
errors:
- Missing or invalid REST API key for the app.
'404':
description: '404'
content:
application/json:
schema:
$ref: '#/components/schemas/BasicErrorResponse'
example:
errors:
- No message exists with the provided `message_id` in this app, or the message is older than 30 days and its audience activity has been purged.
'429':
description: Rate limit exceeded. Wait the number of seconds in the `Retry-After` header before retrying.
headers:
Retry-After:
description: Number of seconds to wait before retrying the request. Always emitted on 429 responses.
schema:
type: integer
minimum: 0
content:
application/json:
schema:
$ref: '#/components/schemas/BasicErrorResponse'
example:
errors:
- API rate limit exceeded
'503':
description: Service temporarily unavailable. Retry after a short backoff. The body may be empty or non-JSON in some failure modes.
headers:
Retry-After:
description: Number of seconds to wait before retrying. Optional — may be absent when the response is generated upstream.
schema:
type: integer
minimum: 0
content:
application/json:
schema:
$ref: '#/components/schemas/BasicErrorResponse'
example:
errors:
- Service temporarily unavailable
deprecated: false
tags:
- Notifications
security:
- {}
servers:
- url: https://api.onesignal.com
/notifications/{message_id}?app_id={app_id}:
get:
summary: View message
description: View the details of a single message and the Outcomes associated with it.
operationId: view-message
x-codeSamples:
- lang: typescript
label: Node.js SDK
source: "import Onesignal from '@onesignal/node-onesignal';\n\nconst configuration = Onesignal.createConfiguration({\n restApiKey: 'YOUR_REST_API_KEY',\n});\nconst apiInstance = new Onesignal.DefaultApi(configuration);\n\n// string\nconst appId: string = \"YOUR_APP_ID\";\n// string\nconst notificationId: string = \"
# --- truncated at 32 KB (143 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/onesignal/refs/heads/main/openapi/onesignal-notifications-api-openapi.yml