---
metadata:
  - name: generator
    content: Diplodoc Platform v5.19.6
alternate:
  - https://docs.routeq.com/doc/en/vrp/geozones.md
  - https://docs.routeq.com/doc/tr/vrp/geozones.md
title: RouteQ — geofences
---
> **Documentation Index:** Fetch the complete configuration index at https://docs.routeq.com/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://docs.routeq.com/doc/en/vrp/properties-of-vehicles.md#geozones).

{% include [geozones-orders-in-geofences](_includes/orders-in-geofences-f060ee25f0d5.md) %}

{% include [zones-and-pickup-to-delivery](_includes/zones-and-pickup-to-delivery-7982a12ca7d4.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://docs.routeq.com/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://docs.routeq.com/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://docs.routeq.com/doc/en/vrp/interface-geozones.md)).
1. Plan a route using an [Excel file](https://docs.routeq.com/doc/en/vrp/example.md).
1. When you [manage optimization settings](https://docs.routeq.com/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://docs.routeq.com/doc/en/vrp/interface-geozones.md#geozones-public).

## 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://docs.routeq.com/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://docs.routeq.com/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://docs.routeq.com/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>
```

{% include [warehouse-feedback](_includes/feedback-81845556eeea.md) %}
