# Quickstart

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

Mint a member's session token, then create an itinerary, route a segment on it, and publish it.

Create and publish an itinerary in five calls.

**Comes with an agreement:** its itineraries, zones and collections need one, so [talk to us](https://mountaya.com/en/contact/).

You need two keys from **Organization → API keys** in the [Mountaya app](https://app.mountaya.com/api-keys), and the member the writes act as:

- a **publishable key** with the `studio-embedded` scope,
- a **secret key**, which stays on your server,
- the member's `user_id` ([find it](https://docs.mountaya.com/en/apis/map-studio/quickstart.md#find-a-members-user-id)).

```bash
export MOUNTAYA_PUBLISHABLE_KEY="pk_your_publishable_key"
export MOUNTAYA_SECRET_KEY="sk_your_secret_key"
export MOUNTAYA_USER_ID="7a4e1c98-3b52-4f60-9d81-c05e2f7a83b1"
```

**1. Mint a session token for the member**

Every write acts as a member. Your server mints a token that names them, for `studio-embedded`. The cURL samples need [jq](https://jqlang.org/).

**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\": \"$MOUNTAYA_USER_ID\", \"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 secretKey = process.env.MOUNTAYA_SECRET_KEY ?? "";
const userId = "7a4e1c98-3b52-4f60-9d81-c05e2f7a83b1";

const server = new Mountaya({ credential: { secretKey } });
const { data: session } = await new MountayaAdmin(server).sessions.postSession({
  body: { publishable_key: publishableKey, user_id: userId, surface: "studio-embedded" },
});
const sessionToken = session.token;
```

**Python**

```python
import os
import uuid

import requests

USER_ID = "7a4e1c98-3b52-4f60-9d81-c05e2f7a83b1"

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": USER_ID,
        "surface": "studio-embedded",
    },
    timeout=10,
).json()["data"]
```

**Response**

```json
{
  "data": {
    "expires_at": "2026-11-09T11:12:34.799589Z",
    "token": "sess_your_session_token",
    "user_id": "7a4e1c98-3b52-4f60-9d81-c05e2f7a83b1"
  }
}
```

The token lasts five minutes. Check that `user_id` names your member.

- Mint on your server only, for the person signed in to your own product. The secret key never reaches a browser.
- `surface` must be `studio-embedded`: every `studio-embedded` operation, each itinerary, segment, collection and zone write among them, answers any other token `401`. A token minted without `user_id` also answers `401` there.
- The member must belong to the key's organization in a role that writes (`owner`, `admin`, `contributor`); a `viewer` is refused a write with `403`. A `user_id` that is neither a member nor invited is a `403`, the same whether or not the user exists.
- The token expires at `data.expires_at`, at most five minutes after minting; a token minted moments earlier for the same key, surface and user is answered again while it has more than two minutes left. Re-mint before expiry.
- The key needs `studio-embedded`, which needs an agreement including Embedded Studio, Map Studio, the Tile API and the Data API. A key that does not reach `studio-embedded` is refused the mint with `403`; an organization without Embedded Studio, `402`.

**2. Find the activity**

An itinerary takes an activity at creation. The catalog nests activities under categories: pick `hiking-and-trail`.

**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')
```

**TypeScript**

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

const { data: categories } = await mountaya.studio.activities.getActivities();
const hiking = categories
  .flatMap((category) => category.children)
  .find((activity) => activity.slug === "hiking-and-trail");
if (hiking === undefined) {
  throw new Error("The catalog has no hiking-and-trail activity.");
}

// The itinerary you create next.
const body = {
  name: "Tour du Mont-Blanc",
  description: "Ten stages from Les Houches, anticlockwise.",
  activity_id: hiking.id,
  is_private: true,
};
```

**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"
)
```

**Response (abridged)**

```json
{
  "data": [
    {
      "id": "2af4e4fc-53d3-40bb-8505-e7b48437e491",
      "slug": "byfoot",
      "locales": { "en": { "name": "By foot" }, "fr": { "name": "À pied" } },
      "children": [
        {
          "id": "a1c4e7b2-3d59-4f08-8b6a-2e5c9d0f7134",
          "slug": "hiking-and-trail",
          "locales": { "en": { "name": "Hiking and trail" }, "fr": { "name": "Randonnée et trail" } },
          "capabilities": {
            "analysis": true,
            "default_speed": 4.5,
            "directions": true,
            "linestring": false
          }
        }
      ]
    }
  ]
}
```

- `GET /v1/activities` takes the publishable key alone (`publishing` or `studio-embedded`). It is a catalog, the same for every caller and not paged: every category comes back at once.
- Shape: `data[]` is a category (`id`, `slug`, `locales`, `children`); `data[].children[]` is an activity (`id`, `slug`, `locales`, `capabilities`). `capabilities.directions` says whether a `directions` segment can route it, `capabilities.linestring` whether a `linestring` segment can draw it, and `capabilities.default_speed` is its speed in km/h.
- An itinerary keeps its activity for life, and every segment inherits it. Cache the catalog; match on `slug`, never on a name or a position.

**3. Create the itinerary**

`POST /v1/itineraries` takes a name, the activity, and whether the itinerary is private.

**cURL**

```bash
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\": \"Tour du Mont-Blanc\", \"description\": \"Ten stages from Les Houches, anticlockwise.\", \"activity_id\": \"$ACTIVITY_ID\", \"is_private\": true}" \
  | jq -r .data.id)
```

**TypeScript**

```typescript
const { data: itinerary } = await mountaya.studio.itineraries.postItinerary({ body });
const itineraryId = itinerary.id;
```

**Python**

```python
itinerary = 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": "Tour du Mont-Blanc",
        "description": "Ten stages from Les Houches, anticlockwise.",
        "activity_id": activity_id,
        "is_private": True,
    },
    timeout=30,
).json()["data"]
itinerary_id = itinerary["id"]
```

**Response**

```json
{
  "data": {
    "activity_id": "a1c4e7b2-3d59-4f08-8b6a-2e5c9d0f7134",
    "ascent": null,
    "count": { "groups": 0, "segments": 0, "waypoints": 0 },
    "created_at": "2026-11-09T11:07:56.330432Z",
    "created_by": { "id": "7a4e1c98-3b52-4f60-9d81-c05e2f7a83b1" },
    "description": "Ten stages from Les Houches, anticlockwise.",
    "distance": null,
    "etag": "\"d1\"",
    "groups": [],
    "has_unpublished_changes": false,
    "id": "0b6d1a4e-6d3f-4f7a-9c2e-1f0a5b8c3d21",
    "is_private": true,
    "is_verified": false,
    "name": "Tour du Mont-Blanc",
    "organization_id": "a5eec5f3-3463-4b20-9469-de3eeb870a7a",
    "published_at": null,
    "revision": 1,
    "segments": [],
    "status": "draft",
    "updated_at": "2026-11-09T11:07:56.330432Z",
    "waypoints": []
  }
}
```

It answers `201 Created`. The `Idempotency-Key` makes a retry safe: the same key is answered the first `201`.

- Answer: `201 Created`, the itinerary's full draft, with empty `segments`, `waypoints` and `groups`, and its address in `Location`. `description`, `distance` and `ascent` are `null` until set or computed.
- `name` is 2 to 30 characters after trimming, on a single line: a tab or a line break inside it is a `400`. A name already taken inside the organization answers `409 Conflict` naming the holder at `extensions.metadata.itinerary.id`; sent again with the same `Idempotency-Key`, the call answers the first `201` rather than meeting its own name.
- Send a fresh `Idempotency-Key` per write and repeat it unchanged on a retry. See [idempotency](https://docs.mountaya.com/en/apis/conventions/idempotency.md). The TypeScript client draws one per call.
- The organization must hold Map Studio, or the create is `402`.

**4. Route a segment**

A `directions` segment takes a GeoJSON `MultiPoint` of 2 to 45 waypoints, as `[longitude, latitude]`. The router draws the trail between them.

**cURL**

```bash
curl -s -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": "Les Houches to Argentière",
    "mode": "directions",
    "geojson": {
      "type": "MultiPoint",
      "coordinates": [[6.7991, 45.8915], [6.8712, 45.9231], [6.9271, 45.9822]]
    }
  }' | jq '.data | {distance, ascent, segments: [.segments[] | {id, name, distance, duration}]}'
```

**TypeScript**

```typescript
const { data: routed } = await mountaya.studio.itineraries.postItinerarySegment({
  itinerary_id: itineraryId,
  body: {
    name: "Les Houches to Argentière",
    mode: "directions",
    geojson: {
      type: "MultiPoint",
      coordinates: [
        [6.7991, 45.8915],
        [6.8712, 45.9231],
        [6.9271, 45.9822],
      ],
    },
  },
});

console.log(routed.distance, routed.ascent);
```

**Python**

```python
routed = 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": "Les Houches to Argentière",
        "mode": "directions",
        "geojson": {
            "type": "MultiPoint",
            "coordinates": [[6.7991, 45.8915], [6.8712, 45.9231], [6.9271, 45.9822]],
        },
    },
    timeout=30,
).json()["data"]

print(routed["distance"], routed["ascent"])
```

**Response (abridged)**

```json
{
  "distance": 16733.59,
  "ascent": 397,
  "segments": [
    {
      "id": "8fa7a85f-0e2b-41dc-a24a-172c2787db4a",
      "name": "Les Houches to Argentière",
      "distance": 16733.59,
      "duration": 17201.36
    }
  ]
}
```

The answer is the whole itinerary, with its totals recomputed. Distances are in meters, durations in seconds.

- Answer: `201 Created` with the whole `ItineraryWithDetails` (route, totals, profile); the new segment's id is at `extensions.metadata.created.id`.
- `directions` takes a `MultiPoint` of 2 to 45 waypoints whose straight line is at most 100 km; the route is computed on the trail network for the itinerary's activity. `linestring` takes a `LineString` the router leaves alone. Sending a `LineString` in `directions` mode is a `400`.
- Distance, duration, ascent, descent, surface and way type are computed from the routed line. They are not fields a body takes; sending one is a `400`.
- `speed` (km/h, 0.01 to 999.99) overrides the activity's default speed for this segment's duration.
- `before_segment_id` inserts the segment before another instead of appending it.

**5. Publish it**

Edits change a draft. Publishing freezes the draft into what embeds and share links show.

**cURL**

```bash
curl -s -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)" \
  | jq '.data | {status, published_at, has_unpublished_changes}'
```

**TypeScript**

```typescript
const { data: published } = await mountaya.studio.itineraries.postItineraryPublication({
  itinerary_id: itineraryId,
});

console.log(published.status, published.published_at);
```

**Python**

```python
published = 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,
).json()["data"]

print(published["status"], published["published_at"])
```

**Response (abridged)**

```json
{
  "status": "published",
  "published_at": "2026-11-09T11:07:56.536793Z",
  "has_unpublished_changes": false
}
```

Your itinerary now shows in [embeds and share links](https://docs.mountaya.com/en/map-publishing.md). [Publishing](https://docs.mountaya.com/en/apis/map-studio/publishing.md) covers edits after a publish.

- Publishing needs Map Publishing beside Map Studio; without it the call is `402`. It takes no body, is safe to repeat, and answers `200 OK` with the itinerary, `status`, `published_at` and `has_unpublished_changes` updated.
- An itinerary with no segments is `409`. One a collaborator holds a lock in is `409` naming the holder at `extensions.metadata.holder.id`. A first publish past the agreement's `published-itineraries` limit is `429` coded `LIMIT_REACHED`, with no `Retry-After`. See [publishing](https://docs.mountaya.com/en/apis/map-studio/publishing.md).
- `DELETE` on the same path takes the itinerary down.

## Find a member's user ID

List your members with a key that carries the `management` scope. Create one under **Organization → API keys**: it carries no other scope, so it stays on your server.

```bash
export MOUNTAYA_MANAGEMENT_KEY="pk_your_publishable_key"
```

**cURL**

```bash
ORGANIZATION_ID=$(curl -s -X POST https://api.mountaya.com/v1/organizations/lookup \
  -H "Content-Type: application/json" \
  -d "{\"publishable_key\": \"$MOUNTAYA_PUBLISHABLE_KEY\"}" | jq -r .data.id)

export MOUNTAYA_ADMIN_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_MANAGEMENT_KEY\"}" | jq -r .data.token)

curl -s "https://api.mountaya.com/v1/organizations/$ORGANIZATION_ID/members" \
  -H "X-API-Key: $MOUNTAYA_MANAGEMENT_KEY" \
  -H "X-Session-Token: $MOUNTAYA_ADMIN_TOKEN" \
  | jq '[.data[] | {email, user_id, role}]'
```

**TypeScript**

```typescript
const managementKey = process.env.MOUNTAYA_MANAGEMENT_KEY ?? "";
const backend = new Mountaya({
  credential: { secretKey: process.env.MOUNTAYA_SECRET_KEY ?? "" },
});

const { data: organization } = await backend.studio.organizations.postOrganizationLookup({
  body: { publishable_key: process.env.MOUNTAYA_PUBLISHABLE_KEY ?? "" },
});
const { data: adminSession } = await new MountayaAdmin(backend).sessions.postSession({
  body: { publishable_key: managementKey },
});

const management = new Mountaya({
  credential: { publishableKey: managementKey, sessionToken: adminSession.token },
});
const { data: members } = await new MountayaAdmin(management).members.getOrganizationMembers({
  organization_id: organization.id,
});

console.log(members.map((member) => [member.email, member.user_id]));
```

**Python**

```python
organization = requests.post(
    "https://api.mountaya.com/v1/organizations/lookup",
    json={"publishable_key": os.environ["MOUNTAYA_PUBLISHABLE_KEY"]},
    timeout=10,
).json()["data"]

admin_session = requests.post(
    "https://api.mountaya.com/v1/sessions",
    headers={"X-API-Key": os.environ["MOUNTAYA_SECRET_KEY"]},
    json={"publishable_key": os.environ["MOUNTAYA_MANAGEMENT_KEY"]},
    timeout=10,
).json()["data"]

members = requests.get(
    f"https://api.mountaya.com/v1/organizations/{organization['id']}/members",
    headers={
        "X-API-Key": os.environ["MOUNTAYA_MANAGEMENT_KEY"],
        "X-Session-Token": admin_session["token"],
    },
    timeout=30,
).json()["data"]

print([(member["email"], member["user_id"]) for member in members])
```

**Response (abridged)**

```json
[
  {
    "email": "ada@example.com",
    "user_id": "7a4e1c98-3b52-4f60-9d81-c05e2f7a83b1",
    "role": "owner"
  }
]
```

Match the person signed in to your product by `email`, and store their `user_id`.

- The Mountaya app shows no user ids: list them with `GET /v1/organizations/{organization_id}/members` (`management` scope and a session token). `role` narrows the listing; it pages by cursor.
- `POST /v1/organizations/lookup` takes no credential: it resolves the organization of the publishable key in its body. The key must carry `publishing` or `studio-embedded`; any other key, unknown or revoked, answers `404`.
- `management` is carried alone on its key. A session token minted for it with no `user_id`, for the default surface, reaches every `management` read with no member role asked, so it stays on your own backend; never hand it to a browser.
- A member listed without `email` or `name` has an account that could not be resolved at that moment.
- A person with a pending invitation is not a member yet and is not listed; a token may still be minted for them, matched by a verified email address, and reaches only the operations under `/v1/me` marked `x-pending-invitee`.

## Next steps

- [Run Mountaya from your backend](https://docs.mountaya.com/en/apis/map-studio/server-integration.md): Keep the keys on your server and renew tokens before they expire.
- [Publishing](https://docs.mountaya.com/en/apis/map-studio/publishing.md): Edit after a publish, take it down, and handle conflicts.
- [API reference](https://docs.mountaya.com/en/apis/map-studio/reference.md): Segments, waypoints, groups, zones and collections.
