Overview
The Push Notifications API allows you to send notifications to subscribers using configured push notification services (FCM, APNS, etc.). All endpoints are prefixed with/v2/push-notification.
Get Subscriber Authentication Token
Generate a JWT authentication token for a subscriber.GET /v2/push-notification/subscriber-auth-token
string
required
Subscriber ID to generate token for
integer
default:"3600"
Token validity duration in seconds (default: 1 hour)
boolean
Whether token generation succeeded
string
The generated JWT token
string
Description: “Token is available in dataId field”
Send Notification to Subscribers
Send a push notification to specific subscribers.POST /v2/push-notification/subscribers
string[]
required
Array of subscriber IDs to send notification to
string
required
JSON-formatted notification message as a string
string
Name of the push notification service to use. If not specified, uses the default service.
boolean
Whether notification was sent successfully
string
Result message or error description
Send Notification to Topic
Send a push notification to all subscribers of a topic.POST /v2/push-notification/topics/{topic}
string
required
Topic name to send notification to
string
Notification title
string
Notification message body
object
Additional data payload for the notification
string
Name of the push notification service to use
boolean
Whether notification was sent successfully
string
Result message or error description
Push Notification Services
Supported Services
Ant Media Server supports multiple push notification services:- FCM (Firebase Cloud Messaging) - For Android and iOS
- APNS (Apple Push Notification Service) - For iOS
- Custom notification services via plugins
Configuration
Push notification services must be configured in the application settings before use. Each service requires specific credentials: FCM Configuration:- Service account JSON file
- Project ID
- Certificate file
- Private key
- Team ID
- Bundle ID
Service Selection
If multiple notification services are configured:- Without
serviceNameparameter: Uses the default/first configured service - With
serviceNameparameter: Uses the specified service
Notification Message Format
Standard Fields
Most push notification services support these standard fields:string
Notification title displayed prominently
string
Main notification message text
string
URL to an image to display in the notification
object
Custom data payload passed to the app
FCM-Specific Fields
For Firebase Cloud Messaging, you can include:Use Cases
Notify Subscribers When Stream Starts
Notify Topic Subscribers
Error Handling
Common Errors
Invalid JSON Message:Best Practices
- Validate JSON - Ensure your notification message is valid JSON before sending
- Handle errors gracefully - Check the
successfield in responses - Batch notifications - Send to multiple subscribers in one request when possible
- Use topics - For broadcasting to many users, use topic-based notifications
- Include data payload - Add context data so the app can handle the notification appropriately
Integration with Subscribers
Push notifications work in conjunction with the Subscriber API. To enable notifications for a subscriber:- Add subscriber to a stream using
/v2/broadcasts/{id}/subscribers - Configure subscriber’s push notification token/device ID
- Send notifications when events occur (stream start, messages, etc.)
