Generate Alerts
Bearer token for authentication (admin role required)
Response
Indicates if alerts were generated successfully
Number of new alerts created
Example Request
curl -X POST https://cemac-api.vercel.app/alerts/generate \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json"
Example Response
{
"success": true,
"alertsGenerated": 5,
"message": "Alertas generadas exitosamente"
}
Error Codes
401 - Unauthorized
403 - Forbidden - Admin role required
500 - Internal server error
Get Alerts
Bearer token for authentication
Query Parameters
Filter by alert status (“pendiente”, “en_proceso”, “atendido”)
Filter by priority level (“critica”, “urgente”, “media”, “baja”)
Filter alerts from this date (ISO 8601 format)
Filter alerts until this date (ISO 8601 format)
Page number for pagination
Number of alerts per page
Field to sort by (e.g., “createdAt”, “priority”)
Sort order: “asc” or “desc”
Response
Indicates if the request was successful
Example Request
curl -X GET "https://cemac-api.vercel.app/alerts?status=pendiente&priority=urgente&page=1&limit=10" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json"
Example Response
{
"success": true,
"data": {
"alerts": [
{
"id": "alert_001",
"type": "stock_low",
"priority": "urgente",
"status": "pendiente",
"productId": "prod_123",
"productName": "Cuaderno Profesional 100 hojas",
"productCategory": "Cuadernos y Libretas",
"currentStock": 5,
"minThreshold": 20,
"message": "Stock bajo: Solo quedan 5 unidades de Cuaderno Profesional 100 hojas",
"createdAt": "2025-11-16T10:30:00.000Z",
"updatedAt": "2025-11-16T10:30:00.000Z"
},
{
"id": "alert_002",
"type": "stock_out",
"priority": "critica",
"status": "pendiente",
"productId": "prod_456",
"productName": "Bolígrafo BIC Azul",
"productCategory": "Bolígrafos",
"currentStock": 0,
"minThreshold": 10,
"message": "Producto agotado: Bolígrafo BIC Azul",
"createdAt": "2025-11-16T09:15:00.000Z",
"updatedAt": "2025-11-16T09:15:00.000Z"
}
],
"pagination": {
"currentPage": 1,
"totalPages": 3,
"total": 25,
"totalAlerts": 25,
"hasNextPage": true,
"hasPrevPage": false,
"limit": 10
}
}
}
Error Codes
401 - Unauthorized
500 - Internal server error
Get Latest Critical Alert
Bearer token for authentication
Response
Indicates if the request was successful
Indicates if a critical alert exists
The latest critical alert object (if exists)
Example Request
curl -X GET https://cemac-api.vercel.app/alerts/latest-critical \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json"
Example Response
{
"success": true,
"data": {
"hasAlert": true,
"alert": {
"id": "alert_002",
"type": "stock_out",
"priority": "critica",
"status": "pendiente",
"productId": "prod_456",
"productName": "Bolígrafo BIC Azul",
"currentStock": 0,
"message": "Producto agotado: Bolígrafo BIC Azul",
"createdAt": "2025-11-16T09:15:00.000Z"
}
}
}
Get Alerts Count
Bearer token for authentication
Response
Indicates if the request was successful
Counts grouped by priority
Example Request
curl -X GET https://cemac-api.vercel.app/alerts/count \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json"
Example Response
{
"success": true,
"data": {
"byStatus": {
"pendiente": 15,
"en_proceso": 8,
"atendido": 2
},
"byPriority": {
"critica": 3,
"urgente": 12,
"media": 7,
"baja": 3
},
"total": 25
}
}
Get Alert by ID
Bearer token for authentication
Path Parameters
ID of the alert to retrieve
Response
Indicates if the alert was found
Alert object with full details
Example Request
curl -X GET https://cemac-api.vercel.app/alerts/alert_001 \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json"
Example Response
{
"success": true,
"alert": {
"id": "alert_001",
"type": "stock_low",
"priority": "urgente",
"status": "pendiente",
"productId": "prod_123",
"productName": "Cuaderno Profesional 100 hojas",
"currentStock": 5,
"minThreshold": 20,
"message": "Stock bajo: Solo quedan 5 unidades",
"createdAt": "2025-11-16T10:30:00.000Z",
"updatedAt": "2025-11-16T10:30:00.000Z"
}
}
Error Codes
401 - Unauthorized
404 - Alert not found
500 - Internal server error
Update Alert Status
Bearer token for authentication
Path Parameters
ID of the alert to update
Request Body
New status: “pendiente”, “en_proceso”, or “atendido”
Optional notes about the status change
Response
Indicates if the update was successful
Example Request
curl -X PUT https://cemac-api.vercel.app/alerts/alert_001/status \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"status": "en_proceso",
"notes": "Pedido realizado al proveedor"
}'
Example Response
{
"success": true,
"alert": {
"id": "alert_001",
"status": "en_proceso",
"notes": "Pedido realizado al proveedor",
"updatedAt": "2025-11-16T11:00:00.000Z"
}
}
Error Codes
400 - Invalid status value
401 - Unauthorized
404 - Alert not found
500 - Internal server error
Mark All Alerts as Read
Bearer token for authentication
Request Body
Optional filters to select which alerts to mark (e.g., {"priority": "media"})
Optional notes to add to all updated alerts
Response
Indicates if the operation was successful
Example Request
curl -X PUT https://cemac-api.vercel.app/alerts/mark-all-read \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"filters": {"priority": "media"},
"notes": "Revisión masiva completada"
}'
Example Response
{
"success": true,
"updatedCount": 7,
"message": "7 alertas marcadas como atendidas"
}
Get Alerts History
Bearer token for authentication
Query Parameters
Filter by specific month (format: “YYYY-MM”)
Page number for pagination
Response
Indicates if the request was successful
Array of historical alert records
Example Request
curl -X GET "https://cemac-api.vercel.app/alerts/history?month=2025-11&page=1&limit=10" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json"
Example Response
{
"success": true,
"history": [
{
"id": "alert_003",
"type": "stock_low",
"priority": "media",
"status": "atendido",
"productName": "Marcador Sharpie Negro",
"resolvedAt": "2025-11-16T12:00:00.000Z",
"notes": "Stock repuesto"
}
],
"pagination": {
"page": 1,
"limit": 10,
"total": 50
}
}
Update Alert Thresholds
Bearer token for authentication (admin role required)
Request Body
Threshold configuration object
Stock level for critical alerts
Stock level for low stock alerts
Stock level for warning alerts
Response
Indicates if thresholds were updated
Updated threshold settings
Example Request
curl -X PUT https://cemac-api.vercel.app/alerts/settings/thresholds \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"stockThresholds": {
"critical": 5,
"low": 20,
"warning": 50
}
}'
Example Response
{
"success": true,
"settings": {
"stockThresholds": {
"critical": 5,
"low": 20,
"warning": 50
},
"updatedAt": "2025-11-16T13:00:00.000Z"
}
}
Error Codes
401 - Unauthorized
403 - Forbidden - Admin role required
500 - Internal server error
Delete Alert
Bearer token for authentication (admin role required)
Path Parameters
ID of the alert to delete
Response
Indicates if deletion was successful
Example Request
curl -X DELETE https://cemac-api.vercel.app/alerts/alert_001 \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json"
Example Response
{
"success": true,
"message": "Alerta eliminada exitosamente"
}
Error Codes
401 - Unauthorized
403 - Forbidden - Admin role required
404 - Alert not found
500 - Internal server error