Send Notification By Token API

Send push notifications directly using device push tokens (FCM/APNs)

Push Notifications

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

MUTATION/graphql

Send a push notification directly to a device using its FCM (Firebase Cloud Messaging) or APNs (Apple Push Notification service) token.

Authentication:Bearer Token
Required scopes:admin

Request Parameters

tokenString!Required

The device's push notification token (FCM or APNs).

notificationNotificationInput!Required

Object containing the notification details.

subjectString!Required

The notification title.

contentString!Required

The notification body message.

dataJSON

Additional payload data for the app to process.

badgeInt

App badge number (iOS only).

soundString

Notification 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

200Notification Sent Successfully
{
  "data": {
    "sendNotificationByToken": {
      "status": "sent",
      "message": "Notification delivered",
      "messageId": "msg_abc123xyz"
    }
  }
}
400Invalid Token
{
  "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.



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.

Send by Device ID