# Draw and update zones

> Canonical URL: https://docs.mountaya.com/en/apis/map-studio/zones/
> Last updated: 2026-11-27
> Rules for agents: https://docs.mountaya.com/llms.txt#rules-for-agents

Draw a zone by hand or compute it from a starting point, set its level and validity window, and list the zones in force.

A zone marks an area with something to say about it: a closure, an avalanche bulletin, a permit boundary. It carries a severity level and an optional validity window, and is published as an itinerary is.

## Before you start

Writes act as a member, so mint a session token that names one, as in the [quickstart](https://docs.mountaya.com/en/apis/map-studio/quickstart.md):

**cURL**

```bash
export MOUNTAYA_MEMBER_TOKEN=$(curl -s -X POST https://api.mountaya.com/v1/sessions \
  -H "X-API-Key: $MOUNTAYA_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"publishable_key\": \"$MOUNTAYA_PUBLISHABLE_KEY\", \"user_id\": \"7a4e1c98-3b52-4f60-9d81-c05e2f7a83b1\", \"surface\": \"studio-embedded\"}" \
  | jq -r .data.token)
```

**TypeScript**

```typescript
import { Mountaya } from "@mountaya/client";
import { MountayaAdmin } from "@mountaya/client/admin";

const publishableKey = process.env.MOUNTAYA_PUBLISHABLE_KEY ?? "";
const server = new Mountaya({
  credential: { secretKey: process.env.MOUNTAYA_SECRET_KEY ?? "" },
});
const { data: session } = await new MountayaAdmin(server).sessions.postSession({
  body: {
    publishable_key: publishableKey,
    user_id: "7a4e1c98-3b52-4f60-9d81-c05e2f7a83b1",
    surface: "studio-embedded",
  },
});

const mountaya = new Mountaya({ credential: { publishableKey, sessionToken: session.token } });
```

**Python**

```python
import os
import uuid

import requests


session = requests.post(
    "https://api.mountaya.com/v1/sessions",
    headers={"X-API-Key": os.environ["MOUNTAYA_SECRET_KEY"]},
    json={
        "publishable_key": os.environ["MOUNTAYA_PUBLISHABLE_KEY"],
        "user_id": "7a4e1c98-3b52-4f60-9d81-c05e2f7a83b1",
        "surface": "studio-embedded",
    },
    timeout=10,
).json()["data"]
```

## Draw a zone

Send the area as a GeoJSON Feature holding one Polygon, with a `level` that sets how a map styles it:

**cURL**

```bash
ZONE=$(curl -s -X POST https://api.mountaya.com/v1/zones \
  -H "X-API-Key: $MOUNTAYA_PUBLISHABLE_KEY" \
  -H "X-Session-Token: $MOUNTAYA_MEMBER_TOKEN" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d @- <<JSON
{
  "name": "Tricot rockfall closure",
  "level": "danger",
  "mode": "polygon",
  "is_private": false,
  "start_at": "2027-06-01T00:00:00Z",
  "end_at": "2027-09-30T23:59:59Z",
  "geojson": {
    "type": "Feature",
    "properties": {},
    "geometry": {
      "type": "Polygon",
      "coordinates": [[[6.7845, 45.8612], [6.7961, 45.8612], [6.7961, 45.8698], [6.7845, 45.8698], [6.7845, 45.8612]]]
    }
  }
}
JSON
)

ZONE_ID=$(echo "$ZONE" | jq -r .data.id)
echo "$ZONE" | jq '.data | {id, name, level, status, start_at, end_at}'
```

**TypeScript**

```typescript
const { data: zone } = await mountaya.studio.zones.postZone({
  body: {
    name: "Tricot rockfall closure",
    level: "danger",
    mode: "polygon",
    is_private: false,
    start_at: new Date("2027-06-01T00:00:00Z"),
    end_at: new Date("2027-09-30T23:59:59Z"),
    geojson: {
      type: "Feature",
      properties: {},
      geometry: {
        type: "Polygon",
        coordinates: [
          [
            [6.7845, 45.8612],
            [6.7961, 45.8612],
            [6.7961, 45.8698],
            [6.7845, 45.8698],
            [6.7845, 45.8612],
          ],
        ],
      },
    },
  },
});
const zoneId = zone.id;

console.log(zone.id, zone.level, zone.status);
```

**Python**

```python
zone = requests.post(
    "https://api.mountaya.com/v1/zones",
    headers={
        "X-API-Key": os.environ["MOUNTAYA_PUBLISHABLE_KEY"],
        "X-Session-Token": session["token"],
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={
        "name": "Tricot rockfall closure",
        "level": "danger",
        "mode": "polygon",
        "is_private": False,
        "start_at": "2027-06-01T00:00:00Z",
        "end_at": "2027-09-30T23:59:59Z",
        "geojson": {
            "type": "Feature",
            "properties": {},
            "geometry": {
                "type": "Polygon",
                "coordinates": [
                    [[6.7845, 45.8612], [6.7961, 45.8612], [6.7961, 45.8698], [6.7845, 45.8698], [6.7845, 45.8612]]
                ],
            },
        },
    },
    timeout=30,
).json()["data"]
zone_id = zone["id"]

print(zone["id"], zone["level"], zone["status"])
```

**Response (abridged)**

```json
{
  "id": "c40f8a25-7e63-4d19-b8a0-9f2e5c31d764",
  "name": "Tricot rockfall closure",
  "level": "danger",
  "status": "draft",
  "start_at": "2027-06-01T00:00:00Z",
  "end_at": "2027-09-30T23:59:59Z"
}
```

A new zone is a draft that only your members see. Its level is `info`, `warning`, `danger` or `resolved`. Leave out `start_at` and `end_at` for a zone in force from now on, with no end.

- `POST /v1/zones` answers `201`. Required: `name` (at most 30 characters, at least 2 once trimmed, unique in the organization, `409` naming the zone that holds it), `level`, `mode` and `is_private`, plus exactly one of `geojson` and `source`.
- `geojson` is a GeoJSON Feature whose geometry is one Polygon. Every ring is closed (its last position repeats its first) and holds at least four `[longitude, latitude]` positions; a third value is accepted and not kept. Any other geometry, a ring that crosses itself or another, a ring that touches itself, a hole outside its shell, or an outline that one meridian or parallel crosses more than 512 times is a `400` naming `geojson.geometry`, judged in degrees and once projected to Web Mercator. A feature `id` becomes the zone's id; one another zone already has is a `409`.
- `mode` records the tool the area was drawn with: `polygon`, `circle`, `sensor`, `sector` or `freehand`. Every mode stores one Polygon. A zone computed from a `source` is always `polygon`.
- `level` styles the zone and carries no access meaning. `is_private` decides who reads it once it is published: a private zone is reached only with your organization's key.
- `start_at` and `end_at` are the validity window: a zone with neither is in force from now on and never expires. An `end_at` earlier than `start_at` is a `400` naming `end_at`. The zone tiles filter on the window when asked for an instant, so an expired zone drops off such a map without being deleted.
- `organization_id` may name the key's organization and nothing else; left out, it is that organization. The organization must hold Map Studio (`402` otherwise). It needs the `studio-embedded` scope and a session token minted for `studio-embedded` naming a member with a write role.
- Creating zones is limited to 30 a minute per member and 300 a minute per organization (`429` with `Retry-After`).

## Update a zone

`PATCH` the fields that change. A field you leave out keeps its value:

**cURL**

```bash
curl -s -X PATCH https://api.mountaya.com/v1/zones/$ZONE_ID \
  -H "X-API-Key: $MOUNTAYA_PUBLISHABLE_KEY" \
  -H "X-Session-Token: $MOUNTAYA_MEMBER_TOKEN" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"level": "warning", "description": "Path reopened, rockfall still possible.", "end_at": "2027-10-31T23:59:59Z"}' \
  | jq '.data | {name, level, description, end_at}'
```

**TypeScript**

```typescript
const { data: updated } = await mountaya.studio.zones.patchZone({
  zone_id: zoneId,
  body: {
    level: "warning",
    description: "Path reopened, rockfall still possible.",
    end_at: new Date("2027-10-31T23:59:59Z"),
  },
});

console.log(updated.level, updated.description, updated.end_at);
```

**Python**

```python
updated = requests.patch(
    f"https://api.mountaya.com/v1/zones/{zone_id}",
    headers={
        "X-API-Key": os.environ["MOUNTAYA_PUBLISHABLE_KEY"],
        "X-Session-Token": session["token"],
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={
        "level": "warning",
        "description": "Path reopened, rockfall still possible.",
        "end_at": "2027-10-31T23:59:59Z",
    },
    timeout=30,
).json()["data"]

print(updated["level"], updated["description"], updated["end_at"])
```

**Response (abridged)**

```json
{
  "name": "Tricot rockfall closure",
  "level": "warning",
  "description": "Path reopened, rockfall still possible.",
  "end_at": "2027-10-31T23:59:59Z"
}
```

Send a new `geojson` to redraw the area, and `null` to clear the description or either end of the window.

- `PATCH /v1/zones/{zone_id}` answers `200` with the zone. `description`, `start_at` and `end_at` take `null` to clear, and `source: null` detaches the source and keeps the area as it stands; `name`, `level`, `mode`, `is_private` and `geojson` take no `null`. A `geojson` replaces the area whole, held to the rules of a create. A `mode` is sent with the area it describes, beside `geojson` or `source`; alone it is a `400` naming `mode`.
- An `end_at` earlier than the resulting `start_at`, sent or kept, is a `400` naming `end_at`. Renaming to a name another zone of the organization carries is a `409`.
- Every update writes a new revision, even one that changes nothing, and on a published zone sets `has_unpublished_changes`: the public sees the change at the next publish. `is_private` is the exception, read from the draft and in force at once.
- Send the zone's `etag` as `If-Match` to update only the version you read (`412` otherwise). Another member holding the zone's collaboration lock is a `409` naming them.
- `DELETE /v1/zones/{zone_id}` deletes the zone and removes it from every collection that held it. It cannot be undone.
- Updating zones is limited to 30 a minute per member and 300 a minute per organization.

## Compute a zone from a starting point

Send a `source` in place of `geojson`, and Mountaya computes the area: here, the ground reachable on foot within an hour of a trailhead.

**cURL**

```bash
REACHABLE=$(curl -s -X POST https://api.mountaya.com/v1/zones \
  -H "X-API-Key: $MOUNTAYA_PUBLISHABLE_KEY" \
  -H "X-Session-Token: $MOUNTAYA_MEMBER_TOKEN" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d @- <<JSON
{
  "name": "Tricot trailhead, one hour",
  "level": "info",
  "mode": "polygon",
  "is_private": false,
  "source": {
    "kind": "isochrones",
    "activity": "hiking-and-trail",
    "location": [6.7845, 45.8612],
    "range_type": "time",
    "range": 3600
  }
}
JSON
)

REACHABLE_ZONE=$(echo "$REACHABLE" | jq -r .data.id)
echo "$REACHABLE" | jq '.data | {id, name, mode, source}'
```

**TypeScript**

```typescript
const { data: reachable } = await mountaya.studio.zones.postZone({
  body: {
    name: "Tricot trailhead, one hour",
    level: "info",
    mode: "polygon",
    is_private: false,
    source: {
      kind: "isochrones",
      activity: "hiking-and-trail",
      location: [6.7845, 45.8612],
      range_type: "time",
      range: 3600,
    },
  },
});

console.log(reachable.id, reachable.source);
```

**Python**

```python
reachable = requests.post(
    "https://api.mountaya.com/v1/zones",
    headers={
        "X-API-Key": os.environ["MOUNTAYA_PUBLISHABLE_KEY"],
        "X-Session-Token": session["token"],
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={
        "name": "Tricot trailhead, one hour",
        "level": "info",
        "mode": "polygon",
        "is_private": False,
        "source": {
            "kind": "isochrones",
            "activity": "hiking-and-trail",
            "location": [6.7845, 45.8612],
            "range_type": "time",
            "range": 3600,
        },
    },
    timeout=30,
).json()["data"]

print(reachable["id"], reachable["source"])
```

**Response (abridged)**

```json
{
  "id": "3e9b7c14-5a20-4d6f-8b31-c7e04f9a2d58",
  "name": "Tricot trailhead, one hour",
  "mode": "polygon",
  "source": {
    "kind": "isochrones",
    "activity": "hiking-and-trail",
    "location": [6.7845, 45.8612],
    "range_type": "time",
    "range": 3600
  }
}
```

The zone keeps its `source`. Send it again in a `PATCH` to compute the area afresh.

- `source.kind` is `isochrones`: the area reachable from `location` (`[longitude, latitude]`) for `activity`, within `range` seconds (`range_type: "time"`, at most 7,200) or meters (`range_type: "distance"`, at most 25,000). `speed` (km/h) overrides the activity's pace, and only beside `time`. `ranges` lists every band the zone was created alongside, informational. `context` is stored and echoed back, at most 32 top-level fields and 4 KiB.
- A computed area that breaks the polygon rules, or holds more than 10,000 positions, is a `400` naming `source`: change the location or the range, or draw the zone.
- A zone given a `source` must be `polygon`. A `PATCH` sending a `geojson` to a computed zone replaces the area and detaches the source.
- Each computation is recorded as the organization's `studio-embedded` data usage, never counted toward the Data API's limits, allowance or invoice.

## List the zones in force

`active_at` lists the zones whose window holds that instant. With a member's token, the listing holds drafts and private zones too:

**cURL**

```bash
curl -s "https://api.mountaya.com/v1/zones?active_at=2027-07-15T12:00:00Z&level=warning" \
  -H "X-API-Key: $MOUNTAYA_PUBLISHABLE_KEY" \
  -H "X-Session-Token: $MOUNTAYA_MEMBER_TOKEN" \
  | jq '[.data[] | {id, name, level, status}]'
```

**TypeScript**

```typescript
const { data: inForce } = await mountaya.studio.zones.getZones({
  query: { active_at: "2027-07-15T12:00:00Z", level: "warning" },
});

console.log(inForce.map(({ id, name, level, status }) => ({ id, name, level, status })));
```

**Python**

```python
in_force = requests.get(
    "https://api.mountaya.com/v1/zones",
    headers={
        "X-API-Key": os.environ["MOUNTAYA_PUBLISHABLE_KEY"],
        "X-Session-Token": session["token"],
    },
    params={"active_at": "2027-07-15T12:00:00Z", "level": "warning"},
    timeout=30,
).json()["data"]

print([{key: listed[key] for key in ("id", "name", "level", "status")} for listed in in_force])
```

**Response**

```json
[
  {
    "id": "c40f8a25-7e63-4d19-b8a0-9f2e5c31d764",
    "name": "Tricot rockfall closure",
    "level": "warning",
    "status": "draft"
  }
]
```

- `GET /v1/zones` lists the key's organization, a page at a time: follow `extensions.metadata.pagination.next_cursor` until it is `null`. Filters: `status`, `is_private`, `level`, `mode`, `active_at`, `updated_since` and `q`; `sort` by `updated_at` (newest first by default), `created_at` or `name`.
- A publishable key alone, or with a token minted without `user_id`, lists public zones only, and only while published, as last published. A member's token lists drafts and private zones and serves each zone's draft.
- `GET /v1/zones/{zone_id}` reads one zone with its full area, the geometry to edit from.

## Publish a zone

The public sees a zone once you publish it. A zone publishes the way an itinerary does: see [publishing](https://docs.mountaya.com/en/apis/map-studio/publishing.md#zones). Share it through a [collection](https://docs.mountaya.com/en/apis/map-studio/sharing.md), since a zone has no share link of its own.

## Next steps

- [Publishing](https://docs.mountaya.com/en/apis/map-studio/publishing.md#zones): Show a zone to the public.
- [Zones reference](https://docs.mountaya.com/en/apis/map-studio/reference/zones.md): Every field and refusal of a zone write.
