---
metadata:
  - name: generator
    content: Diplodoc Platform v5.52.0
alternate:
  - https://yandex.kz/routing/doc/en/vrp/geozones.md
  - https://yandex.kz/routing/doc/kk/vrp/geozones.md
  - https://yandex.kz/routing/doc/ru/vrp/geozones.md
  - https://yandex.kz/routing/doc/tr/vrp/geozones.md
  - href: en/vrp/geozones.md
    type: text/markdown
    title: Markdown version
  - href: llms.txt
    type: text/markdown
    title: llms.txt
title: RouteQ — geofences
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.kz/routing/doc/en/llms.txt


# Geofences 

You can use geofences to set restrictions when planning routes and take into account vehicle characteristics, access conditions, and terrain features. For more information, see [Vehicle](https://yandex.kz/routing/doc/en/vrp/properties-of-vehicles.md#geozones).

<!-- source: en/vrp/_includes/orders-in-geofences.md -->
When orders are being assigned, geofence incompatibility is taken into account: both the [global option](https://yandex.kz/routing/doc/en/vrp/options-geozones.md#incompatible-zones) and the values set for [individual couriers](https://yandex.kz/routing/doc/en/vrp/options-geozones.md#incompatible-zones). When planning routes, you can also [cancel all limits](https://yandex.kz/routing/doc/en/vrp/options-geozones.md#incompatible-zones) related to geofences.
<!-- endsource: en/vrp/_includes/orders-in-geofences.md -->

<!-- source: en/vrp/_includes/zones-and-pickup-to-delivery.md -->
If orders are [related](https://yandex.kz/routing/doc/en/vrp/properties-of-orders.md#pickup-and-delivery) by types `pickup` and `delivery`, and one of the orders belongs to a [geofence](https://yandex.kz/routing/doc/en/vrp/interface-geozones.md), then the other order will also belong to this geofence.
<!-- endsource: en/vrp/_includes/zones-and-pickup-to-delivery.md -->

{% note info %}

You can add no more than 500 geofences for a single company.

{% endnote %}

To remove restrictions for one or more orders in a route, use the `ignore_zones_compatibility` parameter. For more information, see [Order incompatibility and geofences](https://yandex.kz/routing/doc/en/vrp/properties-of-orders.md#order-incompatibility-zones).

## Geofences in the interface  {#geozones-interface}

You can manage geofences from the [master data](https://yandex.kz/routing/doc/en/vrp/interface-geozones.md) using the Planning interface. To do this:

1. Define geofences in **Master data** → **Geofences** (for more information, see [Geofence master data](https://yandex.kz/routing/doc/en/vrp/interface-geozones.md)).
1. Plan a route using an [Excel file](https://yandex.kz/routing/doc/en/vrp/example.md).
1. When you [manage optimization settings](https://yandex.kz/routing/doc/en/vrp/interface-import.md#step-3) on the **Settings** tab, select **Consider geofences** → **Yes**.

When planning routes, orders will be automatically assigned to zones by their coordinates.

You can also use [public geofences](https://yandex.kz/routing/doc/en/vrp/interface-geozones.md#geozones-public):

<!-- source: en/vrp/_includes/public-zones.md -->
- `public_inside_ttk`: The area inside the TTK.
- `public_inside_mkad`: The area between the MKAD and TTK (not including the area inside the TTK).
- `public_inside_gr`: The area inside the Garden Ring.
- `public_ttk_gr`: The area between the TTK and the Garden Ring.
<!-- endsource: en/vrp/_includes/public-zones.md -->

## Geofences in the API {#geozones-api}

You can work with geofences in the API in one of the following ways:

- Using [API methods](#geozones-methods-api).
- Using [geofences from the master data](https://yandex.kz/routing/doc/en/vrp/interface-geozones.md).
- Setting [geofence boundaries by coordinates](#geozones-zones) in the planning task.

### API methods for working with geofences {#geozones-methods-api}

[API methods](https://yandex.ru/routing/doc/en/vrp/redoc/index.html#tag/zones) can be effectively used in the following situations:

- You create and edit geofences in a third-party service, update the geofence master data in RouteQ using the methods for [adding](https://yandex.ru/routing/doc/en/vrp/redoc/index.html#operation/addsCompanyZonesToReferenceBook), [editing](https://yandex.ru/routing/doc/en/vrp/redoc/index.html#operation/patchesCompanyZoneFromReferenceBook), and [deleting](https://yandex.ru/routing/doc/en/vrp/redoc/index.html#operation/deletesCompanyZoneFromReferenceBook) geofences, and then use this master data for planning.

    {% cut "Sample JSON" %}

    This example creates a geofence named `zone_1` with an empty area inside. The geofence is displayed in green in the interface.

    ```json
    [
    {
        "number": "zone_1",
        "polygon":{
        "type": "Polygon",
        "coordinates": [
            [
            [
                37.453341832031036,
                55.47515872719678
            ],
            [
                37.41900955664041,
                55.42715840626307
            ],
            [
                37.466388096679474,
                55.36384893358992
            ],
            [
                37.609897007812286,
                55.36658663328021
            ],
            [
                37.69916092382792,
                55.42832984374252
            ],
            [
                37.6126435898435,
                55.48412788836129
            ],
            [
                37.51788650976538,
                55.4899762368179
            ],
            [
                37.453341832031036,
                55.47515872719678
            ]
            ],
            [
            [
                37.49866043554666,
                55.44862921459692
            ],
            [
                37.58174454199197,
                55.454482853927836
            ],
            [
                37.616763462890425,
                55.41231717677708
            ],
            [
                37.515826573241974,
                55.39668877847346
            ],
            [
                37.49866043554666,
                55.44862921459692
            ]
            ]
        ]
        },
        "color_edge": "rgb(0,179,65)",
        "color_fill": "rgb(0,179,65)"
    }
    ]
    ```

    {% endcut %}

- You create and edit geofences in the [RouteQ interface](https://yandex.kz/routing/doc/en/vrp/interface-geozones.md) and then upload them to your corporate system using the [Get company geofence](https://yandex.ru/routing/doc/en/vrp/redoc/index.html#operation/getsCompanyZoneFromReferenceBook) or [Get company geofence master data](https://yandex.ru/routing/doc/en/vrp/redoc/index.html#operation/getsCompanyZonesFromReferenceBook) methods.
    
To work with geofences using the API, send a request to the [mvrp resource with OAuth authorization](https://yandex.ru/routing/doc/en/vrp/redoc/index.html#tag/mvrpaddsATask):

```bash
curl -H "Content-Type: application/json" -H "Authorization: OAuth <your-token>" -X POST -d <request body> https://courier.yandex.ru/api/v1/vrs/add/mvrp
```

In the `Authorization: OAuth <your-token>` header, change `<your-token>` to the [OAuth token](https://yandex.kz/routing/doc/en/delivery/quickstart/register.md) that you received for Track & Trace.

{% note alert %}

The path in the authorization request (with an OAuth token) is different from the path indicated in the [specifications](https://yandex.ru/routing/doc/en/vrp/redoc/index.html#operation/addMVRPTask) (with an API key).

{% endnote %}


### Setting geofences using coordinates {#geozones-zones}

To set geofence coordinates right in your planning task, create a `zones` object in the request. Each element of this item describes one geofence and contains the coordinates of the polygon vertices.

To obtain coordinates, use the tools of the [Yandex Map Constructor](https://yandex.com/map-constructor:

1. Draw a geofence using the **Polygons** tool (for more information, see [Create an item](https://yandex.com/support/maps-builder/concept/markers_1.html) in Yandex Map Constructor Help).
1. Click **Save and continue** → **Export** (for more information, see [Exporting map items](https://yandex.com/support/maps-builder/concept/markers_3.html) in Yandex Map Constructor Help).
1. Select **GeoJSON** → **Download**.
1. Use the `geometry` item in the request to form the `zones` item.

    {% cut "Sample geofence description in a request" %}
    ```json
            "zones": [
        {
                "id": "zone1",
                "geometry":{
                    "type": "Polygon",
                    "coordinates": [
                        [
                            [
                                37.3890158054755,
                                55.8142956464218
                            ],
                            [
                                37.4755331394599,
                                55.7415407888477
                            ],
                            [
                                37.5716635105537,
                                55.7984405246533
                            ],
                            [
                                37.5847097752021,
                                55.799987651288
                            ],
                            [
                                37.3890158054755,
                                55.8142956464218
                            ]
                        ]
                    ]
                }
            }
         ]
    ```
    {% endcut %}

To set geofences using coordinates, send a request to the [mvrp](https://yandex.ru/routing/doc/en/vrp/redoc/index.html#operation/addMVRPTask) resource:

```bash
curl -H "Content-Type: application/json" -X POST -d <request body> https://courier.yandex.ru/vrs/api/v1/add/mvrp?apikey=<API key>
```

<!-- source: en/vrp/_includes/feedback.md -->
<a href="feedback">
  <span class="button">Contact support</span>
</a>


<!-- endsource: en/vrp/_includes/feedback.md -->
