---
title: "Wialon Messages API: load_interval, Flags and Paging"
url: https://theassettrack.com/wialon-api/messages/
description: "How the Wialon messages API works: messages/load_interval, flags and flagsMask, paging with get_messages, message parameters, and the limits that bite."
---

# Wialon Messages API: load_interval, Flags and Paging

Reference · last checked December 1, 2026

How the Wialon messages API works: messages/load_interval, flags and flagsMask, paging with get_messages, message parameters, and the limits that bite.

Raw messages are what the tracker actually sent, and the reports and trips you see in Wialon are built on top of them. The Wialon messages API gives you that history directly, and it behaves differently from everything else in the Remote API. You do not get a response you can page through freely. You load a set of messages into your session, then read it back in slices. This page covers `messages/load_interval` and its flags, how to page through an interval too large for one response, what the `p` object and “Wialon parameters” actually are, and the limits that make large extractions fail.

If the request format is new to you, read the [Postman setup](https://theassettrack.com/wialon-api/postman/) first. Every call below is `svc` plus `params` sent to `wialon/ajax.html` with a session id. For the current position and last message of a unit, you do not need this page: that is flag 1024 on a unit search, covered on the [units page](https://theassettrack.com/wialon-api/units/).

## Know which documentation is current

The older wiki at sdk.wialon.com still ranks for these queries, but it now states that it is no longer supported and points to [help.wialon.com](https://help.wialon.com/en/api). The two disagree in ways that matter. The [old load_interval page](https://sdk.wialon.com/wiki/en/kit/remoteapi/apiref/messages/load_interval) lists six parameters; the [current one](https://help.wialon.com/en/api/user-guide/api-reference/messages/load_interval) lists ten, including `calcSensors` and `filter`, and documents error 1004. The current [get_messages page](https://help.wialon.com/en/api/user-guide/api-reference/messages/get_messages) also states precisely what `flags` and `flagsMask` do there, which turns out to be the opposite of what they do in `load_interval`. When the two sources differ, trust help.wialon.com.

## Understand the message loader first

The [messages section](https://help.wialon.com/en/api/user-guide/api-reference/messages) describes a message loader: a set of messages held in your session on the server. `messages/load_interval` and `messages/load_last` fill it, `messages/get_messages` reads from it, `messages/delete_message` removes one message from it and from the unit, and `messages/unload` clears it.

The loader holds one set. Loading a second set flushes the first automatically. Two practical consequences follow. A worker that shares a session with another worker overwrites that worker’s set, so parallel extraction needs one session per worker. And `get_messages` answers from whatever is loaded right now: if nothing is loaded it fails with error 4 rather than returning an empty array.

## Load an interval of messages

`https://hst-api.wialon.com/wialon/ajax.html?sid=<sid>&svc=messages/load_interval&params={"itemId":<unitId>,"timeFrom":1764547200,"timeTo":1764633599,"flags":1,"flagsMask":65281,"loadCount":100}`

That asks for the first hundred data messages with a position for one unit and one day. Times are Unix timestamps in seconds. The parameters, from the [reference](https://help.wialon.com/en/api/user-guide/api-reference/messages/load_interval):

| Parameter | Meaning |
| --- | --- |
| `itemId` | Unit or resource id, depending on the message type; for user log records, a user id |
| `timeFrom`, `timeTo` | Interval bounds. If `timeFrom` is greater than `timeTo`, nothing is returned and `count` is 0 |
| `flags`, `flagsMask` | Which message types and bits to select; see the next section |
| `loadCount` | How many messages to return, oldest first; `0xffffffff` means all found; `0` returns an empty `messages` array |
| `calcSensors` | Any non-zero value adds a `sensors` object to each message, keyed by sensor id |
| `measure` | Measurement system for sensor values: 0 metric, 1 US, 2 imperial, 3 metric with gallons; only with `calcSensors` |
| `sensorId` | Calculate this one sensor only; only with `calcSensors` |
| `filter` | Trim the `pos` and `p` objects to the named fields, for example `pos.x,p.pre*` |

The response is `{"count": N, "messages": [...]}`. Read `count` carefully: it is the number of messages found for the interval and it does not depend on `loadCount`. That makes a request with a small `loadCount` a cheap way to learn how big an interval is before deciding how to read it.

Three details are easy to miss:

- **gzip is mandatory.** A request whose `Accept-Encoding` header lacks `gzip` fails with error 1003. Most HTTP libraries send it by default; `curl` needs `--compressed`.
- **It counts as a heavy request.** `load_interval` is on the [resource-intensive list](https://help.wialon.com/en/api/user-guide/limitations#resource-intensive-requests), and a session may run no more than three of those at once. The fourth fails with error 1003 and the reason `LIMIT api_concurrent`.
- **Sensor values exist only on data messages.** With `calcSensors`, other message types return `-348201.3876` for a numeric sensor and `"---"` for a text one, per the [message format](https://help.wialon.com/en/api/user-guide/data-format/messages#data-message). Filter to data messages before trusting a sensor column.

The `calcSensors`, `measure` and `sensorId` parameters are marked in the reference as available in Wialon Local from version 2604.

## Select messages with flags and flagsMask

The two parameters work as a pair. The high byte of the mask selects the message type; the low bits select properties of the message. `flags` is the value those masked bits must equal. The reference gives these examples, shown here in the decimal form the JSON requires:

| `flagsMask` | `flags` | Selects |
| --- | --- | --- |
| 65280 (`0xFF00`) | 0 | All data messages |
| 65296 (`0xFF10`) | 16 | Data messages with the alarm bit |
| 65281 (`0xFF01`) | 1 | Data messages with a position |
| 65281 (`0xFF01`) | 1537 (`0x0601`) | Events that are violations |
| 65280 (`0xFF00`) | 16384 (`0x4000`) | Messages about triggered notifications |

As everywhere in this API, hexadecimal is not accepted in the request. Write 65281, not `0xFF01`.

The message type values come from the [message format reference](https://help.wialon.com/en/api/user-guide/data-format/messages):

| Type flag | Decimal | Message |
| --- | --- | --- |
| `0x0000` | 0 | Data message |
| `0x0100` | 256 | SMS |
| `0x0200` | 512 | Command |
| `0x0600` | 1536 | Event |
| `0x0900` | 2304 | SMS to and from a driver |
| `0x1000` | 4096 | Log record |
| `0x2000` | 8192 | Video usage |
| `0x4000` | 16384 | Triggered notification |
| `0x5000` | 20480 | Task |

The full list also has user log, billing and a few more. One type is a trap: online notifications (`0x0300`) are never returned by `load_interval` or `load_last`, because they are not stored on the server. The stored record of a triggered notification is the `0x4000` type.

`get_messages` reuses the names `flags` and `flagsMask` with the opposite meaning. There they exclude: a message is dropped when `flags` is non-zero and the bitwise AND of the message flags and `flags` equals `flagsMask`. With `flags` 65280 and `flagsMask` 0, data messages are removed from the response. The values are not interchangeable either: the `load_interval` pair for data messages (`flags` 0, `flagsMask` 65280) copied into `get_messages` excludes nothing, because `flags` 0 means no exclusion, and the call raises no error.

## Page through a large interval with get_messages

A month of messages for one unit can run to hundreds of thousands of records. Returning them in one response is slow, and a single oversized response is the common reason an extraction dies halfway. The loader exists so you do not have to: load once, then read slices by index.

`https://hst-api.wialon.com/wialon/ajax.html?sid=<sid>&svc=messages/get_messages&params={"indexFrom":0,"indexTo":5000}`

`indexFrom` is the first index and `indexTo` is exclusive: the message with that index is not returned. The reference example, `"indexFrom":8,"indexTo":9`, returns exactly one message, the one at index 8. If `indexTo` runs past the end you get messages up to the last one; if `indexFrom` is at or beyond the end you get an empty array. The response is a bare array of messages, with no `count` wrapper.

`get_messages` also accepts time-based selection, and the reference says the request must contain at least one complete pair: `timeFrom` with `timeTo`, `timeFrom` with `loadCount`, `timeTo` with `loadCount`, or the index pair. The documentation does not say whether `timeFrom` is inclusive, so a time cursor can repeat or skip messages that share a second. Index paging has no such ambiguity.

The official [request examples](https://help.wialon.com/en/api/user-guide/api-reference/messages/message-request-examples) show the pattern: load with `loadCount` 3 while `count` reports 9172, then fetch index 8. The loader therefore holds the whole found set, not only the messages returned by the first call. A paging loop in TypeScript:

`const HOST = "https://hst-api.wialon.com/wialon/ajax.html"; const PAGE = 5000; async function call < T >(sid: string, svc: string, params: object): Promise < T > { const res = await fetch (HOST, { method: "POST", body: new URLSearchParams ({ svc, params: JSON. stringify (params), sid }), }); const body = await res. json (); if (body &&! Array. isArray (body) && "error" in body) { throw new Error (`${ svc } failed with error ${ body. error }`); } return body as T; } async function* readMessages (sid: string, unitId: number, timeFrom: number, timeTo: number) { try { const first = await call <{ count: number; messages: object [] }>(sid, "messages/load_interval", { itemId: unitId, timeFrom, timeTo, flags: 1, flagsMask: 65281, loadCount: PAGE, }); yield first.messages; for (let from = PAGE; from < first.count; from += PAGE) { yield await call < object []>(sid, "messages/get_messages", { indexFrom: from, indexTo: from + PAGE }); } } finally { await call (sid, "messages/unload", {}); } }`

Run it one interval at a time per session, and size the intervals by days rather than months. Message loading is metered per user, not per session: 15 million messages loaded within two minutes, 200 million within an hour, and 15 million held across all of a user’s sessions, all from the [limitations page](https://help.wialon.com/en/api/user-guide/limitations). Hitting one returns error 1004 with the reason `LIMIT msgs_count`. The [error codes page](https://theassettrack.com/wialon-api/errors/) lays out the full budget, and the [rate-limit design guide](https://theassettrack.com/blog/wialon-api-rate-limits-and-resilient-sync-design/) covers retry and backoff, so this page does not repeat them. The `unload` in the `finally` block matters because the set lives in the session until you replace or clear it. `messages/unload` always returns an empty object, even when nothing is loaded, so calling it defensively costs nothing.

## Load the latest messages with load_last

When you want the most recent messages rather than an interval, use [messages/load_last](https://help.wialon.com/en/api/user-guide/api-reference/messages/load_last):

`https://hst-api.wialon.com/wialon/ajax.html?sid=<sid>&svc=messages/load_last&params={"itemId":<unitId>,"lastTime":1764633599,"lastCount":50,"flags":0,"flagsMask":65280,"loadCount":50}`

`lastTime` is the point in time the messages are requested for, and `lastCount` is how many messages to load. Two limits are documented: `lastCount` must be between 1 and 10000 or the call fails with error 4, and loading unit log messages (`0x1000`) requires the Manage object log access right. Without that right the log messages are silently left out and no error is returned, so an empty result for a log query is ambiguous until you check the unit’s access. The response has the same shape as `load_interval` and fills the same loader, so everything above about `get_messages` and `unload` applies.

## Read a data message and its parameters

A data message, the `0x0000` type, is what a tracker sends. From the [format reference](https://help.wialon.com/en/api/user-guide/data-format/messages#data-message):

`{ "t": 1764547261, "f": 3, "tp": "ud", "pos": { "y": 53.8396544, "x": 27.5608672, "z": 213, "s": 0, "c": 51, "sc": 9 }, "i": 0, "p": { "adc1": 12.606, "pwr_ext": 12.598, "param22": 3 }, "rt": 1764547262 }`

`t` is the message time in UTC and `rt` is when the server registered it. `tp` is the type, `ud` for data. In `pos`, `y` is latitude, `x` longitude, `z` altitude, `s` speed, `c` course and `sc` the satellite count. `lc` is the LBS checksum, and each message also has `tns`, the time in nanoseconds (Wialon Local from 2604).

The `f` field is a bit field, and reading it decides whether the other fields exist:

| Bit | Decimal | Meaning |
| --- | --- | --- |
| `0x01` | 1 | Location is available |
| `0x02` | 2 | Input data (`i`) is present |
| `0x04` | 4 | Output data (`o`) is present |
| `0x10` | 16 | Alarm bit |
| `0x20` | 32 | Driver code, in `dr` and the `avl_driver` parameter |
| `0x20000` | 131072 | Corrected by LBS |
| `0x40000` | 262144 | Registered during a private trip, location unavailable |

`pos` is `null` when the message has no location, which is routine: a message about an input change or a sensor reading carries parameters and no fix. Check bit 1 or `pos` before reading coordinates. This is the same split between position and message as on the units page, at the level of a single record. The `dr` field, and the matching `avl_driver` parameter, is where the driver codes from the [drivers page](https://theassettrack.com/wialon-api/drivers/) show up on the raw feed.

### What “Wialon parameters” means

The `p` object is the parameters of a message: a map from parameter name to value, where the format reference types the values as numbers. The example responses in the documentation use names such as `adc1`, `pwr_ext` and `param22`. This object is where everything a device reports beyond position lives, and the set of names depends on the device and how its messages are parsed, so build against the names you actually see in `load_interval` output for your own units, not against a list.

There are three ways to keep it manageable:

- **Trim at the source.** The `filter` parameter on `load_interval` and `get_messages` keeps only the matching parts of `pos` and `p`. Masks are comma separated, `*` matches zero or more characters and `?` exactly one. The documentation’s example `pos.x,p.pre*,p.param?` keeps `pos.x`, every parameter starting with `pre`, and `param5` but not `param`. The filter never touches `t`, `f`, `tp`, `i` or `o`, and if no `pos` field matches, `pos` comes back as an empty object. On a unit with dozens of parameters this is the difference between a response you can parse and one you wait for.
- **Read the accumulated values instead of the history.** The unit data flag 1048576 (`0x00100000`) adds a `prms` block to the unit: for each parameter name, its latest value `v`, the time of the last change `ct`, and the time of the last message that carried it `at`. For the question “what is this parameter now”, that is one unit request instead of a message load. The [unit format reference](https://help.wialon.com/en/api/user-guide/data-format/units) describes it.
- **Cap the list on busy units.** For units with a very large number of parameters, such as ones that relay Bluetooth tags, [core/set_prms_limit](https://help.wialon.com/en/api/user-guide/api-reference/core/set_prms_limit) limits how many of the most recent parameters the server returns per unit for the whole session, and the unit then reports the total in `prms_total`. It is not available in Wialon Local.

## Deal with the other message types

The data message is the common case, but the loader returns anything you select with `flags` and `flagsMask`. Events (`tp` of `evt`) carry the event text in `et`, coordinates in `x` and `y`, and details such as `evt_name` in `p`; their `f` bits mark violations, maintenance, fuel fillings and route progress. SMS messages (`us`) have `st` for the text and `mp` for the modem phone number. Commands (`ucr`) have the command name in `ca` and the execution time in `et`. All of these have the same envelope of `t`, `f`, `tp`, `rt` and `p`, and the [format reference](https://help.wialon.com/en/api/user-guide/data-format/messages) has the field tables.

Deleting is the one write operation in this section, and it is narrower than it looks. [messages/delete_message](https://help.wialon.com/en/api/user-guide/api-reference/messages/delete_message) takes a `msgIndex` and works only on a message of a unit that you loaded into the current session. The access right depends on the type: Delete messages for data messages, SMS and commands, Manage events for events. You cannot delete the last message or the last position of a unit; that returns error 4. Treat it as a destructive operation on the unit’s history, not a cleanup of your session.

## The errors you will meet

- **Error 4** on `load_interval` means a missing or mistyped parameter, for example a negative `timeFrom`. On `get_messages` it means no pair of parameters was given, or nothing is loaded. On `load_last` it also covers a `lastCount` outside 1 to 10000.
- **Error 7** means the item does not exist or does not store messages, or the user lacks the Request reports and messages right. The [token page](https://theassettrack.com/wialon-api/token/) covers access flags.
- **Error 1003** has two causes here: a missing `gzip` in `Accept-Encoding`, or the heavy-request ceiling with reason `LIMIT api_concurrent`. Read the `reason` field to tell them apart.
- **Error 1004** with `LIMIT msgs_count` is the message-loading budget. Wait for the window to clear and cut the interval size.

Wialon returns these with HTTP 200, so check the response body rather than the status. Everything else is on the [error codes page](https://theassettrack.com/wialon-api/errors/).

## Where next

Messages are the raw material; the [report execution](https://theassettrack.com/wialon-api/reports/) calls answer most questions about them without moving them over the wire, and the [notification engine](https://theassettrack.com/wialon-api/notifications/) produces the `0x4000` records you can read back here. The open-source [TypeScript SDK](https://theassettrack.com/wialon-api/sdk/) wraps `load_interval`, `load_last` and `unload` with the session handling above. If you need months of raw history queryable in SQL rather than re-extracted per request, that is what [FleetSQL](https://theassettrack.com/products/fleetsql/) stores.

Work with us

Rather not build this integration yourself?

We connect Wialon to ERP, TMS, CMMS and BI: a fixed quote after a free 30-minute call, from $500, with the source code and a runbook at handover.

What a build includes: [Wialon integration →](https://theassettrack.com/wialon-integration/)

[Book a free call](https://cal.com/sergey.govorunov/call) or send us a message

## Also in this reference

- ### Wialon TypeScript SDK: Typed Remote API Client
 Open-source TypeScript client for the Wialon Remote API: token login, units, trips, drivers, reports and typed errors, for Node and the browser.
 [Wialon TypeScript SDK: Typed Remote API Client](https://theassettrack.com/wialon-api/sdk/)
- ### Wialon MCP: Ask Claude About Your Wialon Fleet
 Connect Claude, ChatGPT, Cursor or Codex to Wialon over MCP: the hosted server, read-only sign-in, the agent skill, and when to build an API integration.
 [Wialon MCP: Ask Claude About Your Wialon Fleet](https://theassettrack.com/wialon-api/mcp/)
- ### Wialon API Token and Login: Sessions That Survive
 Wialon authorization end to end: the login form, token/login, token/update, the access-flag table, and the 100-day inaction rule that deletes idle tokens.
 [Wialon API Token and Login: Sessions That Survive](https://theassettrack.com/wialon-api/token/)
- ### Wialon API Errors: Codes 1, 4, 6, 7 and 1004
 The full Wialon Remote API error table, the 1003 reason variants, the quotas that produce each code, and how to classify them for retry logic.
 [Wialon API Errors: Codes 1, 4, 6, 7 and 1004](https://theassettrack.com/wialon-api/errors/)
- ### Wialon API in Postman: Authenticate in 10 Minutes
 The Wialon request format, the two headers and encodings that break every first call, and a Postman setup for an authenticated session.
 [Wialon API in Postman: Authenticate in 10 Minutes](https://theassettrack.com/wialon-api/postman/)
- ### Wialon API: Get a Unit's Last Position and Message
 Data flags, core/search_items, and the difference between last position and last message — the distinction behind the most-asked question on the SDK board.
 [Wialon API: Get a Unit's Last Position and Message](https://theassettrack.com/wialon-api/units/)
- ### Wialon Drivers API: Bind Drivers to Units
 Create drivers, bind them to units, read binding history over the Wialon Remote API — including the avl_driver auto-binding sensor.
 [Wialon Drivers API: Bind Drivers to Units](https://theassettrack.com/wialon-api/drivers/)
- ### Wialon API Reports: exec_report Without the Errors
 One report per session, the cleanup_result rule, the calls that cannot run alongside it, and the time limit that returns no rows instead of an error.
 [Wialon API Reports: exec_report Without the Errors](https://theassettrack.com/wialon-api/reports/)
- ### Wialon Geofence API: Create, Edit and Query Zones
 How the Wialon geofence API works: resource/update_zone for create, edit and delete, reading zones back, point lookups, groups and the entry/exit trigger.
 [Wialon Geofence API: Create, Edit and Query Zones](https://theassettrack.com/wialon-api/geofences/)
- ### Wialon API Notifications: Create, Edit, Enable
 resource/update_notification end to end — call modes, the trigger and action pair, schedules, and the response fields that make notifications diffable.
 [Wialon API Notifications: Create, Edit, Enable](https://theassettrack.com/wialon-api/notifications/)
- ### Wialon Retranslator: Protocols and Configuration
 The nine retranslation protocols Wialon can forward to, the update_config parameters each one uses, and where retranslation fits against an API pull.
 [Wialon Retranslator: Protocols and Configuration](https://theassettrack.com/wialon-api/retranslator/)
- ### Wialon IPS Protocol (v1.1 and v2.0): Packets and CRC16
 The Wialon IPS device protocol from the Gurtam spec: v1.1 vs v2.0 packets, login, data and black box fields, CRC16, response codes and a worked exchange.
 [Wialon IPS Protocol (v1.1 and v2.0): Packets and CRC16](https://theassettrack.com/wialon-api/ips/)
