# Manage members, invitations and keys

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

Invite people to your organization, find their user ids, change their roles, remove them, and create and revoke publishable keys.

People join your organization by invitation, and each member holds one role. Your backend administers members and publishable keys with a key of its own, the management key.

## Before you start

Create a key that carries the `management` scope under **Organization → API keys** in the [Mountaya app](https://app.mountaya.com/api-keys). It carries no other scope, so it stays on your server. Your organization's id is in the app's address, after `/organizations/`.

```bash
export MOUNTAYA_MANAGEMENT_KEY="pk_your_publishable_key"
export MOUNTAYA_ORGANIZATION_ID="a5eec5f3-3463-4b20-9469-de3eeb870a7a"
```

Changes act as an owner or admin, so mint the token for one:

**cURL**

```bash
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\", \"user_id\": \"7a4e1c98-3b52-4f60-9d81-c05e2f7a83b1\"}" \
  | jq -r .data.token)
```

**TypeScript**

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

const managementKey = process.env.MOUNTAYA_MANAGEMENT_KEY ?? "";
const organizationId = process.env.MOUNTAYA_ORGANIZATION_ID ?? "";

const server = new Mountaya({
  credential: { secretKey: process.env.MOUNTAYA_SECRET_KEY ?? "" },
});
const { data: session } = await new MountayaAdmin(server).sessions.postSession({
  body: { publishable_key: managementKey, user_id: "7a4e1c98-3b52-4f60-9d81-c05e2f7a83b1" },
});

const mountaya = new Mountaya({
  credential: { publishableKey: managementKey, sessionToken: session.token },
});
```

**Python**

```python
import os
import uuid

import requests

organization_id = os.environ["MOUNTAYA_ORGANIZATION_ID"]
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"],
        "user_id": "7a4e1c98-3b52-4f60-9d81-c05e2f7a83b1",
    },
    timeout=10,
).json()["data"]
```

The samples below read the token as `MOUNTAYA_ADMIN_TOKEN`. It lasts five minutes, so mint another before it expires.

- Every operation on this page takes a publishable key carrying the `management` scope and a session token. A key carrying `management` carries no other scope (`400` on a create or update that lists another beside it), so it never ships to a page.
- Every write (invite, withdraw, change a role, remove, create, update or revoke a key) acts as the user the token names, who must be an owner or admin (`403` otherwise); a token minted without `user_id` is a `401`. Leaving the organization, a member removing themself, is the exception: a contributor or a viewer may.
- Every read (members, invitations, keys) is answered under a token minted for the default surface without `user_id`, asking no role. Keep such a token on your backend: it reads your account. A token naming a user is answered while that user holds the role the read asks: any role for members and invitations, owner or admin for keys.
- Under a key, a token governs members with at most an admin's say, the owner's included: granting, changing or removing `admin`, inviting an admin, an admin leaving, and handing the organization on are the owner's acts in the Mountaya app, and a `403` under any key.
- Your organization's id: the Mountaya app's address, or `POST /v1/organizations/lookup` with a publishable key carrying `publishing` or `studio-embedded`.

## Invite someone

Invite an email address with the role the person holds once they accept:

**cURL**

```bash
INVITATION=$(curl -s -X POST https://api.mountaya.com/v1/organizations/$MOUNTAYA_ORGANIZATION_ID/invitations \
  -H "X-API-Key: $MOUNTAYA_MANAGEMENT_KEY" \
  -H "X-Session-Token: $MOUNTAYA_ADMIN_TOKEN" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"email": "camille@example.com", "role": "contributor"}')

INVITATION_ID=$(echo "$INVITATION" | jq -r .data.id)
echo "$INVITATION" | jq .data
```

**TypeScript**

```typescript
const { data: invitation } = await new MountayaAdmin(mountaya).invitations.postOrganizationInvitation({
  organization_id: organizationId,
  body: { email: "camille@example.com", role: "contributor" },
});
console.log(invitation.id, invitation.expires_at);
```

**Python**

```python
invitation = requests.post(
    f"https://api.mountaya.com/v1/organizations/{organization_id}/invitations",
    headers={
        "X-API-Key": os.environ["MOUNTAYA_MANAGEMENT_KEY"],
        "X-Session-Token": admin_session["token"],
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={"email": "camille@example.com", "role": "contributor"},
    timeout=30,
).json()["data"]
invitation_id = invitation["id"]

print(invitation["id"], invitation["expires_at"])
```

**Response**

```json
{
  "id": "3d6f0a2b-4c1e-4f87-9b25-7e0c1d9a6f43",
  "email": "camille@example.com",
  "role": "contributor",
  "invited_by": { "id": "7a4e1c98-3b52-4f60-9d81-c05e2f7a83b1" },
  "created_at": "2026-11-19T09:12:44Z",
  "expires_at": "2026-12-19T09:12:44Z"
}
```

Mountaya sends nothing to the address, so tell the person yourself. They accept in the Mountaya app, once their account has verified that address. Each member and each waiting invitation holds one of the seats your agreement allows.

- `POST /v1/organizations/{organization_id}/invitations` answers `201`. `role` is `admin`, `contributor` or `viewer`: `owner` is a `400`, and `admin` is a `403` under any key. One request invites one address, stored trimmed and lowercased, and any well-formed address is answered alike whether or not an account carries it.
- An address that is already a member's, or already has an invitation waiting, is a `409` naming which. To change a waiting invitation's role, withdraw it and invite again.
- An invitation holds a seat from the moment it is made. Members and unexpired invitations together past the seats the agreement allows is a `429` coded `LIMIT_REACHED`, `extensions.metadata.limit` reading `seats`; more than 500 invitations waiting at once is the same with `pending-invitations`. Neither carries `Retry-After`: free a seat, or change the agreement.
- Invitations are limited to 30 a minute per member and 200 a day per organization (`429` with `Retry-After`).
- An invitation expires thirty days after it is made, which frees its seat. Accepting it makes the person a member; declining, withdrawing or expiry removes it.
- The person may also accept through the API: a token `POST /v1/sessions` mints for their `user_id` while their invitation waits (matched by an address their account has verified) reaches `GET /v1/me/invitations` and `POST /v1/me/invitations/{invitation_id}/accept`, under a key carrying `studio-embedded`. Such a token reaches nothing else of the organization until they accept.
- `GET /v1/organizations/{organization_id}/invitations` lists the invitations still waiting, newest first, a page at a time.

## Find each member's user id

List the members, then match each person signed in to your product by `email` and store their `user_id`. Their session tokens are minted with it.

**cURL**

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

**TypeScript**

```typescript
const { data: members } = await new MountayaAdmin(mountaya).members.getOrganizationMembers({
  organization_id: organizationId,
});

console.log(members.map(({ user_id, email, role }) => ({ user_id, email, role })));
```

**Python**

```python
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([{key: member.get(key) for key in ("user_id", "email", "role")} for member in members])
```

**Response**

```json
[
  {
    "user_id": "7a4e1c98-3b52-4f60-9d81-c05e2f7a83b1",
    "email": "ada@example.com",
    "role": "owner"
  },
  {
    "user_id": "7f3c1d92-4a08-4b6e-9c15-2d84e0b7a361",
    "email": "camille@example.com",
    "role": "contributor"
  }
]
```

- `GET /v1/organizations/{organization_id}/members` lists everybody who has joined, a page at a time: follow `extensions.metadata.pagination.next_cursor` until it is `null`. `role` narrows it, and `sort` orders it by `joined_at`, oldest first by default.
- A person whose invitation still waits is not listed. A member whose account cannot be resolved at that moment is listed without `email` and `name`.
- Roles: `owner` (one per organization), `admin`, `contributor`, `viewer`. Owners, admins and contributors write content; a viewer reads.

## Change a role

Send the role the member holds from their next request on:

**cURL**

```bash
curl -s -X PATCH https://api.mountaya.com/v1/organizations/$MOUNTAYA_ORGANIZATION_ID/members/7f3c1d92-4a08-4b6e-9c15-2d84e0b7a361 \
  -H "X-API-Key: $MOUNTAYA_MANAGEMENT_KEY" \
  -H "X-Session-Token: $MOUNTAYA_ADMIN_TOKEN" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"role": "viewer"}' \
  | jq '.data | {user_id, email, role}'
```

**TypeScript**

```typescript
const { data: member } = await new MountayaAdmin(mountaya).members.patchOrganizationMember({
  organization_id: organizationId,
  user_id: "7f3c1d92-4a08-4b6e-9c15-2d84e0b7a361",
  body: { role: "viewer" },
});

console.log(member.user_id, member.role);
```

**Python**

```python
member = requests.patch(
    f"https://api.mountaya.com/v1/organizations/{organization_id}/members/7f3c1d92-4a08-4b6e-9c15-2d84e0b7a361",
    headers={
        "X-API-Key": os.environ["MOUNTAYA_MANAGEMENT_KEY"],
        "X-Session-Token": admin_session["token"],
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={"role": "viewer"},
    timeout=30,
).json()["data"]

print(member["user_id"], member["role"])
```

**Response**

```json
{
  "user_id": "7f3c1d92-4a08-4b6e-9c15-2d84e0b7a361",
  "email": "camille@example.com",
  "role": "viewer"
}
```

Through the API, a member moves between `contributor` and `viewer`. Granting or changing `admin` is the owner's, in the Mountaya app.

- `PATCH /v1/organizations/{organization_id}/members/{user_id}` answers `200` with the member. `owner` is not a value it takes (`400`), and the owner's role cannot be changed (`409`): ownership moves only in the Mountaya app.
- A `user_id` that matches no member who has joined is a `404`. Sending the role the member already holds changes nothing.
- A role changes nothing about seats: each member holds one seat, whatever their role.

## Remove a member or withdraw an invitation

Removing a member frees their seat, and what they created stays with your organization. Withdrawing an invitation frees its seat too:

**cURL**

```bash
curl -s -X DELETE https://api.mountaya.com/v1/organizations/$MOUNTAYA_ORGANIZATION_ID/members/7f3c1d92-4a08-4b6e-9c15-2d84e0b7a361 \
  -H "X-API-Key: $MOUNTAYA_MANAGEMENT_KEY" \
  -H "X-Session-Token: $MOUNTAYA_ADMIN_TOKEN" \
  -H "Idempotency-Key: $(uuidgen)"

curl -s -X DELETE https://api.mountaya.com/v1/organizations/$MOUNTAYA_ORGANIZATION_ID/invitations/$INVITATION_ID \
  -H "X-API-Key: $MOUNTAYA_MANAGEMENT_KEY" \
  -H "X-Session-Token: $MOUNTAYA_ADMIN_TOKEN" \
  -H "Idempotency-Key: $(uuidgen)"
```

**TypeScript**

```typescript
await new MountayaAdmin(mountaya).members.deleteOrganizationMember({
  organization_id: organizationId,
  user_id: "7f3c1d92-4a08-4b6e-9c15-2d84e0b7a361",
});

const { data: waiting } = await new MountayaAdmin(mountaya).invitations.getOrganizationInvitations({
  organization_id: organizationId,
});
const pending = waiting.find((item) => item.email === "camille@example.com");
if (pending !== undefined) {
  await new MountayaAdmin(mountaya).invitations.deleteOrganizationInvitation({
    organization_id: organizationId,
    invitation_id: pending.id,
  });
}
```

**Python**

```python
requests.delete(
    f"https://api.mountaya.com/v1/organizations/{organization_id}/members/7f3c1d92-4a08-4b6e-9c15-2d84e0b7a361",
    headers={
        "X-API-Key": os.environ["MOUNTAYA_MANAGEMENT_KEY"],
        "X-Session-Token": admin_session["token"],
        "Idempotency-Key": str(uuid.uuid4()),
    },
    timeout=30,
).raise_for_status()

requests.delete(
    f"https://api.mountaya.com/v1/organizations/{organization_id}/invitations/{invitation_id}",
    headers={
        "X-API-Key": os.environ["MOUNTAYA_MANAGEMENT_KEY"],
        "X-Session-Token": admin_session["token"],
        "Idempotency-Key": str(uuid.uuid4()),
    },
    timeout=30,
).raise_for_status()
```

**Response**

```json
{
  "data": null
}
```

- `DELETE /v1/organizations/{organization_id}/members/{user_id}` answers `200` with `data: null`. A `user_id` that matches no member who has joined answers `200` too and changes nothing, so a repeat is harmless. The owner cannot be removed (`409`), and removing an admin is a `403` under any key.
- The removed member's session tokens act as nobody from their next request: every write is refused, and every read serves published content only, as the key alone does.
- A contributor or viewer leaves by naming themself, under a token minted for them. An admin and the owner leave only in the Mountaya app.
- `DELETE /v1/organizations/{organization_id}/invitations/{invitation_id}` answers `200` with `data: null`, and so does an invitation already accepted, declined, withdrawn or expired. An accepted invitation is a member: remove the member instead.

## Create and revoke publishable keys

A publishable key reaches only the scopes it carries. Create one per app, with what that app needs:

**cURL**

```bash
KEY=$(curl -s -X POST https://api.mountaya.com/v1/organizations/$MOUNTAYA_ORGANIZATION_ID/publishable-keys \
  -H "X-API-Key: $MOUNTAYA_MANAGEMENT_KEY" \
  -H "X-Session-Token: $MOUNTAYA_ADMIN_TOKEN" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"name": "Website embed", "scopes": ["publishing", "tiles"]}')

KEY_ID=$(echo "$KEY" | jq -r .data.id)
echo "$KEY" | jq '.data | {id, name, key, scopes}'
```

**TypeScript**

```typescript
const { data: created } = await new MountayaAdmin(mountaya).keys.postOrganizationPublishableKey({
  organization_id: organizationId,
  body: { name: "Website embed", scopes: ["publishing", "tiles"] },
});
console.log(created.key, created.scopes);
```

**Python**

```python
created = requests.post(
    f"https://api.mountaya.com/v1/organizations/{organization_id}/publishable-keys",
    headers={
        "X-API-Key": os.environ["MOUNTAYA_MANAGEMENT_KEY"],
        "X-Session-Token": admin_session["token"],
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={"name": "Website embed", "scopes": ["publishing", "tiles"]},
    timeout=30,
).json()["data"]
key_id = created["id"]

print(created["key"], created["scopes"])
```

**Response (abridged)**

```json
{
  "id": "3b1f9c02-6d4e-4a87-b5c1-70e2af3d8916",
  "name": "Website embed",
  "key": "pk_your_publishable_key",
  "scopes": ["publishing", "tiles"]
}
```

Revoke a key you no longer use. To rotate one, create its replacement, deploy it, then revoke the old key. Every request with a revoked key fails at once:

**cURL**

```bash
curl -s -X DELETE https://api.mountaya.com/v1/organizations/$MOUNTAYA_ORGANIZATION_ID/publishable-keys/$KEY_ID \
  -H "X-API-Key: $MOUNTAYA_MANAGEMENT_KEY" \
  -H "X-Session-Token: $MOUNTAYA_ADMIN_TOKEN" \
  -H "Idempotency-Key: $(uuidgen)" \
  | jq '.data | {id, name, revoked_at}'
```

**TypeScript**

```typescript
const { data: keys } = await new MountayaAdmin(mountaya).keys.getOrganizationPublishableKeys({
  organization_id: organizationId,
});
const old = keys.find((key) => key.name === "Website embed" && key.revoked_at === undefined);
if (old !== undefined) {
  const { data: revoked } = await new MountayaAdmin(mountaya).keys.deleteOrganizationPublishableKey({
    organization_id: organizationId,
    key_id: old.id,
  });

  console.log(revoked.id, revoked.revoked_at);
}
```

**Python**

```python
revoked = requests.delete(
    f"https://api.mountaya.com/v1/organizations/{organization_id}/publishable-keys/{key_id}",
    headers={
        "X-API-Key": os.environ["MOUNTAYA_MANAGEMENT_KEY"],
        "X-Session-Token": admin_session["token"],
        "Idempotency-Key": str(uuid.uuid4()),
    },
    timeout=30,
).json()["data"]

print(revoked["id"], revoked["revoked_at"])
```

**Response (abridged)**

```json
{
  "id": "3b1f9c02-6d4e-4a87-b5c1-70e2af3d8916",
  "name": "Website embed",
  "revoked_at": "2026-11-19T10:02:31Z"
}
```

Secret keys are created and revoked in the Mountaya app only.

- `POST /v1/organizations/{organization_id}/publishable-keys` answers `201` with the key, its value at `key` (`pk_` and 32 lowercase hexadecimal characters), returned in full on every read. Both `name` (2 to 30 characters) and `scopes` are required; an empty `scopes` is a `400`. The key carries exactly the scopes listed: nothing is added for you.
- Scopes: `publishing`, `studio-embedded`, `tiles`, `data`, `mcp`, `management`. `management` beside another scope is a `400`, one entry per other scope. `studio-embedded` without `tiles` and `data` is a `400`, one entry per missing scope. A scope whose product the organization does not hold is a `402`, one entry per refused scope. Nothing is created on any of them.
- `PATCH /v1/organizations/{organization_id}/publishable-keys/{key_id}` changes `name`, `scopes`, or both. `scopes` is replaced whole: list every scope the key keeps. The `pk_` value never changes; a revoked key cannot be changed (`409`). Requests with the key are judged by its new scopes from the next one.
- `DELETE` on the same path revokes the key, answers it with `revoked_at` and its `ETag`, and cannot be undone. Revoking a revoked key answers `200` again. Every client presenting it is a `401` from the next request; a session minted against it ends too. An answer a shared cache holds is served until it expires: at most 5 minutes for a public tile, 6 for a published itinerary read, and 25 hours for the layer catalog.
- Send the key's `etag` as `If-Match` to update or revoke only the version you read (`412` otherwise).
- `GET /v1/organizations/{organization_id}/publishable-keys` lists the keys, revoked ones included with `revoked_at`, newest first; `scope` narrows it.
- Secret keys are absent from the API: no operation lists, creates or revokes one. A secret key's value is shown once, at creation in the Mountaya app. Revoking one stops new session tokens; tokens already minted stay valid until they expire, at most five minutes.

## Next steps

- [Run Mountaya from your backend](https://docs.mountaya.com/en/apis/map-studio/server-integration.md): Mint each member's token, and renew it in time.
- [Members reference](https://docs.mountaya.com/en/apis/map-studio/reference/organization-members.md): Every member and invitation operation.
