[Goto Home](/docs/index.html)

# 🔐 POST `/admin/notifications/send-push-to-all`

## Description

- Sends a push notification to **all active users** (terminated ≠ true, and both `name` and `username` exist).
- Uses **paginated** processing in the background: users are fetched in pages (100 per page); for each user, every device in `auth.loggedinDevices` that has an **fcmToken** receives the notification via `utils/helpers.sendPushNotification()`.
- The API **responds immediately** with a success message and does **not** wait for all notifications to be sent. Sending continues in the background after the response.

## Request Body

```json
{
  "title": "Announcement",
  "body": "Check out the new features we just released!"
}
```

- **title** – string, required, min 1, max 100 characters.
- **body** – string, required, min 1, max 500 characters.

## Response Body

Responds immediately with:

```json
{
  "message": "Started sending notifications to active users"
}
```

## Notes

- Only users with `terminated` not true and with both `name` and `username` set are considered active.
- Notifications are sent to each **fcmToken** in `auth.loggedinDevices` for those users; devices without an fcm token are skipped.
- Sending is done in the background in a paginated way (100 users per batch). Failures for individual tokens are handled via `Promise.allSettled` and do not stop the rest of the sends.

# Links

[Goto Home](/docs/index.html)
