# Collections

> Canonical URL: https://docs.mountaya.com/en/apis/tiles/reference/collections/
> Last updated: 2026-11-26
> Rules for agents: https://docs.mountaya.com/llms.txt#rules-for-agents

A collection's itineraries and zones as tiles, addressed by the collection rather than one resource at a time.

## Retrieve the tile specification for a collection

### GET /v1/collections/{collection_id}/specification

- Operation: `getCollectionSpecification`
- Requires: scope `tiles`
- Behavior: idempotent, safe to retry · answers within 30000 ms or times out

Returns the tile specification (sources and layers) for rendering a collection on a MapLibre GL map. The response includes tile URLs, layer configuration, paint properties, and zoom range constraints needed to add the collection as a vector source.

Collection tiles carry zone and itinerary layers. Zone layers are painted by zone level (info, warning, danger, resolved); itinerary layers take their color per feature, and a feature that carries none falls back to a fixed default color, the last argument of the `coalesce` in the layer's `paint`.

The declared layers are narrowed by the resolved `with_zones` and `with_itineraries` toggles, whatever the credential, and on a publishable-key request those toggles are clamped to the organization's safety rules, so the specification never declares a layer the toggles switch off. They are not narrowed by what the credential may see: the tile draws only the members this credential could list, so the zone layer declared to a publishable key without a session token naming a member draws the collection's published public zones alone, and every layer of another organization's collection stays empty.

The answer also carries `bbox`, the extent of the itineraries the tiles draw for this same credential, the same `surface` and the same `with_itineraries`, so an embed opens on the whole collection: fit the map's camera to it once the sources are registered. Zones do not count toward it, it is not clipped to the organization's geographic boundaries, and it is null when the tiles draw no itinerary. Ask for the specification with the `surface` the tiles are asked for with, so the two agree.

A publishable key needs the `tiles` scope, or `publishing` on a request from a page on Mountaya's own domain. A share token carries its own authority and needs none.

**Path parameters**

- `collection_id` (string (uuid), in path, required): Identifier of the collection the operation acts on. A collection this credential does not reach is a 404 rather than a 403, and so is one that does not exist, so the parameter cannot be used to learn which collection ids exist.

**Query parameters**

- `surface` (string, in query, optional, one of: `published`): Reads the published snapshot rather than the draft. `published` is the only accepted value: there is deliberately no `draft` spelling, because the param only ever narrows what the caller is served. An unrecognized value is rejected with a validation error rather than silently ignored. A read of one itinerary, or of one zone, refuses it with `403` when it is personal, owned by no organization, to the person whose it is: the published surface is what a video and an embed are made of, and a personal itinerary or zone makes neither. Every other caller reads a personal itinerary or zone as published, and since one is never published it is answered as one that does not exist.

- `with_zones` (boolean, in query, optional): Whether the collection's zones are part of the answer. On this route that is the zone layers the specification declares.

  It declares no `default`, and that is deliberate rather than an omission: the value when the parameter is absent is the organization's own default for this layer, clamped to its safety rules for a publishable-key caller, so there is no one figure this document could publish. For a request from Mountaya's web application, which names no organization of its own, that organization is Mountaya's own, and its default is not clamped. Sending it explicitly is the way to decide it per request, within the rule: on a publishable-key request an explicit `true` is still capped by the organization's safety rule.

- `with_itineraries` (boolean, in query, optional): Whether the collection's itineraries are part of the answer. On this route that is the itinerary layers the specification declares, `itinerary_lines` and `itinerary_points`.

  It declares no `default`, and that is deliberate rather than an omission: the value when the parameter is absent is the organization's own default for this layer, clamped to its safety rules for a publishable-key caller, so there is no one figure this document could publish. For a request from Mountaya's web application, which names no organization of its own, that organization is Mountaya's own, and its default is not clamped. Sending it explicitly is the way to decide it per request, within the rule: on a publishable-key request an explicit `true` is still capped by the organization's safety rule.

Also takes `Accept-Language`, as every operation of this API does: the [overview](https://docs.mountaya.com/en/apis/tiles/reference.md) describes it.

**Response** `200`

Tile specification: the sources and render-layers to register before the map starts fetching this resource's `{z}/{x}/{y}` tiles, and `bbox`, the extent of the itineraries they draw, to fit the camera to.

- `extensions` (object): Top-level extensions map for 2xx responses. Mirrors the GraphQL-spec response extensions: a free-form map for response-scoped metadata.
  - `metadata` (object): Response-scoped metadata. Its shape is per-operation: the operation that emits it names the schema, and an operation that documents none never emits this field.

- `data` (TileSpecification, required): Rendering specification for a tile resource. Returned by every `/specification` endpoint and consumed once while a map is initializing: iterate `sources` and call `map.addSource()` for each, then iterate the `layers` inside each source and call `map.addLayer()` for each. The map library then fetches the `{z}/{x}/{y}` tiles automatically. A collection's specification also carries `bbox`, the extent of the itineraries its tiles draw, which is where to fit the camera once the sources are registered.

  Served to a publishable key, every `zoom_min` and `zoom_max` in it is already narrowed to the organization's zoom-bounds safety rule, so a map that follows it asks only for tiles that rule serves. A layer's range is intersected with the bounds, and a layer whose range lies wholly outside them is left out, as is a source left with no layer. A source's own range is clamped into the bounds rather than intersected, so a source whose tiles stop below the bounds still reports a range inside them, and the tiles past its own ceiling are cut from their ancestors.

  See [the TileSpecification object](https://docs.mountaya.com/en/apis/tiles/reference/itineraries.md#tile-specification-object).

**Errors** `400`, `401`, `402`, `403`, `404`, `405`, `429`, `500`, `504`. See [Errors](https://docs.mountaya.com/en/apis/conventions/errors.md).

- `400`: Bad Request
- `401`: Unauthorized
- `402`: A publishable-key request from an organization whose entitlements do not grant the capability the request needs: `tiles`, or `publishing` on a request from a page on Mountaya's own domain. Both are granted by the organization's agreement with Mountaya, so this clears when the agreement changes rather than when the request does. No tile and no specification is served for it. The capability is checked before the key's scope, so a key that lacks the scope as well is answered this rather than a `403`. It is not a permissions failure and does not clear by changing the request. A share-token request is never answered with this status: a share link is never refused for a capability.
- `403`: The credential is valid and this operation is not open to it: the key does not carry the scope the request needs (`tiles`, or `publishing` on a request from a page on Mountaya's own domain), or the request's page is not an allowed one: under a key, one outside the organization's allowed domains, and under a share token, any page not on Mountaya's own domain. A share token used outside its grant is not refused here: it is a `404`, exactly as a resource that does not exist is.
- `404`: No collection with that identifier is reachable: either none exists, or this credential does not reach it. The two answer alike, so this status cannot be used to learn which collection ids exist.
- `405`: The path takes `GET`, `HEAD`, which answers the headers a `GET` would with no body, and `OPTIONS` as a CORS preflight, and nothing else. Every route on this surface reads, so a write method is refused before the credential is even looked at, which is why this answers ahead of `401`. The `Allow` response header names the methods the path does take.
- `429`: `TooManyRequests`, given in full at the end of this page.
- `500`: Internal Server Error
- `504`: Gateway Timeout

**cURL**

```bash
# The specification is JSON in the usual envelope: register everything under
# .data.sources, then the layers inside each source.
curl -s "https://tiles.mountaya.com/v1/collections/3f1b9c42-8a6e-4d55-9f1a-2c7e5b0d4a13/specification" \
  -H "X-API-Key: pk_your_publishable_key" | jq '.data.sources[] | {id, type, tiles, zoom_min, zoom_max}'
```

**TypeScript**

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

const mountaya = new Mountaya({
  credential: { publishableKey },
});

const { data } = await mountaya.tiles.getCollectionSpecification({ collection_id: "3f1b9c42-8a6e-4d55-9f1a-2c7e5b0d4a13" });

console.log(data);
```

**Python**

```python
import requests

response = requests.get(
    "https://tiles.mountaya.com/v1/collections/3f1b9c42-8a6e-4d55-9f1a-2c7e5b0d4a13/specification",
    headers={
        "X-API-Key": "pk_your_publishable_key",
    },
    timeout=30,
)
response.raise_for_status()
print(response.json()["data"])
```

Response 200:

```json
{
  "data": {
    "sources": [
      {
        "id": "fc79978a-0e9c-4491-a5e4-b0de35a8b508",
        "type": "vector",
        "attribution": "<a href=\"https://mountaya.com/\" target=\"_blank\">&copy; Mountaya</a>",
        "tiles": [
          "https://tiles.mountaya.com/v1/zones/{z}/{x}/{y}"
        ],
        "zoom_min": 5,
        "zoom_max": 18,
        "layers": [
          {
            "id": "zones/fc79978a-0e9c-4491-a5e4-b0de35a8b508/fills",
            "key": "",
            "type": "fill",
            "source": "fc79978a-0e9c-4491-a5e4-b0de35a8b508",
            "source_layer": "fills",
            "zoom_min": 5,
            "zoom_max": 18,
            "layout": null,
            "paint": {
              "fill-color": [
                "match",
                [
                  "get",
                  "level"
                ],
                "info",
                "#1c7ed6",
                "warning",
                "#f59f00",
                "danger",
                "#f03e3e",
                "resolved",
                "#37b24d",
                "#1c7ed6"
              ],
              "fill-opacity": 0.3
            }
          }
        ]
      }
    ]
  }
}
```

## Retrieve a vector tile of a collection's itineraries and zones

### GET /v1/collections/{collection_id}/{z}/{x}/{y}

- Operation: `getCollectionTile`
- Requires: scope `tiles`
- Behavior: idempotent, safe to retry · answers within 30000 ms or times out

Returns a vector tile for a collection at the given zoom level, x, and y coordinates. The response is Mapbox Vector Tile (MVT) binary data containing the zones and itineraries tied to the collection that this credential could list: under a publishable key alone, the organization's public itineraries and zones, each as last published, so a member never published draws nothing, and the same under a key with a session token minted without `user_id`; with a session token naming a member, every member the key's organization owns, as drafts unless `surface=published` asks for the published snapshots; under a collection share token, the itineraries and zones that collection contains, each as last published. Another organization's public collection is reachable, but its tile draws nothing.

Collection tiles are returned as vector data. They must be used as a `vector` source. The tile carries exactly four source-layers: `fills` for zones, and `itinerary_lines`, `itinerary_points` and `itinerary_restrictions` for itineraries. A publishable-key request for a tile outside the organization's zoom bounds or geographic boundaries is a `400`.

`itinerary_restrictions` carries, from zoom 9, one line feature for each stretch of a segment's `road_access_info` that restricts who may pass: the segment's line cut between the stretch's two indexes, never across two of its lines. A feature carries `segment_id`, `itinerary_id` and `kind`, the most severe of the stretch's restrictions: `forbidden` for `no`, `private` for `private`, `permit` for `permit`, `service` for `service`, `local-access` for `destination`, `customers` and `delivery`, and `restricted` for `restricted`, `unknown` and any value this list does not name. A stretch whose restrictions are only `permissive`, `agricultural` or `forestry` has no kind and is not drawn. The specification declares no layer for it: a map that draws restricted stretches adds layers of its own over it, as `@mountaya/elements` does.

In `fills`, a zone is one feature for each of its polygons. A feature's geometry is that polygon clipped exactly to a window around the tile, however intricate it is, from two tiles' width before its square to one tile's width past it, -8192 to 8191 in the tile's 4,096-unit coordinates, so it may extend past the tile's square and is not the zone's whole outline. Draw it clipped to the tile, as a map library does, and take a zone's outline from the zone itself, never from a tile. A zone stored before outlines were checked on write is checked by Mountaya shortly after the release; until it has been, and for good when its outline breaks a rule a write now holds it to (a valid polygon, at most 10,000 positions, no meridian or parallel crossing it more than 512 times, which a zone computed from a source was not held to), it is carried as it is stored and approximated where it passes through that window many times. The work of one tile is bounded: a tile whose zones take longer than that to draw is the `504` of a spent budget.

A zone drawn from its draft carries its `id`, `name`, `level`, `mode`, `is_private`, `revision` and `created_by` as properties, and its `organization_id`, `description`, `start_at` and `end_at` when it has them: a personal zone, owned by no organization, carries no `organization_id`. A zone drawn from its publication carries what a published itinerary does: its `id`, `name`, `level` and `mode`, and its `description`, `start_at` and `end_at` when the publication has them, never who made it, which organization holds it, its privacy or its revision. The two bounds are Unix seconds, so a style can filter on a zone's validity window.

Details for consuming a collection can be found in [the specification endpoint](https://docs.mountaya.com/en/apis/tiles/reference/collections.md#getCollectionSpecification).

This route is consumed as a URL template rather than called directly. The matching specification endpoint returns it under `sources[].tiles` with the `{z}`, `{x}` and `{y}` placeholders intact, and a map library (MapLibre GL JS, Mapbox GL JS, or `@mountaya/elements`) expands and fetches them on its own schedule. The generated SDKs bind no method for it.

A publishable key needs the `tiles` scope, or `publishing` on a request from a page on Mountaya's own domain. A share token carries its own authority and needs none.

**Path parameters**

- `collection_id` (string (uuid), in path, required): Identifier of the collection the operation acts on. A collection this credential does not reach is a 404 rather than a 403, and so is one that does not exist, so the parameter cannot be used to learn which collection ids exist.

- `z` (integer (int32), in path, required): Zoom level. Higher values show more detail over a smaller area. On a publishable-key request for anything but the base map (a terrain's tiles, the tiles of the sources its style draws and the elevation raster's), the organization's zoom-bounds safety rule narrows the accepted range, and a `z` outside it is a 400 naming `z`, so a structurally valid value can still be refused. Each layer's `zoom_min` and `zoom_max` in the specification say where a map should ask for tiles; they are not a refusal. A specification served to a publishable key reports them already narrowed to that rule, so a map that follows it asks only for a `z` the rule accepts.

- `x` (integer (int32), in path, required): Tile column index at the given zoom level, from 0 to 2^z - 1 inclusive. An index at or past 2^z addresses no tile and is a `400` naming `x`, as a negative or non-integer one is, so an index computed wrongly is refused before anything is drawn or fetched for it.

- `y` (integer (int32), in path, required): Tile row index at the given zoom level, from 0 to 2^z - 1 inclusive. An index at or past 2^z addresses no tile and is a `400` naming `y`, as a negative or non-integer one is, so an index computed wrongly is refused before anything is drawn or fetched for it.

**Query parameters**

- `timestamp` (string (date-time), in query, optional): Selects the instant the tile is drawn for. When absent it defaults to the current date-time, so a tile asked for with no timestamp carries the zones active now. When present, only zones active at that instant are returned. Either way the instant is rounded down to the hour, in UTC, first.

  The window it accepts is 3 days into the past and 6 days into the future, measured from the moment the request arrives. It is relative rather than fixed, which is why it is stated here and not as a `minimum` and `maximum`: a value outside it is a 400 naming `timestamp`.

  It only affects time-bound zones. Permanent zones are returned either way.

  Absence means something different here from what it means on `getZonesTile`, where it disables the filter and returns every zone whatever its validity window. A collection is a trip with dates on it, so what it looks like changes continuously and the useful default is the instant the request is made. The organization-wide zone tile is a reference layer a client styles for itself, and it has no instant of its own, so the useful default there is no filter at all.

- `surface` (string, in query, optional, one of: `published`): Reads the published snapshot rather than the draft. `published` is the only accepted value: there is deliberately no `draft` spelling, because the param only ever narrows what the caller is served. An unrecognized value is rejected with a validation error rather than silently ignored. A read of one itinerary, or of one zone, refuses it with `403` when it is personal, owned by no organization, to the person whose it is: the published surface is what a video and an embed are made of, and a personal itinerary or zone makes neither. Every other caller reads a personal itinerary or zone as published, and since one is never published it is answered as one that does not exist.

- `itinerary_id` (string (uuid), in query, optional): Identifier of one itinerary inside this collection, to draw it alone. It only filters, and marks nothing as selected: with `with_itineraries` set to `false`, the tile carries that one itinerary and no other, and with `with_itineraries` set to `true` every itinerary of the collection is drawn and this parameter changes nothing. The layers that paint it are the itinerary layers of a specification read with `with_itineraries` on, so read it that way: one read with it `false` declares none. An identifier that names no itinerary of the collection is not an error; it matches nothing, so the tile carries no itinerary. The nil UUID, like any spelling but the canonical one, is a `400` naming this parameter. It draws nothing the organization's safety rule withholds: on a publishable-key request whose organization keeps collection itineraries off, the tile carries no itinerary whatever this names.

- `with_zones` (boolean, in query, optional): Whether the collection's zones are part of the answer. On this route that is the zone features the tile carries.

  It declares no `default`, and that is deliberate rather than an omission: the value when the parameter is absent is the organization's own default for this layer, clamped to its safety rules for a publishable-key caller, so there is no one figure this document could publish. For a request from Mountaya's web application, which names no organization of its own, that organization is Mountaya's own, and its default is not clamped. Sending it explicitly is the way to decide it per request, within the rule: on a publishable-key request an explicit `true` is still capped by the organization's safety rule.

- `with_itineraries` (boolean, in query, optional): Whether the collection's itineraries are part of the answer. On this route that is the itinerary features the tile carries, split across three source layers: `itinerary_lines` for line geometries, `itinerary_points` for point geometries and `itinerary_restrictions` for the restricted stretches. Setting it to `false` still leaves in the one itinerary `itinerary_id` names, unless it is the organization's safety rule that keeps the itineraries off.

  It declares no `default`, and that is deliberate rather than an omission: the value when the parameter is absent is the organization's own default for this layer, clamped to its safety rules for a publishable-key caller, so there is no one figure this document could publish. For a request from Mountaya's web application, which names no organization of its own, that organization is Mountaya's own, and its default is not clamped. Sending it explicitly is the way to decide it per request, within the rule: on a publishable-key request an explicit `true` is still capped by the organization's safety rule.

Also takes `Accept-Language`, as every operation of this API does: the [overview](https://docs.mountaya.com/en/apis/tiles/reference.md) describes it.

**Response** `200` `application/x-protobuf`

Mapbox Vector Tile (MVT) binary for the requested `{z}/{x}/{y}` tile. Empty (zero-length) when no features fall inside the tile.

**Errors** `400`, `401`, `402`, `403`, `404`, `405`, `429`, `500`, `504`. See [Errors](https://docs.mountaya.com/en/apis/conventions/errors.md).

- `400`: Bad Request
- `401`: Unauthorized
- `402`: A publishable-key request from an organization whose entitlements do not grant the capability the request needs: `tiles`, or `publishing` on a request from a page on Mountaya's own domain. Both are granted by the organization's agreement with Mountaya, so this clears when the agreement changes rather than when the request does. No tile and no specification is served for it. The capability is checked before the key's scope, so a key that lacks the scope as well is answered this rather than a `403`. It is not a permissions failure and does not clear by changing the request. A share-token request is never answered with this status: a share link is never refused for a capability.
- `403`: The credential is valid and this operation is not open to it: the key does not carry the scope the request needs (`tiles`, or `publishing` on a request from a page on Mountaya's own domain), or the request's page is not an allowed one: under a key, one outside the organization's allowed domains, and under a share token, any page not on Mountaya's own domain. A share token used outside its grant is not refused here: it is a `404`, exactly as a resource that does not exist is.
- `404`: No collection with that identifier is reachable: either none exists, or this credential cannot view it, a share token used outside its grant included. The two answer alike, so this status cannot be used to learn which collection ids exist.
- `405`: The path takes `GET`, `HEAD`, which answers the headers a `GET` would with no body, and `OPTIONS` as a CORS preflight, and nothing else. Every route on this surface reads, so a write method is refused before the credential is even looked at, which is why this answers ahead of `401`. The `Allow` response header names the methods the path does take.
- `429`: `TooManyRequests`, given in full at the end of this page.
- `500`: Internal Server Error
- `504`: Gateway Timeout

**cURL**

```bash
# The body is the tile's bytes, not JSON. A map library fetches these URLs
# itself and cannot set a header, so a browser sends ?publishable_key= instead.
curl -s "https://tiles.mountaya.com/v1/collections/3f1b9c42-8a6e-4d55-9f1a-2c7e5b0d4a13/12/2126/1458" \
  -H "X-API-Key: pk_your_publishable_key" -o tile.mvt
```

**TypeScript**

```typescript
// A map library requests each tile itself and cannot set a header, so the credential rides the query.
const tiles = `https://tiles.mountaya.com/v1/collections/3f1b9c42-8a6e-4d55-9f1a-2c7e5b0d4a13/{z}/{x}/{y}?publishable_key=${publishableKey}`;
```

**Python**

```python
import requests

response = requests.get(
    "https://tiles.mountaya.com/v1/collections/3f1b9c42-8a6e-4d55-9f1a-2c7e5b0d4a13/12/2126/1458",
    headers={
        "X-API-Key": "pk_your_publishable_key",
    },
    timeout=30,
)
response.raise_for_status()
with open("tile.mvt", "wb") as file:
    file.write(response.content)
```

**Error answers the operations of this page share**

- `TooManyRequests` (`429`): A bound the request's surface is held to is spent: for the organization's own clients and its hosted embed, the organization's per-minute limit or its monthly allowance, or, under a key sent without a session token or with one minted without `user_id`, the bound on the client's IP address, an IPv6 address counted by its `/64` prefix; for an Embedded Studio, the bound of the member its session names, or of its client IP address for a session minted without `user_id`, or its organization's; for a share link, the bound on the client's IP address or the bound of the organization that owns the link; for Mountaya's web application, the 6,000 a minute of the person signed in to it, which carries no rate-limit fields. Or the client's IP address has had 60 unknown share tokens refused within the minute, or 60 unknown publishable keys, a key refused again within seconds counted once, and the token or the key it sends was not resolved moments earlier. Every one carries `Retry-After`: for a per-minute bound, the seconds left in the minute; for a spent monthly allowance, the whole seconds until the organization's next billing period begins, until which every request of the organization's own clients and of its hosted embed, specifications included, is refused; for a share token or a publishable key refused because its address had 60 unknown ones refused, the seconds left in that minute. A share token or a publishable key resolved moments earlier is never refused that last way. `RateLimit-Policy` and `RateLimit` say which bound was spent, except on the refusal of an unknown share token or of an unknown publishable key, which no bound of the organization's counts: that answer carries no `RateLimit-Policy` or `RateLimit` field.
