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

# Manage delivery zones

> Create, update, and list a connected location’s delivery zones, and check whether a coordinate is deliverable.

Delivery zones define where a location delivers. Each zone is a GeoJSON polygon with a delivery fee and optional ordering constraints (minimum order, maximum distance, priority). All delivery-zone endpoints require an **active connection** to the location — only the app acting as the location's order receiver can manage its zones.

## Scopes

* `delivery_zones:read` — list zones, get a zone, and check coverage.
* `delivery_zones:write` — create, update, and delete zones.

## Create a zone

Zone names must be unique per location. `polygon` is a GeoJSON `Polygon` of `[longitude, latitude]` rings — the first ring must be closed (first and last points equal).

```bash theme={null}
curl -X POST $MAPLE_BASE/locations/{locationId}/delivery_zones \
  -H "Authorization: Bearer $MAPLE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Downtown",
    "polygon": {
      "type": "Polygon",
      "coordinates": [
        [
          [-74.02, 40.70],
          [-73.99, 40.70],
          [-73.99, 40.73],
          [-74.02, 40.73],
          [-74.02, 40.70]
        ]
      ]
    },
    "delivery_fee_cents": 450,
    "priority": 0
  }'
```

`delivery_fee_cents` defaults to `0`, `is_active` to `true`, `priority` to `0`, and `zone_type` to `polygon`. The response is the created `delivery_zone` object; use its `id` for the zone endpoints.

Coverage checks always evaluate `polygon`. `zone_type: 'circle'` and `radius_miles` are descriptive metadata only — for a circle zone, submit a polygon that approximates the circle.

## List zones

```bash theme={null}
curl $MAPLE_BASE/locations/{locationId}/delivery_zones \
  -H "Authorization: Bearer $MAPLE_KEY"
```

Returns `{ "object": "list", "data": [...] }` containing only **active** zones.

## Update a zone

`PATCH` changes only the fields you send:

```bash theme={null}
curl -X PATCH $MAPLE_BASE/locations/{locationId}/delivery_zones/{zoneId} \
  -H "Authorization: Bearer $MAPLE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "delivery_fee_cents": 550 }'
```

## Delete a zone

Deletes deactivate the zone (it drops out of list results and coverage checks):

```bash theme={null}
curl -X DELETE $MAPLE_BASE/locations/{locationId}/delivery_zones/{zoneId} \
  -H "Authorization: Bearer $MAPLE_KEY"
```

## Check whether a coordinate is deliverable

Before quoting a delivery, check the customer's coordinates against the location's zones:

```bash theme={null}
curl -X POST $MAPLE_BASE/locations/{locationId}/delivery_zones/check \
  -H "Authorization: Bearer $MAPLE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "latitude": 40.7128, "longitude": -74.006 }'
```

The response is a `delivery_zone_check`: `in_zone` tells you the location delivers there, and when true `zone` carries the matching zone and `delivery_fee_cents` its fee. When false, both are `null`.

Zone `get`/`update`/`delete` return `404` for a zone that belongs to a different location — a partner can only ever touch zones owned by the location in the path.
