# API Keys

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

The publishable keys an organization issues: what each one is called, which scopes it carries, and when it was last used.

 A publishable key is meant to be seen, so its value is returned in full on every read. Every operation here needs a session token beside the key.

## The PublishableKey object

A publishable key: the credential a browser presents. It is safe to ship in a page, which is why what it reaches is narrowed by its scopes and why a `management` scope is never enough on its own.

- `created_at` (string (date-time), required): Timestamp of the publishable key's creation.

- `etag` (string, required): The version of the key, the one the `ETag` of a read of it carries, opaque and compared whole. It moves on every change to the key's name or scopes and when it is revoked. Send it as `If-Match` to make `patchOrganizationPublishableKey` or `deleteOrganizationPublishableKey` conditional.

- `id` (string (uuid), required): Identifier of the key. It is what names the key on an update or a revocation, and is not the key itself.

- `key` (string, required): The key value, the `pk_` token a client sends as `X-API-Key`. Always the `pk_` prefix followed by 32 lowercase hexadecimal characters, 35 in all, the shape every key is minted with. It is returned in full on every read, because a publishable key is meant to be seen.

- `last_used_at` (string (date-time)): Timestamp of the last request that presented this key, recorded at most once a minute, so it may trail the latest use by up to a minute. Absent on a key never used.

- `name` (string, required): Display name of the publishable key.

- `organization_id` (string (uuid), required): Identifier of the organization the key belongs to.

- `revoked_at` (string (date-time)): Timestamp of the key's revocation. Absent on a key still in force.

- `scopes` (array of string, required): The scopes the key carries, each at most once, in the order `PublishableKeyScope` declares them whatever order they were sent in. A key in force carries at least one, and one carrying `management` carries no other. A revoked key lists what it carried when it was revoked, which can be none. The list is what the key was given and nothing more, so no scope appears because another is present. A scope stays listed when its product is later switched off for the organization, and answers `402` where it is used until the product returns.

### An example PublishableKey

```json
{
  "id": "3b1f9c02-6d4e-4a87-b5c1-70e2af3d8916",
  "organization_id": "d5a83e17-92c6-4b0f-a7d3-1e6482f9c05b",
  "name": "Website embed",
  "key": "pk_9f3c2a71b845d0e4c7a6b3f180d92e5a",
  "created_at": "2026-02-03T11:45:02Z",
  "etag": "\"d3\"",
  "last_used_at": "2026-08-22T18:07:44Z",
  "scopes": [
    "publishing"
  ]
}
```

## List an organization's publishable keys

### GET /v1/organizations/{organization_id}/publishable-keys

- Operation: `getOrganizationPublishableKeys`
- Requires: scope `management` · acting user optional (a session token naming a member, or one minted without `user_id`)
- Behavior: idempotent, safe to retry · answers within 30000 ms or times out

Returns the publishable keys the organization holds, revoked ones included, each with its scopes, when it was created and when a request last presented it. The key value itself is returned in full: a publishable key is meant to be seen, which is what distinguishes it from the secret key that mints sessions.

- A session token minted for `api` without `user_id` is asked for no member role on this read; one minted for `studio-embedded` without `user_id` is the `401` a key alone gets. One that names a user is answered only while that user holds the owner or admin role in the organization, and is a 403 otherwise. Creating, changing and revoking keys take the same role, held by the user the session token names, which a write requires.
- A revoked key carries `revoked_at` and stays in the listing, so an audit of what was once in circulation does not need a second source.
- `scope` keeps the keys given that scope, revoked ones included.
- The listing is paged. Nothing caps how many keys an organization mints, so a page holds 50 keys unless `limit` says otherwise, most recently created first unless `sort` says otherwise. Send the page's `next_cursor` back as `cursor` for the next one; the last page reports `next_cursor: null`.

Like every read made with a session token naming a user, it is limited to 1200 a minute per user the token names and then to 6000 a minute per organization, and one made with a session token minted without `user_id` is held as the key alone is, to 600 a minute per client IP address and then 6000 per organization; past either, the answer is a `429` carrying `Retry-After`.

Requires a publishable key with the `management` scope AND a session token. A publishable key without a session token is not accepted here: a key written to be shipped in a browser cannot be sufficient on its own to read or change an organization's account.

**Path parameters**

- `organization_id` (string (uuid), in path, required): Identifier of the organization the operation acts on. A publishable key reaches only its own organization: any other identifier is a 403, whether or not it exists, so the parameter cannot be used to probe which organization ids exist.

**Query parameters**

- `cursor` (string, in query, optional): Where the page starts: the `next_cursor` the previous page reported at `extensions.metadata.pagination`, sent back unchanged. Omitted, the listing starts at its first item.

  A cursor is opaque: it is not an offset and not an identifier, and a client never builds or edits one, and it is never longer than 1024 characters. It is bound to the operation that issued it, to its filters and its `sort`, and to the scope it listed, such as the organization or the collection in the path or the key's own organization. On `getItineraries`, `getZones` and `getCollections`, whose scope `organization_id` may leave implicit, it is bound as well to the tier of the credential it was issued to, a key alone (or with a session token minted without `user_id`, which reads as one) or a key with a session token naming a member. The next page is asked for the same way. A cursor sent to another operation, with different filters, a different `sort`, another scope or, on those three, another tier of credential, or altered in any way, is a `400` at `["request", "query", "cursor"]`. On every listing, each page applies the read tier of the credential that asks for it. Paging is by position in the sort order rather than by count, so an item whose sort key does not change is never skipped or served twice, whatever is created or deleted between two pages.

- `limit` (integer (int32), in query, optional, default: `50`): How many items one page holds, between 1 and 100; 50 when omitted, on every listing that pages. `extensions.metadata.pagination.limit` reports the size the page was served at. A page shorter than `limit` is not how the end is told: the end is a `next_cursor` of `null`. The page is cut after authorization, so it never widens what a caller can read.

- `scope` (string, in query, optional, one of: `publishing`, `studio-embedded`, `tiles`, `data`, `mcp`, `management`): Keep only the keys given this scope. It reads the scopes a key carries, not the ones they include, so a key carrying `studio-embedded`, `tiles` and `data` is not kept for `publishing`.

- `sort` (string, in query, optional, default: `-created_at`, one of: `-created_at`, `created_at`, `name`, `-name`): The order of the listing, by one field: `created_at` or `name`, ascending, or either with a leading `-`, descending. Omitted, it is `-created_at`, the most recently created first. Publishable keys that tie on the field are ordered by `id`.

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

**Response** `200`

One page of the organization's publishable keys, revoked ones included, in the order `sort` names. `extensions.metadata.pagination.next_cursor` asks for the next page, and is `null` on the last.

- `extensions` (object, required): The envelope's second half, everything the answer carries that is not the answer itself. Here that is `metadata.pagination` alone: the `limit` this page was served at, and the `next_cursor` of the page after it, null on the last.
  - `metadata` (ListMetadata, required): The `extensions.metadata` object every listing that pages returns. It carries the page and nothing else, so `extensions.metadata.pagination` is the one path a client reads paging from. A listing that does not page, a catalog or a usage series, answers with no `extensions` at all.
    - `pagination` (object, required): The page this listing served, and the cursor of the next one.
      - `limit` (integer (int32), required): The page size the listing was served at: the `limit` sent, or 50 when none was.
      - `next_cursor` (string | null, required): The `cursor` that asks for the page after this one, with the same filters and `sort`, or null when this page is the last. A page that is not the last may hold fewer than `limit` items; the end is told by this field alone.

- `data` (array of PublishableKey, required): See [the PublishableKey object](https://docs.mountaya.com/en/apis/map-studio/reference/api-keys.md#publishable-key-object).

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

- `400`: Bad Request
- `401`: Unauthorized
- `403`: The credential is valid and this operation is not open to it: the key does not carry the `management` scope, or the path names an organization other than the key's own, whether or not it exists, or the session token names a user without the owner or admin role in the organization. A session token minted for `api` without `user_id` is asked for no role: it IS the organization's own backend's credential, minted server-side from its secret key, so it authorizes the read without a member behind it. One minted for `studio-embedded` without `user_id` is the `401` a key alone gets. The blanket refusal in the [order of checks](https://docs.mountaya.com/en/apis/conventions/errors.md#which-refusal-you-get-first), an `Origin` or `Referer` the organization does not allow, answers here as well.
- `404`: Answered only from Mountaya's web application: the path names an organization the person is not a member of, or one that does not exist. The two answer alike, so the path cannot be used to learn which organizations exist. Under a publishable key an identifier other than the key's organization is a `403` instead, whether or not it exists.
- `429`: `TooManyRequests`, given in full at the end of this page.
- `500`: Internal Server Error
- `504`: Gateway Timeout

**cURL**

```bash
curl -s https://api.mountaya.com/v1/organizations/d5a83e17-92c6-4b0f-a7d3-1e6482f9c05b/publishable-keys \
  -H "X-API-Key: pk_your_publishable_key" \
  -H "X-Session-Token: sess_your_session_token" | jq '.data'
```

**TypeScript**

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

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

const { data } = await admin.keys.getOrganizationPublishableKeys({ organization_id: "d5a83e17-92c6-4b0f-a7d3-1e6482f9c05b" });

console.log(data);
```

**Python**

```python
import requests

response = requests.get(
    "https://api.mountaya.com/v1/organizations/d5a83e17-92c6-4b0f-a7d3-1e6482f9c05b/publishable-keys",
    headers={
        "X-API-Key": "pk_your_publishable_key",
        "X-Session-Token": "sess_your_session_token",
    },
    timeout=30,
)
response.raise_for_status()
print(response.json()["data"])
```

Response 200:

```json
{
  "data": [
    {
      "id": "3b1f9c02-6d4e-4a87-b5c1-70e2af3d8916",
      "organization_id": "d5a83e17-92c6-4b0f-a7d3-1e6482f9c05b",
      "name": "Website embed",
      "key": "pk_9f3c2a71b845d0e4c7a6b3f180d92e5a",
      "created_at": "2026-02-03T11:45:02Z",
      "etag": "\"d3\"",
      "last_used_at": "2026-08-22T18:07:44Z",
      "scopes": [
        "publishing"
      ]
    }
  ],
  "extensions": {
    "metadata": {
      "pagination": {
        "limit": 50,
        "next_cursor": "eyJ2IjoxLCJzIjoiLXVwZGF0ZWRfYXQifQ"
      }
    }
  }
}
```

## Create a publishable key

### POST /v1/organizations/{organization_id}/publishable-keys

- Operation: `postOrganizationPublishableKey`
- Requires: scope `management` · acting user required (a session token naming a member) · an `Idempotency-Key` header, the same on every retry
- Behavior: answers within 30000 ms or times out

Creates a publishable key with exactly the scopes the request names: none is added because another is present. Both the name and the scopes are required, and an empty `scopes` list is a `400` naming `scopes`: a key with no scopes reaches nothing, so there is no useful default to fall back on. The key value is returned here and on every later read, so nothing is lost by not recording it now. A create sent twice without an `Idempotency-Key` makes two keys; with one, the second is answered the first one's key. A create sent again with it, after the first failed with a `5xx` once the key was made, is the `409` coded `IDEMPOTENCY_ANSWER_UNAVAILABLE`, whose `extensions.metadata.location` names the key made, `/v1/organizations/{organization_id}/publishable-keys/{key_id}`, so carry on with that one rather than creating it again.

- Owner or admin only (403 otherwise).
- A key carrying `management` carries no other scope. A `scopes` list naming `management` beside another scope is a `400` and no key is created: the answer carries one `VALIDATION_FAILED` entry per scope listed beside `management`, each naming that scope's position in `scopes`. It is asked before any scope's product, so such a list is never answered `402`.
- A key carrying `studio-embedded` carries `tiles` and `data` beside it, the scopes its editor's map and previews are requested under. A `scopes` list naming `studio-embedded` without one of them is a `400` and no key is created: the answer carries one `VALIDATION_FAILED` entry per missing scope, each naming `scopes`. Neither is added for the caller, and it is asked before any scope's product, so such a list is never answered `402`.
- A scope can be granted only while the organization holds its product. Granting one it does not hold is a `402` and no key is created: the answer carries one entry per refused scope, each naming that scope's position in `scopes`. `publishing` needs Map Publishing, `studio-embedded` needs Embedded Studio and Map Studio, and `tiles` needs the Tile API, each granted by the organization's agreement with Mountaya. `data` and `mcp` need the Data API, which the organization holds once its first card has opened its Data API subscription, or by its agreement, so they are refused before that. `management` belongs to no product and is never refused this way.
- A key keeps a scope whose product is later switched off. The scope answers `402` wherever a request uses it, and works again once the product returns.

Requires a publishable key with the `management` scope AND a session token naming a user, a member with the owner or admin role, whom the request acts as. A session token minted without `user_id` is refused with **401**, and a publishable key without a session token is not accepted here: a key written to be shipped in a browser cannot be sufficient on its own to read or change an organization's account.

**Webhook events** [`organization.publishable_key.created`](https://docs.mountaya.com/en/webhooks/events/organization-publishable-key.md#organization-publishable-key-created), recorded by the task `organization.publishable_key.create`.

**Path parameters**

- `organization_id` (string (uuid), in path, required): Identifier of the organization the operation acts on. A publishable key reaches only its own organization: any other identifier is a 403, whether or not it exists, so the parameter cannot be used to probe which organization ids exist.

**Headers**

- `Idempotency-Key` (string, in header, optional): A value the caller chooses once per logical write and sends again, unchanged, on every retry of it, so a write whose answer was lost runs at most once. A UUID is the usual choice; any 1 to 255 printable ASCII characters without a space are accepted. The key is held for 12 hours, for the credential that sent it (the publishable key and the user its session token names) and for this operation.

  The first request runs. A request repeating the key with the same method, path, query and body, sent as the same media type, is answered with the first one's stored status and body, its `Location` and `ETag` included, and carries `Idempotent-Replayed: true`; nothing runs a second time and no limit is charged again. `Content-Type` is compared as the media type it names, with its `charset`, rather than as the header was written, so the letter case of the type and the spacing around its parameters do not make two requests different. `If-Match` is not compared: a key sent again after a `412`, with a fresh tag, is answered with that same `412`, so a write retried with a new tag takes a new key. Every answer below `500` other than a `429` is stored that way, a refusal included, so a retried request that was refused is refused again in the same words. A request refused before the write is reached stores nothing, and a retry with the same key runs again: every `401`, and every `413` refusing a body over the operation's ceiling. The `413` that `postItineraryPreview` answers for the source it has read, a file or a track too large, is stored as any other refusal is.

  A `5xx` answered before anything was written stores nothing and releases the key: a retry with the same key runs again. A `5xx` answered after the write was made keeps the key, and a request repeating it is a `409` whose entry is coded `IDEMPOTENCY_ANSWER_UNAVAILABLE`, as is a request repeating the key of an answer too large to store whole. Either way the write was made: the `409` carries no `Location`, and its `extensions.metadata` (`ResponseMetadataIdempotentAnswer`) names the `status` the first request was answered with and, where that answer carried them, its `location` and `etag`. Read the resource again rather than sending the write once more, which is answered the same way.

  The same key with a different request is a `400` at `["request", "headers", "Idempotency-Key"]`, and nothing runs, whether the first request is still running or was answered. The same request while its first one is still running is a `409` whose entry is coded `IDEMPOTENCY_KEY_IN_USE`, carrying `Retry-After`: send it again once that has passed. Without the header a write runs every time it is sent, which is harmless on the writes `x-idempotent` marks safe to repeat and creates a second resource on the others. A stream's answer is never stored.

  Keys are kept on a best-effort basis. While Mountaya cannot read or record them, a write runs as if it carried no key, so a retry sent in that moment can run it a second time.

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

**Body**

What the key is for, and the scopes it carries.

- `name` (string, in body, required): Display name of the publishable key: 2 to 30 characters as sent, and still at least 2 once leading and trailing whitespace is trimmed, which is the form it is stored in. A name is one line: a tab, a line break or a line separator between two of its characters is a `400`, and one at either end is trimmed with the whitespace there.

- `scopes` (array of string, in body, required): The scopes to give the key, each at most once. A key carries at least one: an empty list is a `400` naming `scopes`. A scope is granted only while the organization holds its product, so one it does not hold is a `402` naming its position in the list. `management` is carried alone: a list naming it beside another scope is a `400` naming the position of each scope beside it. `studio-embedded` is carried with `tiles` and `data`: a list naming it without one of them is a `400` naming `scopes`, once per missing scope.

**Response** `201`

The key as created, including the `pk_` value to send as `X-API-Key`. `Location` names it, `/v1/organizations/{organization_id}/publishable-keys/{key_id}`, the path `getOrganizationPublishableKey` reads it at.

- `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` (PublishableKey, required): A publishable key: the credential a browser presents. It is safe to ship in a page, which is why what it reaches is narrowed by its scopes and why a `management` scope is never enough on its own.

  See [the PublishableKey object](https://docs.mountaya.com/en/apis/map-studio/reference/api-keys.md#publishable-key-object).

Response headers:

- `Location`: The path of what the request created, relative to this host. A part of an itinerary is addressed under its itinerary, so a new segment's is `/v1/itineraries/{itinerary_id}/segments/{segment_id}`.
- `ETag`: The version of the resource this answer returns, an opaque strong tag in double quotes, equal to that resource's `etag` field. Send it back as `If-Match` to make a write conditional on nobody having changed the resource since. It changes whenever what this read returns changes; compare it whole and never parse it. Present on every answer that returns the resource, and on the `412` that refuses a stale `If-Match`.
- `Idempotent-Replayed`: `true` when this answer is the stored answer to an earlier request carrying the same `Idempotency-Key`, replayed rather than run again. Absent on an answer that ran.

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

- `400`: The request was malformed, or a field failed validation: each entry names what, a field-level one at its `path`. A `scopes` list naming `management` beside another scope is refused here and no key is created, with one `VALIDATION_FAILED` entry per scope listed beside `management`, each with a `path` ending in that scope's position in `scopes`. It is asked before any scope's product, so such a list is never the `402`. A `scopes` list naming `studio-embedded` without `tiles` or without `data` is refused here as well, before any scope's product, with one `VALIDATION_FAILED` entry per missing scope, each with a `path` ending in `scopes`. The same `Idempotency-Key` sent with another request is refused here too, at `["request", "headers", "Idempotency-Key"]`. A refusal the write itself made is stored for its key, so a repeat of the key is refused again in the same words, marked `Idempotent-Replayed: true`.
- `401`: Unauthorized
- `402`: The request names a scope whose product the organization does not hold, and no key is created. One entry is returned per refused scope, each a plain `PAYMENT_REQUIRED` whose `path` ends in that scope's position in `scopes`, so a client can mark the scopes to drop or the products the organization lacks. `publishing` needs Map Publishing, `studio-embedded` needs Embedded Studio and Map Studio, and `tiles` needs the Tile API, each granted by the organization's agreement with Mountaya. `data` and `mcp` need the Data API, held once the organization's first card has opened its Data API subscription, or by its agreement. `management` belongs to no product and is never refused this way.
- `403`: The credential is valid and this operation is not open to it: the key does not carry the `management` scope, or the path names an organization other than the key's own, whether or not it exists, or the user the session token names is not a member of the key's organization, or is a member who is neither owner nor admin. A user outside the organization and a member without the role answer alike. The blanket refusal in the [order of checks](https://docs.mountaya.com/en/apis/conventions/errors.md#which-refusal-you-get-first), an `Origin` or `Referer` the organization does not allow, answers here as well.
- `404`: Answered only from Mountaya's web application: the path names an organization the person is not a member of, or one that does not exist. The two answer alike, so the path cannot be used to learn which organizations exist. Under a publishable key an identifier other than the key's organization is a `403` instead, whether or not it exists.
- `409`: `IdempotencyKeyInUse`, given in full at the end of this page.
- `413`: Payload Too Large
- `429`: `TooManyRequests`, given in full at the end of this page.
- `500`: Internal Server Error
- `504`: Gateway Timeout

**cURL**

```bash
curl -s -X POST https://api.mountaya.com/v1/organizations/d5a83e17-92c6-4b0f-a7d3-1e6482f9c05b/publishable-keys \
  -H "X-API-Key: pk_your_publishable_key" \
  -H "X-Session-Token: sess_your_session_token" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Website embed",
    "scopes": ["publishing"]
  }'
```

**TypeScript**

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

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

const { data } = await admin.keys.postOrganizationPublishableKey({
  organization_id: "d5a83e17-92c6-4b0f-a7d3-1e6482f9c05b",
  body: { name: "Website embed", scopes: ["publishing"] },
});

console.log(data);
```

**Python**

```python
import requests
import uuid

response = requests.post(
    "https://api.mountaya.com/v1/organizations/d5a83e17-92c6-4b0f-a7d3-1e6482f9c05b/publishable-keys",
    headers={
        "X-API-Key": "pk_your_publishable_key",
        "X-Session-Token": "sess_your_session_token",
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={"name": "Website embed", "scopes": ["publishing"]},
    timeout=30,
)
response.raise_for_status()
print(response.json()["data"])
```

Response 201:

```json
{
  "data": {
    "id": "3b1f9c02-6d4e-4a87-b5c1-70e2af3d8916",
    "organization_id": "d5a83e17-92c6-4b0f-a7d3-1e6482f9c05b",
    "name": "Website embed",
    "key": "pk_9f3c2a71b845d0e4c7a6b3f180d92e5a",
    "created_at": "2026-02-03T11:45:02Z",
    "etag": "\"d3\"",
    "last_used_at": "2026-08-22T18:07:44Z",
    "scopes": [
      "publishing"
    ]
  }
}
```

## Retrieve a publishable key

### GET /v1/organizations/{organization_id}/publishable-keys/{key_id}

- Operation: `getOrganizationPublishableKey`
- Requires: scope `management` · acting user optional (a session token naming a member, or one minted without `user_id`)
- Behavior: idempotent, safe to retry · answers within 30000 ms or times out

Returns one of the organization's publishable keys, as `getOrganizationPublishableKeys` lists it: its scopes, when it was created, when a request last presented it, and `revoked_at` once it is revoked. A revoked key is still returned, so the key a `Location` or an audit names can always be read back. The key value itself is returned in full, as on every read.

- A session token minted for `api` without `user_id` is asked for no member role on this read; one minted for `studio-embedded` without `user_id` is the `401` a key alone gets. One that names a user is answered only while that user holds the owner or admin role in the organization, and is a 403 otherwise.
- The answer's `ETag` is the key's `etag`. Send it as `If-Match` on `patchOrganizationPublishableKey` or `deleteOrganizationPublishableKey` to make the change conditional on nobody having changed the key since.

Like every read made with a session token naming a user, it is limited to 1200 a minute per user the token names and then to 6000 a minute per organization, and one made with a session token minted without `user_id` is held as the key alone is, to 600 a minute per client IP address and then 6000 per organization; past either, the answer is a `429` carrying `Retry-After`.

Requires a publishable key with the `management` scope AND a session token. A publishable key without a session token is not accepted here: a key written to be shipped in a browser cannot be sufficient on its own to read or change an organization's account.

**Path parameters**

- `organization_id` (string (uuid), in path, required): Identifier of the organization the operation acts on. A publishable key reaches only its own organization: any other identifier is a 403, whether or not it exists, so the parameter cannot be used to probe which organization ids exist.

- `key_id` (string (uuid), in path, required): Identifier of the publishable key the operation acts on. It is the key's `id`, not the `pk_` value the key itself is.

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

**Response** `200`

The key, revoked or not, with the scopes it carries.

- `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` (PublishableKey, required): A publishable key: the credential a browser presents. It is safe to ship in a page, which is why what it reaches is narrowed by its scopes and why a `management` scope is never enough on its own.

  See [the PublishableKey object](https://docs.mountaya.com/en/apis/map-studio/reference/api-keys.md#publishable-key-object).

Response headers:

- `ETag`: The version of the resource this answer returns, an opaque strong tag in double quotes, equal to that resource's `etag` field. Send it back as `If-Match` to make a write conditional on nobody having changed the resource since. It changes whenever what this read returns changes; compare it whole and never parse it. Present on every answer that returns the resource, and on the `412` that refuses a stale `If-Match`.

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

- `400`: Bad Request
- `401`: Unauthorized
- `403`: The credential is valid and this operation is not open to it: the key does not carry the `management` scope, or the path names an organization other than the key's own, whether or not it exists, or the session token names a user without the owner or admin role in the organization. A session token minted for `api` without `user_id` is asked for no role: it IS the organization's own backend's credential, minted server-side from its secret key, so it authorizes the read without a member behind it. One minted for `studio-embedded` without `user_id` is the `401` a key alone gets. The blanket refusal in the [order of checks](https://docs.mountaya.com/en/apis/conventions/errors.md#which-refusal-you-get-first), an `Origin` or `Referer` the organization does not allow, answers here as well.
- `404`: The organization has no publishable key with the identifier given. A key of another organization answers the same way, so a key id cannot be probed here. A revoked key is not this: it is returned.
- `429`: `TooManyRequests`, given in full at the end of this page.
- `500`: Internal Server Error
- `504`: Gateway Timeout

**cURL**

```bash
curl -s https://api.mountaya.com/v1/organizations/d5a83e17-92c6-4b0f-a7d3-1e6482f9c05b/publishable-keys/3b1f9c02-6d4e-4a87-b5c1-70e2af3d8916 \
  -H "X-API-Key: pk_your_publishable_key" \
  -H "X-Session-Token: sess_your_session_token" | jq '.data'
```

**TypeScript**

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

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

const { data } = await admin.keys.getOrganizationPublishableKey({
  organization_id: "d5a83e17-92c6-4b0f-a7d3-1e6482f9c05b",
  key_id: "3b1f9c02-6d4e-4a87-b5c1-70e2af3d8916",
});

console.log(data);
```

**Python**

```python
import requests

response = requests.get(
    "https://api.mountaya.com/v1/organizations/d5a83e17-92c6-4b0f-a7d3-1e6482f9c05b/publishable-keys/3b1f9c02-6d4e-4a87-b5c1-70e2af3d8916",
    headers={
        "X-API-Key": "pk_your_publishable_key",
        "X-Session-Token": "sess_your_session_token",
    },
    timeout=30,
)
response.raise_for_status()
print(response.json()["data"])
```

Response 200:

```json
{
  "data": {
    "id": "3b1f9c02-6d4e-4a87-b5c1-70e2af3d8916",
    "organization_id": "d5a83e17-92c6-4b0f-a7d3-1e6482f9c05b",
    "name": "Website embed",
    "key": "pk_9f3c2a71b845d0e4c7a6b3f180d92e5a",
    "created_at": "2026-02-03T11:45:02Z",
    "etag": "\"d3\"",
    "last_used_at": "2026-08-22T18:07:44Z",
    "scopes": [
      "publishing"
    ]
  }
}
```

## Update a publishable key's name or scopes

### PATCH /v1/organizations/{organization_id}/publishable-keys/{key_id}

- Operation: `patchOrganizationPublishableKey`
- Requires: scope `management` · acting user required (a session token naming a member) · an `Idempotency-Key` header, the same on every retry
- Behavior: idempotent, safe to retry · answers within 30000 ms or times out

Changes what a key is called, what it reaches, or both. Each field is optional and an omitted one is left alone, but `scopes` is replaced whole rather than merged: a request that sends it lists every scope the key is to keep, and a scope left out is removed. Mountaya answers the key's next request by its new scopes, so a page still holding it starts getting 403 on what it stops reaching. An answer a shared cache already holds for the key is served from there until its lifetime runs out: at most 5 minutes for a public tile, 6 for a published itinerary read or its pace (`max-age=300` and `stale-while-revalidate=60`), and 25 hours for the layer catalog (`max-age=86400` and `stale-while-revalidate=3600`).

- Owner or admin only (403 otherwise).
- A key carrying `management` carries no other scope. A `scopes` list naming `management` beside another scope is a `400` and nothing is changed, the name included: the answer carries one `VALIDATION_FAILED` entry per scope listed beside `management`, each naming that scope's position in `scopes`. It is asked whatever the key carries now, and before any scope's product, so such a list is never answered `402`.
- A key carrying `studio-embedded` carries `tiles` and `data` beside it, the scopes its editor's map and previews are requested under. A `scopes` list naming `studio-embedded` without one of them is a `400` and nothing is changed, the name included: the answer carries one `VALIDATION_FAILED` entry per missing scope, each naming `scopes`. Neither is added for the caller, it is asked whatever the key carries now, and before any scope's product, so such a list is never answered `402`.
- A scope the key does not already carry can be granted only while the organization holds its product. Granting one it does not hold is a `402` and nothing is changed, the name included: the answer carries one entry per refused scope, each naming that scope's position in `scopes`.
- A scope the key already carries is kept even when its product has since been switched off, so sending a key its own list back is never refused. Such a scope answers `402` wherever a request uses it, until the product returns.
- The key is given exactly the list sent: none is added because another is present.
- An empty `scopes` list is a `400` naming `scopes`, as it is on creation: a key carries at least one scope.
- The `pk_` value never changes. Replacing a key that has leaked is revoking it and creating another.
- A revoked key cannot be changed: the request is a `409` and nothing is changed.
- `If-Match` makes the change conditional: send the key's `etag`, and a key changed since is refused with `412`, changing nothing.

Requires a publishable key with the `management` scope AND a session token naming a user, a member with the owner or admin role, whom the request acts as. A session token minted without `user_id` is refused with **401**, and a publishable key without a session token is not accepted here: a key written to be shipped in a browser cannot be sufficient on its own to read or change an organization's account.

**Webhook events** [`organization.publishable_key.updated`](https://docs.mountaya.com/en/webhooks/events/organization-publishable-key.md#organization-publishable-key-updated), recorded by the task `organization.publishable_key.update`.

**Path parameters**

- `organization_id` (string (uuid), in path, required): Identifier of the organization the operation acts on. A publishable key reaches only its own organization: any other identifier is a 403, whether or not it exists, so the parameter cannot be used to probe which organization ids exist.

- `key_id` (string (uuid), in path, required): Identifier of the publishable key the operation acts on. It is the key's `id`, not the `pk_` value the key itself is.

**Headers**

- `Idempotency-Key` (string, in header, optional): A value the caller chooses once per logical write and sends again, unchanged, on every retry of it, so a write whose answer was lost runs at most once. A UUID is the usual choice; any 1 to 255 printable ASCII characters without a space are accepted. The key is held for 12 hours, for the credential that sent it (the publishable key and the user its session token names) and for this operation.

  The first request runs. A request repeating the key with the same method, path, query and body, sent as the same media type, is answered with the first one's stored status and body, its `Location` and `ETag` included, and carries `Idempotent-Replayed: true`; nothing runs a second time and no limit is charged again. `Content-Type` is compared as the media type it names, with its `charset`, rather than as the header was written, so the letter case of the type and the spacing around its parameters do not make two requests different. `If-Match` is not compared: a key sent again after a `412`, with a fresh tag, is answered with that same `412`, so a write retried with a new tag takes a new key. Every answer below `500` other than a `429` is stored that way, a refusal included, so a retried request that was refused is refused again in the same words. A request refused before the write is reached stores nothing, and a retry with the same key runs again: every `401`, and every `413` refusing a body over the operation's ceiling. The `413` that `postItineraryPreview` answers for the source it has read, a file or a track too large, is stored as any other refusal is.

  A `5xx` answered before anything was written stores nothing and releases the key: a retry with the same key runs again. A `5xx` answered after the write was made keeps the key, and a request repeating it is a `409` whose entry is coded `IDEMPOTENCY_ANSWER_UNAVAILABLE`, as is a request repeating the key of an answer too large to store whole. Either way the write was made: the `409` carries no `Location`, and its `extensions.metadata` (`ResponseMetadataIdempotentAnswer`) names the `status` the first request was answered with and, where that answer carried them, its `location` and `etag`. Read the resource again rather than sending the write once more, which is answered the same way.

  The same key with a different request is a `400` at `["request", "headers", "Idempotency-Key"]`, and nothing runs, whether the first request is still running or was answered. The same request while its first one is still running is a `409` whose entry is coded `IDEMPOTENCY_KEY_IN_USE`, carrying `Retry-After`: send it again once that has passed. Without the header a write runs every time it is sent, which is harmless on the writes `x-idempotent` marks safe to repeat and creates a second resource on the others. A stream's answer is never stored.

  Keys are kept on a best-effort basis. While Mountaya cannot read or record them, a write runs as if it carried no key, so a retry sent in that moment can run it a second time.

- `If-Match` (string, in header, optional): Makes the write conditional on the resource still being the version the caller read: the `ETag` an earlier answer carried, which is also that resource's `etag` field, or `*` for any version. When the resource has changed since, the write is refused with `412` `PRECONDITION_FAILED`, nothing is changed, and the answer carries the current `ETag`, so the caller reads the resource again and decides. Omitted, the write is unconditional and the last write wins.

  One strong tag in double quotes, or `*`. A list of tags, a weak tag (`W/`) or any other spelling is a `400` naming the header. A resource the caller cannot see is answered `404` before the condition is asked, so a stale tag never tells a caller anything a read would not.

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

**Body**

The name to give the key, the scopes to replace its own with, or both.

- `name` (string, in body, optional): Display name of the publishable key. Omit to keep the current value. When sent, it is 2 to 30 characters as sent, and still at least 2 once leading and trailing whitespace is trimmed, which is the form it is stored in. A name is one line: a tab, a line break or a line separator between two of its characters is a `400`, and one at either end is trimmed with the whitespace there.

- `scopes` (array of string, in body, optional): The scopes the key carries from now on, each at most once, replacing the list it held. Omit to keep the current scopes. A key carries at least one: an empty list is a `400` naming `scopes`. A scope the key does not already carry is granted only while the organization holds its product, so one it does not hold is a `402` naming its position in the list; a scope the key already carries is kept whatever has become of its product. `management` is carried alone: a list naming it beside another scope is a `400` naming the position of each scope beside it. `studio-embedded` is carried with `tiles` and `data`: a list naming it without one of them is a `400` naming `scopes`, once per missing scope, whatever the key carries now.

**Response** `200`

The key after the change, in full.

- `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` (PublishableKey, required): A publishable key: the credential a browser presents. It is safe to ship in a page, which is why what it reaches is narrowed by its scopes and why a `management` scope is never enough on its own.

  See [the PublishableKey object](https://docs.mountaya.com/en/apis/map-studio/reference/api-keys.md#publishable-key-object).

Response headers:

- `ETag`: The version of the resource this answer returns, an opaque strong tag in double quotes, equal to that resource's `etag` field. Send it back as `If-Match` to make a write conditional on nobody having changed the resource since. It changes whenever what this read returns changes; compare it whole and never parse it. Present on every answer that returns the resource, and on the `412` that refuses a stale `If-Match`.
- `Idempotent-Replayed`: `true` when this answer is the stored answer to an earlier request carrying the same `Idempotency-Key`, replayed rather than run again. Absent on an answer that ran.

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

- `400`: The request was malformed, or a field failed validation: each entry names what, a field-level one at its `path`. A `scopes` list naming `management` beside another scope is refused here and nothing is changed, the name included, with one `VALIDATION_FAILED` entry per scope listed beside `management`, each with a `path` ending in that scope's position in `scopes`. It is asked before any scope's product, so such a list is never the `402`. A `scopes` list naming `studio-embedded` without `tiles` or without `data` is refused here as well, before any scope's product and nothing changed, with one `VALIDATION_FAILED` entry per missing scope, each with a `path` ending in `scopes`. The same `Idempotency-Key` sent with another request is refused here too, at `["request", "headers", "Idempotency-Key"]`. A refusal the write itself made is stored for its key, so a repeat of the key is refused again in the same words, marked `Idempotent-Replayed: true`.
- `401`: Unauthorized
- `402`: The request adds a scope whose product the organization does not hold, and nothing is changed. One entry is returned per refused scope, each a plain `PAYMENT_REQUIRED` whose `path` ends in that scope's position in `scopes`, so a client can mark the scopes to drop or the products the organization lacks. Only a scope the key does not already carry is asked about: one it carries is kept whatever has become of its product. `publishing` needs Map Publishing, `studio-embedded` needs Embedded Studio and Map Studio, and `tiles` needs the Tile API, each granted by the organization's agreement with Mountaya. `data` and `mcp` need the Data API, held once the organization's first card has opened its Data API subscription, or by its agreement. `management` belongs to no product and is never refused this way.
- `403`: The credential is valid and this operation is not open to it: the key does not carry the `management` scope, or the path names an organization other than the key's own, whether or not it exists, or the user the session token names is not a member of the key's organization, or is a member who is neither owner nor admin. A user outside the organization and a member without the role answer alike. The blanket refusal in the [order of checks](https://docs.mountaya.com/en/apis/conventions/errors.md#which-refusal-you-get-first), an `Origin` or `Referer` the organization does not allow, answers here as well.
- `404`: The organization has no publishable key with the identifier given. A key of another organization answers the same way, so a key id cannot be probed here.
- `409`: The key is revoked, and a revoked key is never changed again: nothing is changed. Create another key with `postOrganizationPublishableKey`. A request carrying the same `Idempotency-Key` as one still running is refused here too: its entry is coded `IDEMPOTENCY_KEY_IN_USE` and it carries `Retry-After`, after which the same request is answered with the first one's outcome. A request repeating the key of one whose answer cannot be replayed is refused here as well, its entry coded `IDEMPOTENCY_ANSWER_UNAVAILABLE`: the answer was too large to keep whole, or the request failed with a `5xx` after its write was made. Either way that write was made, and `extensions.metadata` is the `ResponseMetadataIdempotentAnswer` naming how it was answered, so read the resource again rather than sending the write once more.
- `412`: `PreconditionFailed`, given in full at the end of this page.
- `413`: Payload Too Large
- `429`: `TooManyRequests`, given in full at the end of this page.
- `500`: Internal Server Error
- `504`: Gateway Timeout

**cURL**

```bash
curl -s -X PATCH https://api.mountaya.com/v1/organizations/d5a83e17-92c6-4b0f-a7d3-1e6482f9c05b/publishable-keys/3b1f9c02-6d4e-4a87-b5c1-70e2af3d8916 \
  -H "X-API-Key: pk_your_publishable_key" \
  -H "X-Session-Token: sess_your_session_token" \
  -H "Content-Type: application/json" \
  -d '{"scopes": ["tiles"]}'
```

**TypeScript**

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

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

const { data } = await admin.keys.patchOrganizationPublishableKey({
  organization_id: "d5a83e17-92c6-4b0f-a7d3-1e6482f9c05b",
  key_id: "3b1f9c02-6d4e-4a87-b5c1-70e2af3d8916",
  body: { scopes: ["tiles"] },
});

console.log(data);
```

**Python**

```python
import requests
import uuid

response = requests.patch(
    "https://api.mountaya.com/v1/organizations/d5a83e17-92c6-4b0f-a7d3-1e6482f9c05b/publishable-keys/3b1f9c02-6d4e-4a87-b5c1-70e2af3d8916",
    headers={
        "X-API-Key": "pk_your_publishable_key",
        "X-Session-Token": "sess_your_session_token",
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={"scopes": ["tiles"]},
    timeout=30,
)
response.raise_for_status()
print(response.json()["data"])
```

Response 200:

```json
{
  "data": {
    "id": "3b1f9c02-6d4e-4a87-b5c1-70e2af3d8916",
    "organization_id": "d5a83e17-92c6-4b0f-a7d3-1e6482f9c05b",
    "name": "Website embed",
    "key": "pk_9f3c2a71b845d0e4c7a6b3f180d92e5a",
    "created_at": "2026-02-03T11:45:02Z",
    "etag": "\"d3\"",
    "last_used_at": "2026-08-22T18:07:44Z",
    "scopes": [
      "publishing"
    ]
  }
}
```

## Revoke a publishable key

### DELETE /v1/organizations/{organization_id}/publishable-keys/{key_id}

- Operation: `deleteOrganizationPublishableKey`
- Requires: scope `management` · acting user required (a session token naming a member) · an `Idempotency-Key` header, the same on every retry
- Behavior: idempotent, safe to retry · answers within 30000 ms or times out

Revokes a publishable key. Mountaya answers every client still presenting it with a 401 from its next request, so revoke a key that has leaked and create its replacement first if the surface using it cannot go dark. An answer a shared cache already holds for the key is served from there until its lifetime runs out, which no revocation shortens: at most 5 minutes for a public tile, 6 for a published itinerary read or its pace, and 25 hours for the layer catalog, as each of those reads states in its `Cache-Control`.

- Owner or admin only (403 otherwise).
- It cannot be undone. A revoked key stays in `getOrganizationPublishableKeys` carrying `revoked_at`, and is never accepted again.
- The answer is the revoked key, carrying `revoked_at`, with its `ETag`. Revoking a key already revoked changes nothing and answers 200 again with the key as it stands, so a revocation is safe to repeat.
- Revoking the key a session was minted against ends that session too: a session token names the key it was issued for, and a stream opened with it ends with a `reconnect` event whose reason is `credential-revoked`.
- `If-Match` makes the revocation conditional: send the key's `etag`, and a key changed since is refused with `412`, revoking nothing.

Requires a publishable key with the `management` scope AND a session token naming a user, a member with the owner or admin role, whom the request acts as. A session token minted without `user_id` is refused with **401**, and a publishable key without a session token is not accepted here: a key written to be shipped in a browser cannot be sufficient on its own to read or change an organization's account.

**Webhook events** [`organization.publishable_key.revoked`](https://docs.mountaya.com/en/webhooks/events/organization-publishable-key.md#organization-publishable-key-revoked), recorded by the task `organization.publishable_key.revoke`.

**Path parameters**

- `organization_id` (string (uuid), in path, required): Identifier of the organization the operation acts on. A publishable key reaches only its own organization: any other identifier is a 403, whether or not it exists, so the parameter cannot be used to probe which organization ids exist.

- `key_id` (string (uuid), in path, required): Identifier of the publishable key the operation acts on. It is the key's `id`, not the `pk_` value the key itself is.

**Headers**

- `Idempotency-Key` (string, in header, optional): A value the caller chooses once per logical write and sends again, unchanged, on every retry of it, so a write whose answer was lost runs at most once. A UUID is the usual choice; any 1 to 255 printable ASCII characters without a space are accepted. The key is held for 12 hours, for the credential that sent it (the publishable key and the user its session token names) and for this operation.

  The first request runs. A request repeating the key with the same method, path, query and body, sent as the same media type, is answered with the first one's stored status and body, its `Location` and `ETag` included, and carries `Idempotent-Replayed: true`; nothing runs a second time and no limit is charged again. `Content-Type` is compared as the media type it names, with its `charset`, rather than as the header was written, so the letter case of the type and the spacing around its parameters do not make two requests different. `If-Match` is not compared: a key sent again after a `412`, with a fresh tag, is answered with that same `412`, so a write retried with a new tag takes a new key. Every answer below `500` other than a `429` is stored that way, a refusal included, so a retried request that was refused is refused again in the same words. A request refused before the write is reached stores nothing, and a retry with the same key runs again: every `401`, and every `413` refusing a body over the operation's ceiling. The `413` that `postItineraryPreview` answers for the source it has read, a file or a track too large, is stored as any other refusal is.

  A `5xx` answered before anything was written stores nothing and releases the key: a retry with the same key runs again. A `5xx` answered after the write was made keeps the key, and a request repeating it is a `409` whose entry is coded `IDEMPOTENCY_ANSWER_UNAVAILABLE`, as is a request repeating the key of an answer too large to store whole. Either way the write was made: the `409` carries no `Location`, and its `extensions.metadata` (`ResponseMetadataIdempotentAnswer`) names the `status` the first request was answered with and, where that answer carried them, its `location` and `etag`. Read the resource again rather than sending the write once more, which is answered the same way.

  The same key with a different request is a `400` at `["request", "headers", "Idempotency-Key"]`, and nothing runs, whether the first request is still running or was answered. The same request while its first one is still running is a `409` whose entry is coded `IDEMPOTENCY_KEY_IN_USE`, carrying `Retry-After`: send it again once that has passed. Without the header a write runs every time it is sent, which is harmless on the writes `x-idempotent` marks safe to repeat and creates a second resource on the others. A stream's answer is never stored.

  Keys are kept on a best-effort basis. While Mountaya cannot read or record them, a write runs as if it carried no key, so a retry sent in that moment can run it a second time.

- `If-Match` (string, in header, optional): Makes the write conditional on the resource still being the version the caller read: the `ETag` an earlier answer carried, which is also that resource's `etag` field, or `*` for any version. When the resource has changed since, the write is refused with `412` `PRECONDITION_FAILED`, nothing is changed, and the answer carries the current `ETag`, so the caller reads the resource again and decides. Omitted, the write is unconditional and the last write wins.

  One strong tag in double quotes, or `*`. A list of tags, a weak tag (`W/`) or any other spelling is a `400` naming the header. A resource the caller cannot see is answered `404` before the condition is asked, so a stale tag never tells a caller anything a read would not.

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

**Response** `200`

The key, revoked by this request or an earlier one, carrying `revoked_at`; `ETag` carries its `etag`. It stays in `getOrganizationPublishableKeys` as it is here, and is never accepted again.

- `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` (PublishableKey, required): A publishable key: the credential a browser presents. It is safe to ship in a page, which is why what it reaches is narrowed by its scopes and why a `management` scope is never enough on its own.

  See [the PublishableKey object](https://docs.mountaya.com/en/apis/map-studio/reference/api-keys.md#publishable-key-object).

Response headers:

- `ETag`: The version of the resource this answer returns, an opaque strong tag in double quotes, equal to that resource's `etag` field. Send it back as `If-Match` to make a write conditional on nobody having changed the resource since. It changes whenever what this read returns changes; compare it whole and never parse it. Present on every answer that returns the resource, and on the `412` that refuses a stale `If-Match`.
- `Idempotent-Replayed`: `true` when this answer is the stored answer to an earlier request carrying the same `Idempotency-Key`, replayed rather than run again. Absent on an answer that ran.

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

- `400`: The request was malformed, or a field failed validation: each entry names what, a field-level one at its `path`. The same `Idempotency-Key` sent with another request is refused here too, at `["request", "headers", "Idempotency-Key"]`. A refusal the write itself made is stored for its key, so a repeat of the key is refused again in the same words, marked `Idempotent-Replayed: true`.
- `401`: Unauthorized
- `403`: The credential is valid and this operation is not open to it: the key does not carry the `management` scope, or the path names an organization other than the key's own, whether or not it exists, or the user the session token names is not a member of the key's organization, or is a member who is neither owner nor admin. A user outside the organization and a member without the role answer alike. The blanket refusal in the [order of checks](https://docs.mountaya.com/en/apis/conventions/errors.md#which-refusal-you-get-first), an `Origin` or `Referer` the organization does not allow, answers here as well.
- `404`: The organization has no publishable key with the identifier given. A key of another organization answers the same way, so a key id cannot be probed here. A key already revoked is not this: it answers 200.
- `409`: `IdempotencyKeyInUse`, given in full at the end of this page.
- `412`: `PreconditionFailed`, given in full at the end of this page.
- `429`: `TooManyRequests`, given in full at the end of this page.
- `500`: Internal Server Error
- `504`: Gateway Timeout

**cURL**

```bash
curl -s -X DELETE https://api.mountaya.com/v1/organizations/d5a83e17-92c6-4b0f-a7d3-1e6482f9c05b/publishable-keys/3b1f9c02-6d4e-4a87-b5c1-70e2af3d8916 \
  -H "X-API-Key: pk_your_publishable_key" \
  -H "X-Session-Token: sess_your_session_token"
```

**TypeScript**

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

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

const { data } = await admin.keys.deleteOrganizationPublishableKey({
  organization_id: "d5a83e17-92c6-4b0f-a7d3-1e6482f9c05b",
  key_id: "3b1f9c02-6d4e-4a87-b5c1-70e2af3d8916",
});

console.log(data);
```

**Python**

```python
import requests
import uuid

response = requests.delete(
    "https://api.mountaya.com/v1/organizations/d5a83e17-92c6-4b0f-a7d3-1e6482f9c05b/publishable-keys/3b1f9c02-6d4e-4a87-b5c1-70e2af3d8916",
    headers={
        "X-API-Key": "pk_your_publishable_key",
        "X-Session-Token": "sess_your_session_token",
        "Idempotency-Key": str(uuid.uuid4()),
    },
    timeout=30,
)
response.raise_for_status()
print(response.json()["data"])
```

Response 200:

```json
{
  "data": {
    "id": "3b1f9c02-6d4e-4a87-b5c1-70e2af3d8916",
    "organization_id": "d5a83e17-92c6-4b0f-a7d3-1e6482f9c05b",
    "name": "Website embed",
    "key": "pk_9f3c2a71b845d0e4c7a6b3f180d92e5a",
    "created_at": "2026-02-03T11:45:02Z",
    "etag": "\"d3\"",
    "last_used_at": "2026-08-22T18:07:44Z",
    "scopes": [
      "publishing"
    ]
  }
}
```

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

- `TooManyRequests` (`429`): A limit on this operation's requests is spent: the [rate limits](https://docs.mountaya.com/en/apis/conventions/rate-limits.md) page lists every one, the unknown publishable keys one address may present among them, and the operation's description names any of its own. The request was counted and nothing was done. `Retry-After` says how long until the limit lifts; wait that long, with a little jitter of your own, and send the request again. Where the operation takes an `Idempotency-Key`, a write sent again with the same key runs once.
- `IdempotencyKeyInUse` (`409`): The `Idempotency-Key` this request carries is one an earlier request was sent with, and the answer to that one cannot be given here. Nothing was done by this request. Its entry says which. `IDEMPOTENCY_KEY_IN_USE`: the first request is still running. Wait the `Retry-After` this carries and send the same request again, which is then answered with the first request's outcome. `IDEMPOTENCY_ANSWER_UNAVAILABLE`: the first request's write was made, and its answer cannot be given again, because it was too large to keep whole, because the request failed with a `5xx` after the write was made, or because it carried a credential shown only once, which is never kept. `extensions.metadata` names the status it was answered with, and its `Location` and `ETag` where it carried them; a create whose operation says so names what it made there after a `5xx` too. Read the resource again rather than sending the write once more, which is answered the same way. A credential cannot be read again: where the operation says its answer carries one, the one it created is at `metadata.location`, so revoke that one and create another.
- `PreconditionFailed` (`412`): `If-Match` named a version the resource has moved on from: somebody changed it after the caller read it. Nothing was changed. The one entry is coded `PRECONDITION_FAILED`, and `ETag` carries the current version, so read the resource again, decide whether the change still applies, and send it with the new tag. Retrying with the same tag is refused the same way. A resource the caller cannot see is answered `404` before the condition is asked, and a write refused for any other reason is refused for that reason first.
