Get started
Map Studio API

Quickstart

Quickstart

Create and publish an itinerary in five calls. You need two keys from Organization → API keys in the Mountaya app, 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).
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.

export MOUNTAYA_SESSION_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)
Response
{
  "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.

2

Find the activity

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

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

3

Create the itinerary

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

ITINERARY_ID=$(curl -s -X POST https://api.mountaya.com/v1/itineraries \
  -H "X-API-Key: $MOUNTAYA_PUBLISHABLE_KEY" \
  -H "X-Session-Token: $MOUNTAYA_SESSION_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)
Response
{
  "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.

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 -s -X POST https://api.mountaya.com/v1/itineraries/$ITINERARY_ID/segments \
  -H "X-API-Key: $MOUNTAYA_PUBLISHABLE_KEY" \
  -H "X-Session-Token: $MOUNTAYA_SESSION_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}]}'
Response (abridged)
{
  "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.

5

Publish it

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

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_SESSION_TOKEN" \
  -H "Idempotency-Key: $(uuidgen)" \
  | jq '.data | {status, published_at, has_unpublished_changes}'
Response (abridged)
{
  "status": "published",
  "published_at": "2026-11-09T11:07:56.536793Z",
  "has_unpublished_changes": false
}

Your itinerary now shows in embeds and share links. Publishing covers edits after a publish.

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.

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)

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: $ADMIN_TOKEN" \
  | jq '[.data[] | {email, user_id, role}]'
Response (abridged)
[
  {
    "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.

Next steps

Last updated