Get started
Map Studio API
Guides

Draw and update zones

Draw and update zones

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:

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)

Draw a zone

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

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}'
Response (abridged)
{
  "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.

Update a zone

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

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}'
Response (abridged)
{
  "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.

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.

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}'
Response (abridged)
{
  "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.

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 -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}]'
Response
[
  {
    "id": "c40f8a25-7e63-4d19-b8a0-9f2e5c31d764",
    "name": "Tricot rockfall closure",
    "level": "warning",
    "status": "draft"
  }
]

Publish a zone

The public sees a zone once you publish it. A zone publishes the way an itinerary does: see publishing. Share it through a collection, since a zone has no share link of its own.

Next steps

Last updated