Send Notification By Token API
Send push notifications directly using device push tokens (FCM/APNs)
Send Notification By Token API
Send push notifications using device push tokens directly. Bypass device ID lookup for maximum efficiency when you have the FCM or APNs token.
Direct Token
Use push tokens directly without lookup.
Efficient
Fastest path to push notification delivery.
Platform Native
Works with FCM and APNs tokens.
Endpoint Overview
/graphqlSend a push notification directly to a device using its FCM (Firebase Cloud Messaging) or APNs (Apple Push Notification service) token.
Request Parameters
tokenString!RequiredThe device's push notification token (FCM or APNs).
notificationNotificationInput!RequiredObject containing the notification details.
subjectString!RequiredThe notification title.
contentString!RequiredThe notification body message.
dataJSONAdditional payload data for the app to process.
badgeIntApp badge number (iOS only).
soundStringNotification sound to play.
GraphQL Mutation
mutation sendNotificationByToken(
$token: String!
$notification: NotificationInput!
) {
sendNotificationByToken(
token: $token
notification: $notification
) {
status
message
messageId
}
}Variables:
{
"token": "fMz9X...your_fcm_token...abc123",
"notification": {
"subject": "Connection Alert",
"content": "VPN connection established successfully",
"data": {
"action": "connection_status",
"status": "connected"
}
}
}HTTP Request:
curl -X POST https://api.orbnet.com/graphql \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ADMIN_TOKEN" \
-d '{
"query": "mutation sendNotificationByToken($token: String!, $notification: NotificationInput!) { sendNotificationByToken(token: $token, notification: $notification) { status message messageId } }",
"variables": {
"token": "fMz9X...fcm_token...abc123",
"notification": {
"subject": "Connection Alert",
"content": "VPN connected successfully"
}
}
}'Response
{
"data": {
"sendNotificationByToken": {
"status": "sent",
"message": "Notification delivered",
"messageId": "msg_abc123xyz"
}
}
}{
"errors": [
{
"message": "Invalid or expired push token",
"path": ["sendNotificationByToken"],
"extensions": {
"code": "INVALID_TOKEN"
}
}
],
"data": null
}Token Types
FCM Token
Firebase Cloud Messaging for Android and cross-platform.
APNs Token
Apple Push Notification service for iOS devices.
Best Practices
Token Validation
Tokens expire - handle invalid token errors gracefully.
Token Refresh
Apps should update tokens when they change.
Silent Data
Use data payloads for background app updates.
Fallback
Have fallback notifications if token fails.
Related Endpoints
Token Management
Push tokens can change when apps are reinstalled or updated. Implement token refresh handling in your application.
Don't Have Push Tokens?
If you only have device IDs, use the Send by Device ID API which handles token lookup automatically.