> ## Documentation Index
> Fetch the complete documentation index at: https://docsy3.mile.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Read alerts

> Returns alerts of your organization, newest event first, paginated. An alert is a record of a monitored event about a user, such as entering or leaving a geofence, stopping for too long, a task predicted to be late, leaving the planned route, driving above the speed limit, a phone battery at or below its limit, a driver on a trip who stops sending their location, or pressing the panic button. Known codes: `geofence.enter`, `geofence.leave` (user entered or left a geofence), `idle.detected`, `idle.repeated` (user stopped moving), `task.lateness.predicted` (a task is predicted to be late), `route.deviation.detected` (user left the planned route), `overspeed.detected` (user drove above the speed limit), `device.battery.low` (the phone battery of a user is at or below the limit), `driver.offline` (a user on a trip sent no location for the limit; updated when the user is back online), `user.panic` (panic button).

Without `status`, only unresolved alerts are returned. Days in `date`, `from` and `to` are local days in Asia/Jakarta time.

Pass `hubId` to get only one hub's alerts plus the alerts with no hub.

Requires permission `view/alert`.



## OpenAPI

````yaml /openapi/public/openapi-monitoring.json get /alerts
openapi: 3.0.0
info:
  title: API - Monitoring
  version: 3.0.0
  description: API Documentation - RESTful API for field operations management.
servers:
  - url: https://apiweb.mile.app/api/v3
security:
  - bearerAuth: []
tags:
  - name: Alert
    description: >-
      An alert is an event raised while monitoring field users and vehicles, for
      example entering or leaving a geofence, idling too long, a predicted late
      task, a route deviation, driving above the speed limit or a panic button
      press. You can list alerts, read a daily summary, and mark them resolved.
      These endpoints are served under `/api/v4`.
  - name: Alert Setting
    description: >-
      Alert settings switch each alert type on or off for your organization.
      They also return the limits each alert type fires on. These endpoints are
      served under `/api/v4`.
  - name: Geofence
    description: >-
      A geofence is an area drawn on the map, as a polygon or a circle. Alerts
      and automations can react when a field user enters or leaves it, or stays
      inside longer than its dwell time.
  - name: Geofence Group
    description: >-
      Geofence groups organize geofences so you can filter and manage them
      together.
paths:
  /alerts:
    servers:
      - url: https://apiweb.mile.app/api/v4
    get:
      tags:
        - Alert
      summary: Read alerts
      description: >-
        Returns alerts of your organization, newest event first, paginated. An
        alert is a record of a monitored event about a user, such as entering or
        leaving a geofence, stopping for too long, a task predicted to be late,
        leaving the planned route, driving above the speed limit, a phone
        battery at or below its limit, a driver on a trip who stops sending
        their location, or pressing the panic button. Known codes:
        `geofence.enter`, `geofence.leave` (user entered or left a geofence),
        `idle.detected`, `idle.repeated` (user stopped moving),
        `task.lateness.predicted` (a task is predicted to be late),
        `route.deviation.detected` (user left the planned route),
        `overspeed.detected` (user drove above the speed limit),
        `device.battery.low` (the phone battery of a user is at or below the
        limit), `driver.offline` (a user on a trip sent no location for the
        limit; updated when the user is back online), `user.panic` (panic
        button).


        Without `status`, only unresolved alerts are returned. Days in `date`,
        `from` and `to` are local days in Asia/Jakarta time.


        Pass `hubId` to get only one hub's alerts plus the alerts with no hub.


        Requires permission `view/alert`.
      operationId: getAlerts
      parameters:
        - name: status
          in: query
          required: false
          description: |-
            Resolution filter. `unresolved` (default), `resolved`, or `all`.
            **Example:** `all`
          schema:
            type: string
            enum:
              - unresolved
              - resolved
              - all
        - name: date
          in: query
          required: false
          description: |-
            A single local day (Y-m-d). Cannot be combined with `from` / `to`.
            **Example:** `2026-10-15`
          schema:
            type: string
            format: date
        - name: from
          in: query
          required: false
          description: >-
            Start day of a range (Y-m-d). Requires `to`; cannot be combined with
            `date`.

            **Example:** `2026-10-01`
          schema:
            type: string
            format: date
        - name: to
          in: query
          required: false
          description: >-
            End day of a range (Y-m-d). Requires `from`; must be on or after
            `from` and at most 93 days after it.

            **Example:** `2026-10-15`
          schema:
            type: string
            format: date
        - name: alertCode[]
          in: query
          required: false
          description: >-
            Only alerts with these codes. Repeat the parameter for several
            codes.

            **Example:** `alertCode[]=geofence.enter&alertCode[]=idle.detected`
          explode: true
          schema:
            type: array
            items:
              type: string
        - name: email
          in: query
          required: false
          description: |-
            Only alerts about this user (exact email, case-insensitive).
            **Example:** `user@example.com`
          schema:
            type: string
        - name: hubId
          in: query
          required: false
          description: >-
            Only alerts of this hub, plus alerts with no hub. Alerts recorded
            before hubs were stored on alerts have no hub, so they are returned
            for every hub. Leave it out to get the alerts of every hub.

            **Example:** `6a712e4c2385f1c14e04beeb`
          schema:
            type: string
        - $ref: '#/components/parameters/pageInQuery'
        - name: limit
          in: query
          required: false
          description: >-
            Number of alerts per page. Values above 100 are capped to 100.
            Default 20.

            **Example:** `20`
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 20
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: boolean
                    description: Status of response.
                  message:
                    description: Message of API response.
                    type: string
                  data:
                    description: >-
                      Paginated list of alerts. Each item in `data.data` is an
                      [Alert object](/api-reference/objects/alert-object):
                      fields shared by every alert are at the top level, and
                      fields for one kind of alert are inside the item's `data`,
                      whose keys depend on `alertCode`. `data` is always an
                      object, `{}` when the alert stores nothing.
                    type: object
                    additionalProperties: true
                example:
                  status: true
                  message: Success
                  data:
                    current_page: 1
                    data:
                      - _id: 66fb0c1d2e3f4a5b6c7d8e9f
                        alertCode: geofence.enter
                        alertName: Geofence enter
                        title: 'Entered Geofence: Warehouse A'
                        message: User One entered Warehouse A.
                        assignee: user@example.com
                        eventTime: '2026-10-15T02:10:00+00:00'
                        hubId: null
                        data:
                          lat: -6.2001
                          lon: 106.8166
                          geofenceId: 66e0a1b2c3d4e5f6a7b8c9d0
                          geofenceName: Warehouse A
                          geofenceGroup: 66e0a0b1c2d3e4f5a6b7c8d9
                          trackingDate: '2026-10-15'
                          driverName: User One
                        isResolved: false
                        resolvedTime: null
                        resolvedBy: null
                        resolvedByName: null
                        resolvedNotes: null
                      - _id: 66fb0c1d2e3f4a5b6c7d8ea0
                        alertCode: idle.detected
                        alertName: Idle detected
                        title: Idle
                        message: User Two has been idle since around 45 minutes ago.
                        assignee: user2@example.com
                        eventTime: '2026-10-15T01:45:00+00:00'
                        hubId: null
                        data:
                          lat: -6.1754
                          lon: 106.8272
                          driverName: User Two
                          isRepeat: false
                          idleSince: '2026-10-15T01:30:00+00:00'
                          idled: 15
                        isResolved: true
                        resolvedTime: '2026-10-15T02:00:00+00:00'
                        resolvedBy: dispatcher@example.com
                        resolvedByName: Dispatcher One
                        resolvedNotes: User was unloading.
                    first_page_url: https://apiweb.mile.app/api/v4/alerts?page=1
                    from: 1
                    last_page: 1
                    last_page_url: https://apiweb.mile.app/api/v4/alerts?page=1
                    links:
                      - url: null
                        label: '&laquo; Previous'
                        active: false
                      - url: https://apiweb.mile.app/api/v4/alerts?page=1
                        label: '1'
                        active: true
                      - url: null
                        label: Next &raquo;
                        active: false
                    next_page_url: null
                    path: https://apiweb.mile.app/api/v4/alerts
                    per_page: 20
                    prev_page_url: null
                    to: 2
                    total: 2
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: boolean
                    description: Shows if the request was successful.
                  message:
                    type: string
                    description: A short message explaining what went wrong.
                example:
                  status: false
                  message: Bad request - invalid parameters provided.
        '500':
          description: Server error
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: boolean
                    description: Shows if the request was successful.
                  message:
                    type: string
                    description: A short message explaining what went wrong.
                example:
                  status: false
                  message: Internal server error, please contact support@example.com.
      deprecated: false
      security:
        - bearerAuth: []
components:
  parameters:
    pageInQuery:
      name: page
      in: query
      schema:
        default: 1
        type: integer
      description: The page number of results to retrieve. **Example:** `2`
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Use a valid Bearer token to authenticate.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.