The Alerts API lets coffee producers configure price-threshold notifications. When a registered buyer publishes a purchase price that meets or exceeds a producer’sDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/JaiderT/CoffeePrice/llms.txt
Use this file to discover all available pages before exploring further.
precioMinimo, the platform sends an automatic email notification. Alerts can target a specific buyer or watch all buyers at once.
Base URL: /api/alertas
Roles: productor and admin only. Authenticated users with rol: "comprador" cannot access these endpoints.
Alert object
| Field | Type | Description |
|---|---|---|
_id | ObjectId | Unique identifier for the alert. |
usuario | ObjectId (ref: usuario) | The producer who owns the alert. |
comprador | ObjectId (ref: comprador) | null | The specific buyer to watch. null means any buyer can trigger this alert. |
precioMinimo | number | The minimum purchase price (COP per load/kg as configured) that triggers the alert. |
activa | boolean | Whether the alert is currently enabled. Default: true. |
canales.email | boolean | Send an email notification when triggered. Default: false. |
canales.whatsapp | boolean | WhatsApp notification channel. Default: true. |
canales.sms | boolean | SMS notification channel. Default: false. |
canales.push | boolean | Push notification channel. Default: true. |
ultimaNotificacion | Date | null | Timestamp of the most recent triggered notification. |
createdAt | Date | Alert creation timestamp. |
updatedAt | Date | Last modification timestamp. |
GET /api/alertas/usuario/:usuarioId
Returns all alerts belonging to a specific user, with buyer details (nombreempresa) populated.
Auth: Owner of the alerts or admin. Returns 403 if neither condition is met.
200 OK
GET /api/alertas/verificar/:usuarioId
Returns only active alerts for a user whoseultimaNotificacion falls within the last 60 seconds. Intended for real-time UI polling — call this endpoint periodically to detect freshly triggered alerts and display in-app notifications without a WebSocket connection.
Auth: Owner of the alerts or admin.
200 OK — Array of recently triggered alert objects (may be empty if none fired in the last 60 seconds). Buyer’s nombreempresa is populated.
GET /api/alertas/:id
Returns a single alert by its ID. The owner’s name/surname and the buyer’s company name are populated. Auth: Owner of the alert or admin.200 OK — Single alert object with usuario (nombre, apellido) and comprador (nombreempresa) populated.
Response 404 Not Found — If no alert exists with the given :id.
POST /api/alertas
Creates a new price alert. The authenticated user’s ID is automatically used as theusuario field — you do not need to include it in the body.
Auth: productor or admin
Request body
The MongoDB ObjectId of a specific buyer to watch. Omit this field (or set to
null) to watch all buyers simultaneously.The minimum purchase price threshold that triggers the alert, in Colombian pesos (COP). Must be a positive number.
Notification channel preferences. All sub-fields are boolean. Defaults:
whatsapp: true, sms: false, email: false, push: true.Send an email when the alert triggers. Default:
false.Send a WhatsApp message when the alert triggers. Default:
true.Send an SMS when the alert triggers. Default:
false.Send a push notification when the alert triggers. Default:
true.comprador field:
201 Created — Returns the newly created alert object.
Response 400 Bad Request — If precioMinimo is missing or the payload is malformed.
PUT /api/alertas/:id
Updates an existing alert’sprecioMinimo, comprador, canales, or activa state. Only the alert owner or an admin may update an alert.
Auth: Owner of the alert or admin.
New minimum price threshold.
Change the watched buyer. Pass
null to revert to watching all buyers.Updated channel preferences object.
Directly set the active state. Prefer the dedicated toggle endpoint for on/off toggling.
200 OK — Returns the updated alert object.
PUT /api/alertas/:id/toggle
Toggles theactiva flag on an alert. If the alert is currently active, it becomes inactive, and vice versa.
Auth: Owner of the alert or admin.
200 OK
message value is "Alerta activa" when toggled on, or "Alerta desactivada" when toggled off.
DELETE /api/alertas/:id
Permanently deletes an alert. This action is irreversible. Auth: Owner of the alert or admin.200 OK
403 Forbidden — If the authenticated user is not the owner and not an admin.
Response 404 Not Found — If no alert exists with the given :id.