Skip to main content

Send Push Notification

This endpoint allows administrators to send push notifications to users' mobile devices. Notifications can be sent immediately or scheduled for a future date, and can target specific user groups within a platform.

Endpoint

  • URL: /api/push-notifications
  • Method: POST
  • Authentication: Required (Admin access)

Request Body

ParameterTypeRequiredDefaultDescription
GroupIdintegerNo-The ID of the group to send the notification to (if omitted, sends to all users)
PlatformIdintegerYes-The ID of the platform
titlestringNo"Default Title"The title of the notification
messagestringNo"Default Message"The message content of the notification
scheduledForstring (ISO date)No-Date and time to send the notification (if not provided, sends immediately)
ContentIdintegerNo-ID of content to link (mutually exclusive with url)
urlstring (URL)No-External URL to open (mutually exclusive with ContentId)
parameterDatastring (JSON)No""JSON string with additional data for the mobile app (auto-populated for content/url)
destinationPagestringNo"Settings"The page to navigate to (auto-set to "PostView" for content, "ExternalLink" for URLs)
recipientsarray of integersNo[]Array of user IDs to receive the notification (if empty, sends to all users in the group)

Validation Rules

  • ContentId and url are mutually exclusive - only one can be provided per notification
  • If url is provided, it must be a valid URL format starting with http:// or https://
  • If ContentId is provided, the content must exist and be accessible to the selected group
  • When ContentId is set, the backend automatically sets destinationPage to "PostView" and includes contentId in parameterData
  • When url is set, the backend automatically sets destinationPage to "ExternalLink" and includes externalUrl in parameterData

Response

Success Response

  • Code: 200 OK
  • Content: "Notification sent"

Error Response

  • Code: 400 Bad Request
  • Content:
{
"error": "Something went wrong"
}

Notes

  • Notifications are delivered through Firebase Cloud Messaging to mobile devices
  • If scheduledFor is provided, the notification will be queued and sent at the specified time
  • The parameterData field can contain any JSON data needed by the mobile app for deep linking
  • The destinationPage field should match a valid page name in the mobile app
  • For large groups, recipients are processed in batches of 500 users
  • If the platform is not connected to a Firebase project, the notification will be created but not delivered

Example

curl -X POST "https://api.example.com/api/push-notifications" \
-H "Authorization: Bearer YOUR_AUTH_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"PlatformId": 789,
"title": "Live Session Starting Soon",
"message": "Join us on Zoom in 10 minutes!",
"url": "https://zoom.us/j/123456789?pwd=abc123"
}'
curl -X POST "https://api.example.com/api/push-notifications" \
-H "Authorization: Bearer YOUR_AUTH_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"GroupId": 456,
"PlatformId": 789,
"title": "New Video Available",
"message": "Check out our latest tutorial!",
"ContentId": 12345
}'
curl -X POST "https://api.example.com/api/push-notifications" \
-H "Authorization: Bearer YOUR_AUTH_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"PlatformId": 789,
"title": "Platform Update",
"message": "We've added new features to improve your experience!"
}'

Scheduled Notification to Specific Users

curl -X POST "https://api.example.com/api/push-notifications" \
-H "Authorization: Bearer YOUR_AUTH_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"GroupId": 456,
"PlatformId": 789,
"title": "Reminder: Upcoming Event",
"message": "Don't forget about tomorrow's live session!",
"scheduledFor": "2023-11-20T18:00:00.000Z",
"ContentId": 789,
"recipients": [1001, 1002, 1003]
}'