Skip to main content
The push module lets your backend fan a notification out to every registered device belonging to one or more users — across iOS (APNs), Android (FCM), and Web Push — in a single call.
Requires the push bundle and configured provider credentials (APNs, FCM, or Web Push) in the project dashboard. See Push Notifications for the full setup guide.

send

Sends a push notification to all registered devices for the given user IDs. Dispatches to APNs, FCM, and Web Push in parallel.
const result = await sublay.push.send({
  userIds: ["usr_abc123", "usr_def456"],
  title: "New message",
  body: "You have a new message from Alice.",
  data: { conversationId: "conv_xyz789" },
});
userIds
string[]
required
Sublay user IDs to notify. Maximum 100 per call.
title
string
required
Notification title shown on the device.
body
string
required
Notification body text.
data
Record<string, any>
Optional key-value payload forwarded to the app alongside the notification. Use for deep links, entity IDs, or any context your app needs when the user taps.
ReturnsPromise<SendPushResult>
interface SendPushResult {
  results: Record<string, PushDeviceResult[]>;
}

interface PushDeviceResult {
  platform: string;   // "ios" | "android" | "web"
  success: boolean;
  reason?: string;    // present when success is false
}
Every requested userId is present in results — users with no registered devices get an empty array. Stale device tokens that are permanently rejected by the upstream provider are automatically removed; you don’t need a separate cleanup step. Example response:
{
  "results": {
    "usr_abc123": [
      { "platform": "ios", "success": true },
      { "platform": "web", "success": true }
    ],
    "usr_def456": [],
    "usr_ghi789": [
      { "platform": "android", "success": false, "reason": "credentials_not_configured" }
    ]
  }
}
Common reason values when success is false:
ReasonMeaning
credentials_not_configuredNo provider credentials are configured (or enabled) for this platform
Provider error codesAPNs, FCM, or Web Push returned a delivery error