# Collections and share links

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

Group itineraries and zones into a collection, then share it, or one itinerary, with a link that opens a read-only map.

A collection groups itineraries and zones, like a folder. A share link opens one collection, or one itinerary, to whoever holds the link, as a read-only map in Mountaya. Share links need Map Publishing in your agreement.

## 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"]
```

The examples file `$ITINERARY_ID`, a published itinerary of yours.

### No published itinerary yet? Create one

**cURL**

```bash
ACTIVITY_ID=$(curl -s https://api.mountaya.com/v1/activities \
  -H "X-API-Key: $MOUNTAYA_PUBLISHABLE_KEY" \
  | jq -r '.data[].children[] | select(.slug == "hiking-and-trail") | .id')

ITINERARY_ID=$(curl -s -X POST https://api.mountaya.com/v1/itineraries \
  -H "X-API-Key: $MOUNTAYA_PUBLISHABLE_KEY" \
  -H "X-Session-Token: $MOUNTAYA_MEMBER_TOKEN" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d "{\"name\": \"Chamonix to Argentière\", \"activity_id\": \"$ACTIVITY_ID\", \"is_private\": false}" \
  | jq -r .data.id)

curl -s -o /dev/null -X POST https://api.mountaya.com/v1/itineraries/$ITINERARY_ID/segments \
  -H "X-API-Key: $MOUNTAYA_PUBLISHABLE_KEY" \
  -H "X-Session-Token: $MOUNTAYA_MEMBER_TOKEN" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"name": "Chamonix to Argentière", "mode": "directions", "geojson": {"type": "MultiPoint", "coordinates": [[6.8712, 45.9231], [6.9271, 45.9822]]}}'

curl -s -o /dev/null -X POST https://api.mountaya.com/v1/itineraries/$ITINERARY_ID/publication \
  -H "X-API-Key: $MOUNTAYA_PUBLISHABLE_KEY" \
  -H "X-Session-Token: $MOUNTAYA_MEMBER_TOKEN" \
  -H "Idempotency-Key: $(uuidgen)"
```

**TypeScript**

```typescript
const { data: categories } = await mountaya.studio.activities.getActivities();
const hiking = categories
  .flatMap((category) => category.children)
  .find((activity) => activity.slug === "hiking-and-trail");

const { data: created } = await mountaya.studio.itineraries.postItinerary({
  body: { name: "Chamonix to Argentière", activity_id: hiking?.id ?? "", is_private: false },
});
const itineraryId = created.id;

await mountaya.studio.itineraries.postItinerarySegment({
  itinerary_id: itineraryId,
  body: {
    name: "Chamonix to Argentière",
    mode: "directions",
    geojson: {
      type: "MultiPoint",
      coordinates: [
        [6.8712, 45.9231],
        [6.9271, 45.9822],
      ],
    },
  },
});
await mountaya.studio.itineraries.postItineraryPublication({ itinerary_id: itineraryId });
```

**Python**

```python
categories = requests.get(
    "https://api.mountaya.com/v1/activities",
    headers={"X-API-Key": os.environ["MOUNTAYA_PUBLISHABLE_KEY"]},
    timeout=30,
).json()["data"]
activity_id = next(
    activity["id"]
    for category in categories
    for activity in category["children"]
    if activity["slug"] == "hiking-and-trail"
)

itinerary_id = requests.post(
    "https://api.mountaya.com/v1/itineraries",
    headers={
        "X-API-Key": os.environ["MOUNTAYA_PUBLISHABLE_KEY"],
        "X-Session-Token": session["token"],
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={"name": "Chamonix to Argentière", "activity_id": activity_id, "is_private": False},
    timeout=30,
).json()["data"]["id"]

requests.post(
    f"https://api.mountaya.com/v1/itineraries/{itinerary_id}/segments",
    headers={
        "X-API-Key": os.environ["MOUNTAYA_PUBLISHABLE_KEY"],
        "X-Session-Token": session["token"],
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={
        "name": "Chamonix to Argentière",
        "mode": "directions",
        "geojson": {"type": "MultiPoint", "coordinates": [[6.8712, 45.9231], [6.9271, 45.9822]]},
    },
    timeout=30,
).raise_for_status()

requests.post(
    f"https://api.mountaya.com/v1/itineraries/{itinerary_id}/publication",
    headers={
        "X-API-Key": os.environ["MOUNTAYA_PUBLISHABLE_KEY"],
        "X-Session-Token": session["token"],
        "Idempotency-Key": str(uuid.uuid4()),
    },
    timeout=30,
).raise_for_status()
```

## Create a collection

A collection takes a name and whether it is private.

**cURL**

```bash
COLLECTION_ID=$(curl -s -X POST https://api.mountaya.com/v1/collections \
  -H "X-API-Key: $MOUNTAYA_PUBLISHABLE_KEY" \
  -H "X-Session-Token: $MOUNTAYA_MEMBER_TOKEN" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"name": "Chamonix day hikes", "description": "Day hikes around Chamonix.", "is_private": false}' \
  | jq -r .data.id)
```

**TypeScript**

```typescript
// The new collection's id, which the calls below address.
const {
  data: { id },
} = await mountaya.studio.collections.postCollection({
  body: { name: "Chamonix day hikes", description: "Day hikes around Chamonix.", is_private: false },
});
```

**Python**

```python
collection = requests.post(
    "https://api.mountaya.com/v1/collections",
    headers={
        "X-API-Key": os.environ["MOUNTAYA_PUBLISHABLE_KEY"],
        "X-Session-Token": session["token"],
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={"name": "Chamonix day hikes", "description": "Day hikes around Chamonix.", "is_private": False},
    timeout=30,
).json()["data"]
```

**Response (abridged)**

```json
{
  "data": {
    "id": "59cfff6f-29bb-49e9-9090-91e211151802",
    "name": "Chamonix day hikes",
    "description": "Day hikes around Chamonix.",
    "is_private": false,
    "count": { "itineraries": 0, "zones": 0 },
    "etag": "\"d1\"",
    "role": "owner"
  }
}
```

- `POST /v1/collections` answers `201 Created` with the `Collection` and its address in `Location`. `name` is 2 to 30 characters after trimming, on a single line (a tab or a line break inside it is a `400`), and unique in the organization (`409` otherwise); `description` at most 100.
- A collection also carries `sources`: the vector tile source and layers that draw its content on a map, served by the Tile API.
- A private collection is reached only with your organization's key and a member's session token. A share link opens a collection whatever its privacy.
- `GET /v1/collections` lists them, filtered by `itinerary_id` or `zone_id` (where one item is filed), `is_private`, `updated_since` and `q`.

## File itineraries and zones

Add itineraries by id. Zones are filed the same way, at `/zones` with `zone_ids`.

**cURL**

```bash
curl -s -X POST https://api.mountaya.com/v1/collections/$COLLECTION_ID/itineraries \
  -H "X-API-Key: $MOUNTAYA_PUBLISHABLE_KEY" \
  -H "X-Session-Token: $MOUNTAYA_MEMBER_TOKEN" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d "{\"itinerary_ids\": [\"$ITINERARY_ID\"]}" \
  | jq '.data.count'
```

**TypeScript**

```typescript
const { data: filed } = await mountaya.studio.collections.postCollectionItineraries({
  collection_id: id,
  body: { itinerary_ids: [itineraryId] },
});

console.log(filed.count);
```

**Python**

```python
filed = requests.post(
    f"https://api.mountaya.com/v1/collections/{collection['id']}/itineraries",
    headers={
        "X-API-Key": os.environ["MOUNTAYA_PUBLISHABLE_KEY"],
        "X-Session-Token": session["token"],
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={"itinerary_ids": [itinerary_id]},
    timeout=30,
).json()["data"]

print(filed["count"])
```

**Response (abridged)**

```json
{
  "itineraries": 1,
  "zones": 0
}
```

- `POST /v1/collections/{collection_id}/itineraries` takes `itinerary_ids`; `POST /v1/collections/{collection_id}/zones` takes `zone_ids`. Every id is resolved and authorized before anything is written, so the call succeeds or fails as a whole; a repeated id is collapsed. Both answer the whole `Collection`.
- `PATCH /v1/collections/{collection_id}/itineraries/{itinerary_id}` moves an itinerary within the collection's order; `DELETE` on it, or on `/zones/{zone_id}`, removes the item from the collection without deleting it.
- `GET /v1/collections/{collection_id}/itineraries` and `.../zones` list what the collection holds, itineraries in the collection's own order unless you `sort` otherwise.
- Filing changes neither `updated_at` of the collection nor the item's publication.

## Mint a share link

`POST` on the collection's share link mints one, or returns the one it already has.

**cURL**

```bash
SHARE_TOKEN=$(curl -s -X POST https://api.mountaya.com/v1/collections/$COLLECTION_ID/share-link \
  -H "X-API-Key: $MOUNTAYA_PUBLISHABLE_KEY" \
  -H "X-Session-Token: $MOUNTAYA_MEMBER_TOKEN" \
  -H "Idempotency-Key: $(uuidgen)" \
  | jq -r .data.share_token)

echo "https://app.mountaya.com/studio/share?collection_id=$COLLECTION_ID&share_token=$SHARE_TOKEN"
```

**TypeScript**

```typescript
const { data: link } = await mountaya.studio.collections.postCollectionShareLink({
  collection_id: id,
});

const url = new URL("https://app.mountaya.com/studio/share");
url.searchParams.set("collection_id", id);
url.searchParams.set("share_token", link.share_token);
console.log(url.toString());
```

**Python**

```python
link = requests.post(
    f"https://api.mountaya.com/v1/collections/{collection['id']}/share-link",
    headers={
        "X-API-Key": os.environ["MOUNTAYA_PUBLISHABLE_KEY"],
        "X-Session-Token": session["token"],
        "Idempotency-Key": str(uuid.uuid4()),
    },
    timeout=30,
).json()["data"]

print(
    "https://app.mountaya.com/studio/share"
    f"?collection_id={collection['id']}&share_token={link['share_token']}"
)
```

**Response**

```json
{
  "data": {
    "created_at": "2026-11-09T11:04:27.449694Z",
    "share_token": "share_your_share_token"
  }
}
```

The link opens a read-only map of the collection's published itineraries, and of its published public zones. Anyone who holds it can open it, with no account.

- The share view is `https://app.mountaya.com/studio/share?collection_id={collection_id}&share_token={share_token}`, or `?itinerary_id={itinerary_id}&share_token=…` for an itinerary's link. A URL naming both ids is refused as an invalid link. `buildShareSrc` in `@mountaya/studio` builds it.
- The mint answers `201 Created` with `Location` the first time, and `200 OK` with the same token after: it never mints a second link or changes the token.
- A share token is `share_` followed by 32 lowercase hex characters. It grants read-only access (`GET`, `HEAD`, `OPTIONS`) to one resource, sent as `X-Share-Token` or `?share_token=`, in place of a publishable key. A collection's token reaches the collection and the itineraries and zones filed in it, each as last published, whatever their privacy, including what is filed later. An itinerary's token reaches that itinerary alone, as last published.
- Malformed, unknown, removed and rotated tokens all answer `401`. A share token resolves only while your organization holds Map Publishing.
- Tiles a share link draws are recorded as your organization's `share` usage and never counted toward its limits or allowances. A share token is held to 600 requests a minute per client IP address, then to 60,000 a minute across every link of the organization.
- Minting, reading, rotating and removing a link take a member with a write role in the organization that owns the resource, under `studio-embedded`. A member who only views cannot read the link. A share link does not change the resource's `etag` and takes no `If-Match`.

## Read through the link

Your own code reads the shared content with the token in `X-Share-Token`, and no key.

**cURL**

```bash
curl -s https://api.mountaya.com/v1/collections/$COLLECTION_ID/itineraries \
  -H "X-Share-Token: $SHARE_TOKEN" \
  | jq '[.data[] | {name, status}]'
```

**TypeScript**

```typescript
// Your backend reads the collection's link, then reads through it as a visitor would.
const { data: current } = await mountaya.studio.collections.getCollectionShareLink({
  collection_id: id,
});
if (current === null) {
  throw new Error("The collection has no share link.");
}

const visitor = new Mountaya({ credential: { shareToken: current.share_token } });
const { data: shared } = await visitor.studio.collections.getCollectionItineraries({
  collection_id: id,
});

console.log(shared.map((itinerary) => itinerary.name));
```

**Python**

```python
shared = requests.get(
    f"https://api.mountaya.com/v1/collections/{collection['id']}/itineraries",
    headers={"X-Share-Token": link["share_token"]},
    timeout=30,
).json()["data"]

print([itinerary["name"] for itinerary in shared])
```

**Response (abridged)**

```json
[
  {
    "name": "Chamonix to Argentière",
    "status": "published"
  }
]
```

## Rotate or remove a link

- `POST /v1/collections/{collection_id}/share-link/rotate` replaces the token. The old URL stops working.
- `DELETE /v1/collections/{collection_id}/share-link` removes the link.

An itinerary has its own link at `/v1/itineraries/{itinerary_id}/share-link`, with the same calls. A zone has none: share it through a collection.

- Rotating mints a new token every time: send an `Idempotency-Key` and repeat it on a retry, or read the link back with `GET …/share-link` before rotating again. Rotating a link that does not exist is `409`.
- Removing acts on a state: a link that is not there answers `200`. There is no undo; minting again produces a new token.
- Mountaya refuses an old token from the next request on. A shared cache may keep serving an answer it holds until its lifetime ends: at most 5 minutes for a public tile and 25 hours for the layer catalog.
- `GET …/share-link` reads the link, or `data: null` when there is none.

## Next steps

- [Embed a collection](https://docs.mountaya.com/en/map-publishing/parameters.md#content-selection): Show a collection on your own site with `collection_id`.
- [Import and export](https://docs.mountaya.com/en/apis/map-studio/import-export.md): Bring GPX files in, and route files out.
