Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/ALEJ4NDRO2025/urban-store/llms.txt

Use this file to discover all available pages before exploring further.

The alerts endpoint evaluates five real-time anomaly detection rules against recent event data and returns any that are currently triggered. Each rule uses a separate lookback window tuned to its signal type. If no rules fire, a single all_clear alert is returned so your dashboard always has a defined state to render. This endpoint is designed to be polled periodically — every few minutes is typically sufficient.

Endpoint

GET /api/analytics/alerts/

Authentication

Bearer token required with is_admin: true in the JWT payload. Returns 403 if the user is not an admin.

Alert Object Fields

type
string
Machine-readable alert type identifier. See the rules table below.
message
string
Human-readable description of the anomaly, including specific numbers.
severity
string
Urgency level: "critical", "warning", or "info".
timestamp
string
ISO 8601 timestamp of when the alert was generated.

Alert Rules

TypeTriggerLookbackSeverity
high_abandonmentAbandonment rate > 70% with ≥ 3 checkout attemptsLast 24 hourscritical
popular_no_conversionProduct with > 10 unique views but 0 purchasesLast 7 dayswarning
payment_errorsAny payment_error events recordedLast 1 hourcritical
carts_abandoned≥ 5 sessions added to cart without starting checkoutLast 6 hourswarning
stuck_sessionsSessions with > 15 events but no purchaseLast 24 hoursinfo
all_clearNo other rules triggeredinfo

Rule Details

high_abandonment — Counts unique identifiers (user email or session ID) that fired begin_checkout in the last 24 hours. If more than 70% of those did not also fire purchase, and the total checkout count is at least 3, this alert fires. popular_no_conversion — Uses a MongoDB aggregation to find products with more than 10 unique viewing sessions in the last 7 days. For each such product, if no purchase events exist for it in the same window, a separate alert object is emitted (one per affected product). Each includes a product_slug field in addition to the standard fields. payment_errors — Counts payment_error events from the last hour. Any count greater than zero triggers the alert. carts_abandoned — Compares add_to_cart session IDs to begin_checkout session IDs over the last 6 hours. If 5 or more sessions added items but never reached checkout, the alert fires. stuck_sessions — Aggregates sessions with more than 15 total events in the last 24 hours that never fired a purchase event. Any count greater than zero triggers the alert. all_clear — Added automatically only when the alerts array would otherwise be empty.

Response

alerts
array
Array of alert objects. Contains at least one entry (all_clear when everything is normal).

Examples

All clear

curl -X GET https://api.urbanstore.co/api/analytics/alerts/ \
  -H "Authorization: Bearer <admin_token>"
{
  "alerts": [
    {
      "type": "all_clear",
      "message": "No se detectaron anomalías en este momento.",
      "severity": "info",
      "timestamp": "2024-05-22T16:00:00.000000+00:00"
    }
  ]
}

Multiple active alerts

{
  "alerts": [
    {
      "type": "high_abandonment",
      "message": "Tasa de abandono del 78.5% en las últimas 24h (11 de 14 checkouts)",
      "severity": "critical",
      "timestamp": "2024-05-22T16:00:00.000000+00:00"
    },
    {
      "type": "payment_errors",
      "message": "Se detectaron 3 errores de pago en la última hora",
      "severity": "critical",
      "timestamp": "2024-05-22T16:00:00.000000+00:00"
    },
    {
      "type": "popular_no_conversion",
      "message": "Producto \"urban-cargo-pants\" tuvo 23 vistas únicas sin ninguna compra en 7 días",
      "severity": "warning",
      "timestamp": "2024-05-22T16:00:00.000000+00:00",
      "product_slug": "urban-cargo-pants"
    },
    {
      "type": "carts_abandoned",
      "message": "8 carritos no iniciaron checkout en las últimas 6h",
      "severity": "warning",
      "timestamp": "2024-05-22T16:00:00.000000+00:00"
    },
    {
      "type": "stuck_sessions",
      "message": "2 sesiones con más de 15 eventos en 24h sin completar compra",
      "severity": "info",
      "timestamp": "2024-05-22T16:00:00.000000+00:00"
    }
  ]
}
Poll this endpoint every 2–5 minutes in your admin dashboard to surface issues in near real-time. Display critical alerts prominently and use warning alerts to feed a notification queue for the operations team.

Build docs developers (and LLMs) love