View which subscriptions received a particular message

Overview

This API allows you to fetch all the subscriptions that received a specific message, identified by its notification_id, for both push notifications and email channels. You can access message history for up to seven days after the notification is sent. Note that notifications sent to less than 1,000 recipients won't record a sent event, but it will still record clicked events.

Requirements

  • A OneSignal Professional or Enterprise Plan.
  • Enabled the "Send History via OneSignal API" option in Settings -> Integrations; notifications sent before this setting is enabled can't be retrieved.
  • Requests must be made within seven days of sending the notification.

How to Use this API

  1. Submit a request to generate a report.
  2. Decide delivery method
    • After receiving a successful response, poll the destination URL until the file becomes available. Exports typically complete within 1-3 minutes; we recommend a 10-second polling interval.
    • Alternatively, you can opt to receive an email to the address specified in the optional email parameter when the report is ready.

Polling

Use the csv_file_url property in the response to test if the report is complete. If you receive a '403' error response, retry fetching the file after a short period; it only means we're still generating the report.

Sample Report

The generated report is a simple CSV file that can be imported into any system for further processing.

player_id,onesignal_id,external_id,target_channel,timestamp

"2c4fac95-7dfb-4113-9347-aba3a92ff557","ccddf35a-1233-4423-8a57-ac8c4b38eb81","a07aec27-2586-4b92-a24f-62660a1517fa","push","1628189160"

"68f5cf73-b20a-4de9-b6ee-79a863b8e7d8","d2f9f2f8-94af-4942-8183-115cef1213d5","4b66359f-3d94-4a73-806d-8ef5f0430b3d","push","1628187816"

Limitations

  • Querying for opens events are not supported.
  • The timestamp column is included only for clicked events.

Examples

curl --request POST \
     --url https://api.onesignal.com/notifications/NOTIFICATION_ID/history \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --header 'Authorization: Basic REST_API_KEY' \
     --data '
{
  "events": "sent",
  "app_id": "APP_ID",
  "email": "[email protected]"
}
'
Language