Overview
The Push API enables web push notifications using the Web Push Protocol with VAPID authentication. Subscriptions are tied to device sessions.Get VAPID Public Key
Whether push notifications are configured on the server
Base64-encoded VAPID public key (P-256 ECDSA key). Required for creating push subscriptions. Only present when
enabled is true.Status message when push is not configured
Subscribe to Push
Web Push subscription object from
PushManager.subscribe()Returns
true when subscription is savedThe subscription is stored on the device record associated with the current session. If no device ID is available in the session, the subscription will not be saved but the request will still succeed.
Unsubscribe from Push
Returns
true when subscription is removedThis endpoint only removes the subscription from the server. You should also call
subscription.unsubscribe() on the browser’s PushSubscription object.Get Push Status
Whether the current device has an active push subscription
Whether push notifications are configured on the server
Push Notification Flow
- Check if push is enabled: Call
GET /api/push/vapid-keyto verify server support - Request permission: Use browser
Notification.requestPermission() - Get public key: Retrieve VAPID public key from vapid-key endpoint
- Subscribe: Create subscription with
pushManager.subscribe()using the public key - Register subscription: Send subscription to
POST /api/push/subscribe - Receive notifications: Service worker receives push events
- Unsubscribe (optional): Call
POST /api/push/unsubscribeandsubscription.unsubscribe()