Set up HTTP webhooks to receive real-time notifications when users display, click, or dismiss web push notifications. Complete guide with examples for Chrome, Firefox, and Safari browser support.
Web Push Webhooks allow you to receive real-time HTTP POST notifications whenever users interact with your push notifications. When a notification is displayed, clicked, or dismissed, OneSignal automatically sends the notification data and any custom parameters to your specified webhook URL.
Key Benefits:
Browser | Platform Support | Webhook Events Available |
---|---|---|
Chrome | macOS, Windows, Android | All events (display, click, dismiss) |
Firefox | macOS, Windows, Android | Display and click events |
Safari | Not supported | None |
Triggered immediately after a notification appears on the user’s screen.
Use cases: Track delivery rates, log impression data, trigger follow-up campaigns
Triggered when a user clicks on the notification body or any action button.
Use cases: Track engagement rates, trigger conversion events, redirect users to specific content
Triggered when a user actively dismisses a notification or when it expires automatically.
Browser support: Chrome only Use cases: Track dismissal rates, optimize notification timing, A/B test notification content
Important: Clicking the notification body or action buttons does NOT trigger the dismissed webhook.
Navigate to Settings > Web in your OneSignal dashboard
Enable the “Enable webhooks” toggle
Enter your webhook URLs for each event you want to track
Enable webhooks in your OneSignal dashboard settings
Navigate to Settings > Web in your OneSignal dashboard
Enable the “Enable webhooks” toggle
Enter your webhook URLs for each event you want to track
Enable webhooks in your OneSignal dashboard settings
Add webhook configuration to your existing OneSignal.init()
method:
The cors
setting determines what headers and data your webhook endpoint receives:
cors: false
(Recommended): Simpler setup, no CORS configuration needed on your servercors: true
: Provides additional headers but requires CORS support on your serverWhen to use cors: true
:
Content-Type: application/json
headerX-OneSignal-Event
header for easier event identificationYour webhook endpoint receives a POST request with this payload structure:
Same payload as above, plus these additional headers:
Field | Type | Description | Always Present |
---|---|---|---|
event | string | Event type that triggered the webhook | ✅ |
notificationId | string | Unique OneSignal notification identifier | ✅ |
heading | string | Notification title | Only if provided |
content | string | Notification message body | Only if provided |
additionalData | object | Custom data sent with notification | Only if provided |
actionId | string | ID of clicked action button (empty string = notification body clicked) | Click events only |
url | string | Launch URL for the notification | Only if provided |
subscriptionId | string | OneSignal user/subscription ID | CORS enabled only |
Security:
Response Requirements:
Possible causes:
Solution: Ensure webhook configuration is included in your OneSignal init code on all pages where notifications are active.
Cause: Webhooks only track events for users who visit pages with the webhook configuration active.
Solution: Deploy webhook code to all pages with OneSignal, not just specific landing pages.
Cause: Network issues or browser behavior may cause duplicate requests.
Solution: Implement idempotency using the notificationId
field to deduplicate events.
notification.dismissed
event only works in ChromeAfter setting up webhooks, consider:
Set up HTTP webhooks to receive real-time notifications when users display, click, or dismiss web push notifications. Complete guide with examples for Chrome, Firefox, and Safari browser support.
Web Push Webhooks allow you to receive real-time HTTP POST notifications whenever users interact with your push notifications. When a notification is displayed, clicked, or dismissed, OneSignal automatically sends the notification data and any custom parameters to your specified webhook URL.
Key Benefits:
Browser | Platform Support | Webhook Events Available |
---|---|---|
Chrome | macOS, Windows, Android | All events (display, click, dismiss) |
Firefox | macOS, Windows, Android | Display and click events |
Safari | Not supported | None |
Triggered immediately after a notification appears on the user’s screen.
Use cases: Track delivery rates, log impression data, trigger follow-up campaigns
Triggered when a user clicks on the notification body or any action button.
Use cases: Track engagement rates, trigger conversion events, redirect users to specific content
Triggered when a user actively dismisses a notification or when it expires automatically.
Browser support: Chrome only Use cases: Track dismissal rates, optimize notification timing, A/B test notification content
Important: Clicking the notification body or action buttons does NOT trigger the dismissed webhook.
Navigate to Settings > Web in your OneSignal dashboard
Enable the “Enable webhooks” toggle
Enter your webhook URLs for each event you want to track
Enable webhooks in your OneSignal dashboard settings
Navigate to Settings > Web in your OneSignal dashboard
Enable the “Enable webhooks” toggle
Enter your webhook URLs for each event you want to track
Enable webhooks in your OneSignal dashboard settings
Add webhook configuration to your existing OneSignal.init()
method:
The cors
setting determines what headers and data your webhook endpoint receives:
cors: false
(Recommended): Simpler setup, no CORS configuration needed on your servercors: true
: Provides additional headers but requires CORS support on your serverWhen to use cors: true
:
Content-Type: application/json
headerX-OneSignal-Event
header for easier event identificationYour webhook endpoint receives a POST request with this payload structure:
Same payload as above, plus these additional headers:
Field | Type | Description | Always Present |
---|---|---|---|
event | string | Event type that triggered the webhook | ✅ |
notificationId | string | Unique OneSignal notification identifier | ✅ |
heading | string | Notification title | Only if provided |
content | string | Notification message body | Only if provided |
additionalData | object | Custom data sent with notification | Only if provided |
actionId | string | ID of clicked action button (empty string = notification body clicked) | Click events only |
url | string | Launch URL for the notification | Only if provided |
subscriptionId | string | OneSignal user/subscription ID | CORS enabled only |
Security:
Response Requirements:
Possible causes:
Solution: Ensure webhook configuration is included in your OneSignal init code on all pages where notifications are active.
Cause: Webhooks only track events for users who visit pages with the webhook configuration active.
Solution: Deploy webhook code to all pages with OneSignal, not just specific landing pages.
Cause: Network issues or browser behavior may cause duplicate requests.
Solution: Implement idempotency using the notificationId
field to deduplicate events.
notification.dismissed
event only works in ChromeAfter setting up webhooks, consider: