The Ecommerce Delivery API delivers real-time push notifications to mobile and web clients through Firebase Cloud Messaging (FCM), using the officialDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/fredy-rizo/ecommerce-delivery/llms.txt
Use this file to discover all available pages before exploring further.
firebase-admin Node.js SDK. Notifications are fired automatically inside the sale controllers whenever a meaningful order event occurs — no polling required on the client side.
Push notifications require a valid Firebase service account. The API initialises the Admin SDK by reading a JSON credentials file (
quokka-notify-push-firebase-adminsdk-fbsvc-*.json) at startup via firebase-admin’s credential.cert() method. This file must be present in src/middleware/firebase/ before the server starts, or the FCM integration will fail to initialise.How device tokens are stored
Before a device can receive notifications, it must register its FCM token with the API. TheNotificationToken model (src/models/Notification.js) stores one record per user device:
| Field | Type | Description |
|---|---|---|
userId | String | The MongoDB _id of the owning user |
fcmToken | String | The device/browser FCM registration token |
active | Boolean | Whether this token should receive notifications (default true) |
active: true are queried when notifications are dispatched. If a user has no active token registered, the notification is silently skipped.
Registering a device token
CallPOST /api/notification/register-token to register or refresh a device token. The endpoint uses an upsert — if a token already exists for the given userId it is updated in place and marked active: true, so it is safe to call on every app launch or after login.
Call this endpoint on every app startup and immediately after a successful login. FCM tokens can be rotated by the Firebase SDK at any time; re-registering ensures the stored token stays current and the user continues to receive notifications.
Notification triggers
The API fires three distinct push notification events, all originating fromsrc/controllers/saleController.js.
1 — Payment proof uploaded
Triggered by:
POST /api/sale/laod-proof/:saleIdRecipients: All users with role value: "2" (admin) who have an active FCM token.When a buyer uploads their payment proof, the API fetches every admin user ID, queries NotificationToken for their active tokens, and dispatches an individual FCM message to each one.2 — Order status changed
Triggered by:
POST /api/sale/status-change/:saleIdRecipient: The buyer who owns the sale (single token lookup by userId).When an admin changes the top-level status of a sale (e.g. from Validando to Pagado), the buyer is notified with the new status name and their order code.3 — Delivery checkpoint added
Triggered by:
POST /api/sale/status-delivery/:saleIdRecipient: The buyer who owns the sale (single token lookup by userId).Each time a delivery agent appends a new entry to the deliveryStatus array, the buyer receives a real-time update combining the description and detail fields from the request body.The data payload
Every notification includes a structured data object alongside the visible notification object. This allows the client application to navigate the user directly to the relevant order screen when the notification is tapped.
| Field | Value |
|---|---|
saleId | The MongoDB _id of the affected sale |
type | One of "dateproof_update", "status_update", or "delivery_update" |