---
title: "Wialon Geofence API: Create, Edit and Query Zones"
url: https://theassettrack.com/wialon-api/geofences/
description: "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

Reference · last checked December 1, 2026

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.

The Wialon geofence API is a handful of commands on the resource service, and the official reference splits them across six separate pages with different naming (the API says “zone”, the interface says “geofence”, the SDK samples say both). This page puts the whole loop in one place: create a geofence, read it back, edit or delete it, ask which geofences contain a point, group geofences, and fire a notification when a unit enters or leaves one. Where the reference is unclear, the text says so instead of guessing.

If the request format is new to you, read the [Postman setup](https://theassettrack.com/wialon-api/postman/) first. Everything below is a call to `wialon/ajax.html` with `svc` and `params`, authenticated with a session id from the [token page](https://theassettrack.com/wialon-api/token/).

## Geofences belong to a resource

A geofence is a subitem of a resource, like drivers and notifications. Every command takes the resource id as `itemId`, and a geofence id is only meaningful together with it. The reference makes this visible in `resource/get_zones_by_point`, which takes zones as `{"<resource id>":[<geofence id>,...]}`, and in `resource/get_zone_data`, where `id` is described as the zone id inside the resource’s zone array. Two resources can both have a geofence with the same id, so never store a bare geofence id.

Two limits from the [Wialon help center](https://help.wialon.com/en/wialon-hosting/user-guide/requirements-and-limitations/limitations) matter for integrations that create zones in bulk:

- No more than 31,744 micro-objects of each type (geofences, notifications, drivers and so on) per resource. Geofences in the trash count toward it.
- No more than 5000 points per geofence if you want to be able to edit it. A geofence saved from a track is capped at 10,000 points and split into several geofences beyond that.

## Create a geofence

Create, edit and delete all go through one command, [`resource/update_zone`](https://sdk.wialon.com/wiki/en/kit/remoteapi/apiref/resource/update_zone). A polygon around a depot:

`https://hst-api.wialon.com/wialon/ajax.html?sid=<sid>&svc=resource/update_zone&params={"itemId":<resourceId>,"id":0,"callMode":"create","n":"Depot North","d":"Main yard","t":2,"w":0,"f":32,"c":1090453504,"tc":0,"ts":12,"min":0,"max":18,"p":[{"x":27.5612,"y":53.9006,"r":0},{"x":27.5701,"y":53.9006,"r":0},{"x":27.5701,"y":53.8951,"r":0},{"x":27.5612,"y":53.8951,"r":0}]}`

| Name | Meaning |
| --- | --- |
| `itemId` | Resource id, the geofence’s parent |
| `id` | Geofence id; `0` creates |
| `callMode` | `create`, `update`, `delete` or `reset_image` |
| `n`, `d` | Name and description |
| `t` | Type: `1` line, `2` polygon, `3` circle |
| `w` | Line thickness or circle radius |
| `f` | Flags, see below |
| `c` | Colour |
| `tc`, `ts` | Label text colour and font size |
| `min`, `max` | Show on the map from this zoom level, up to this zoom level |
| `path`, `libId` | Short path to the default icon and the icon library id (`0` is the default library) |
| `jp` | Custom JSON |
| `p` | Points: `x` is longitude, `y` is latitude, `r` is radius |
| `oldItemId`, `oldZoneId` | Resource and geofence to copy from |

Things the reference leaves vague, and what to do about them:

- **Which parameters are optional.** The page lists every field and says only that the others are required for create and update. The example above sends the full set, which is the safe choice. Trim it only after you have seen your account accept the shorter version.
- **Colour format.** `resource/get_zone_data` and `resource/create_zone_by_track` describe the colour as ARGB, while the `update_zone` response block says “color RGB”. The example value is a semi-transparent red under the ARGB reading. Create one geofence in the Wialon interface with the colour you want, read it back with `get_zone_data`, and copy the integer you get.
- **Circles.** The reference describes `w` as “line thickness or circle radius” and also lists `r` on each point, but does not say which one carries a circle’s radius on create. Do the same trick: draw a circle in the interface, read it back, and mirror the shape.
- **Polygon closure.** Nothing says whether the first point must be repeated at the end. Read back a polygon drawn in the interface to see what the server stores.

The flag values for `f` are listed on the [get_zone_data page](https://sdk.wialon.com/wiki/en/kit/remoteapi/apiref/resource/get_zone_data): `0x10` is “mandatory for using parameter line width”, `0x20` shows the shape, `0x40` means do not simplify. As everywhere in this API, JSON carries decimal numbers, so `0x20` goes in as `32`. For a line geofence, set the `0x10` bit together with `w`, for example `f` of `48` (`0x10` plus `0x20`).

On create and update the call returns `[<geofenceId>, {...}]` with the full stored record: name, type, flags, colour, a bounding box `b` and a creation and modification time `ct` and `mt`. Read the record rather than assuming your input was stored verbatim.

## Edit, copy and delete

The same call, the same parameters, a different `callMode`:

- `update` with the real `id` and the full new shape. Send the whole definition, including `p`, not only the field you changed.
- `delete` needs only `itemId`, `id` and `callMode`. It returns `[<id>, null]`.
- `reset_image` removes a geofence’s custom image. Uploading one is a separate multipart call, [`resource/upload_zone_image`](https://sdk.wialon.com/wiki/en/kit/remoteapi/apiref/resource/upload_zone_image).
- To copy a geofence, pass `oldItemId` and `oldZoneId` naming the source. The reference says this also lets you edit the copy in the same call, which suits cloning a standard zone template across resources.

## List geofences without downloading every point

The geofences of a resource arrive through `core/search_items` with the geofence data flag. Flag `0x1000` is `4096`, and `0x100000` (`1048576`) is geofence groups:

`svc=core/search_items&params={"spec":{"itemsType":"avl_resource","propName":"sys_name","propValueMask":"*","sortType":"sys_name"},"force":1,"flags":4096,"from":0,"to":0}`

The [resource data format page](https://sdk.wialon.com/wiki/en/kit/remoteapi/apiref/format/resource) shows what comes back: a `zl` object keyed by sequence number, with `n`, `d`, `id`, `f`, `t`, a checksum `e` and the bounding box `b`, plus `zlmax`, the maximum geofence count (`-1` is unlimited). There are no points in that list. It is a summary for rendering: the bounding box is enough to draw a marker or filter by area, and the `e` checksum is the natural field to compare when you check what changed.

To get points, area and perimeter, ask for specific geofences with [`resource/get_zone_data`](https://sdk.wialon.com/wiki/en/kit/remoteapi/apiref/resource/get_zone_data):

`svc=resource/get_zone_data&params={"itemId":<resourceId>,"col":[<id1>,<id2>],"flags":29}`

`col` lists geofence ids and `flags` picks the blocks of the response:

| Flag | Dec | Returns |
| --- | --- | --- |
| `0x01` | 1 | Area (`ar`) |
| `0x02` | 2 | Perimeter (`pr`) |
| `0x04` | 4 | Boundary and centre (`b`) |
| `0x08` | 8 | All points (`p`) |
| `0x10` | 16 | Basic properties |

The documented default is `0x1C`, which is `28`: boundary, all points and basic properties, no area or perimeter. The example above adds area with `29`. A sensible pattern for a sync job: list with `4096`, compare the `e` checksums against your stored copy (the reference only calls it a CRC16 check sum, so verify that it changes when you edit a shape), and call `get_zone_data` only for the ids that changed. The [rate-limit-safe sync design](https://theassettrack.com/blog/wialon-api-rate-limits-and-resilient-sync-design/) covers why that matters once you have thousands of zones.

If you work in JavaScript, the SDK playground has a ready [Get geofences](https://sdk.wialon.com/playground/demo/get_geofences) sample built on `resource.getZones()`. The [SDK page](https://theassettrack.com/wialon-api/sdk/) covers when the SDK is worth loading and when plain `ajax.html` calls are enough.

## Find which geofence contains a point

[`resource/get_zones_by_point`](https://sdk.wialon.com/wiki/en/kit/remoteapi/apiref/resource/get_zones_by_point) answers “where is this coordinate” without downloading any shapes:

`svc=resource/get_zones_by_point&params={"spec":{"lat":53.8980,"lon":27.5650,"radius":100,"zoneId":{"<resourceId>":[]}}}`

`zoneId` is `{"<resource id>":[<geofence id>,...]}`, and an empty array means all geofences of that resource. `radius` is the search radius in metres. The response is a list with one object per resource, mapping each geofence id to a distance in metres: `0` when the point is inside, a positive distance when it is outside. That makes the same call a nearest-geofence lookup. The reference does not say whether geofences beyond `radius` are left out of the result, so filter on the distance yourself instead of relying on it.

This is the call to use for reverse lookups on stored positions: take a unit’s last position from the [units page](https://theassettrack.com/wialon-api/units/) pattern and ask which yard it is in. For a time series, it is cheaper to let the server do the work through a report or a notification than to call this per message.

## Create a geofence from a track

[`resource/create_zone_by_track`](https://sdk.wialon.com/wiki/en/kit/remoteapi/apiref/resource/create_zone_by_track) turns a unit’s track into a line geofence:

`svc=resource/create_zone_by_track&params={"layerName":"<trackLayerName>","itemId":<resourceId>,"unitId":<unitId>,"n":"Route 12","c":1090453504,"w":30}`

The response is `{"all_zones":<uint>,"created_zone":<uint>}`. The reference explains `all_zones` as the number of new geofences, with 10,000 points to one, which matches the help center limit above: a long track becomes several geofences, so check `all_zones` instead of assuming one. The reference does not explain what `layerName` refers to beyond “track layer name”, so this call is easiest to use when the track layer already exists in the session.

## Geofence groups

Groups are a separate subitem with their own command, [`resource/update_zones_group`](https://sdk.wialon.com/wiki/en/kit/remoteapi/apiref/resource/update_zones_group), and the same call modes minus `reset_image`:

`svc=resource/update_zones_group&params={"itemId":<resourceId>,"id":0,"callMode":"create","n":"Customer yards","d":"","zns":[101,102,103],"f":0}`

`zns` is the array of geofence ids, and `f` is documented as not used at the moment. The response is `[<groupId>, {"id":..,"n":..,"d":..,"zns":[..]}]`. You read groups back with `core/search_items` and the flag `1048576`, which returns a `zg` object and a `zgmax` limit.

## Fire a notification on entry or exit

Wialon has no separate “geofence alert” object. Entering and leaving a geofence is a trigger on an ordinary notification, created with `resource/update_notification` exactly as described on the [notifications page](https://theassettrack.com/wialon-api/notifications/). The geofence part is the `trg` value. In the reference’s [notification data format](https://sdk.wialon.com/wiki/en/kit/remoteapi/apiref/resource/get_notification_data), the control type is `geozone`:

`"trg":{"t":"geozone","p":{"geozone_ids":"101,102","type":0}}`

`geozone_ids` is a comma-separated string of geofence ids, and `type` is `0` to control entries and `1` to control exits. The reference block also lists `min_speed`, `max_speed`, `include_lbs`, `lo` and a group of sensor fields. The sensor fields look carried over from another control type. The safest approach is to create one geofence notification in the interface, read it back with `get_notification_data`, and copy its `trg` shape rather than building it from the printed block.

Geofence ids are only unique within a resource, and the reference does not say how `geozone_ids` handles another resource’s geofences, so keep the geofences and the notification on the same resource.

## What breaks

The reference has no error list specific to geofence calls, so the general [error codes](https://theassettrack.com/wialon-api/errors/) apply, and these are the usual causes:

- **Error 4 (invalid input).** The parameter shape for the call mode is wrong. For `delete`, send only `itemId`, `id` and `callMode`. For `create` and `update`, send the full definition, including `p` as an array of objects.
- **Error 7 (no rights).** The session has no rights on the resource. Check the token’s access flags on the [token page](https://theassettrack.com/wialon-api/token/), and on the resource itself.
- **A Geofences tab that is missing in the interface.** The help center says the **Geofences: Access** service must be enabled in the account or billing plan. If geofence calls misbehave on one account and work on another, check that service first.
- **A geofence that “does not exist”.** The id came from a different resource. Qualify every id with its resource.

## Where next

Geofence data feeds the [notification engine](https://theassettrack.com/wialon-api/notifications/) for entry and exit alerts and the [report execution](https://theassettrack.com/wialon-api/reports/) behind visit and dwell-time reports. If you use geofences as business objects such as customers, depots or delivery zones, treat Wialon as the place they are drawn and your own database as the place they are keyed: sync the `e` checksums on a schedule, store the resource id with every geofence id, and diff locally.

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 Messages API: load_interval, Flags and Paging
 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](https://theassettrack.com/wialon-api/messages/)
- ### 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 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/)
