# Errors

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

Read the error envelope every Mountaya API returns, branch on its code, and know which failures to retry.

Every Mountaya API reports a failure the same way: an `errors` array whose entries carry a `message` for people and an `extensions.code` for your code. Branch on the code, never on the message.

**Response**

```json
{
  "errors": [
    {
      "message": "Activity is not recognized",
      "path": ["request", "body", "activity_id"],
      "extensions": { "code": "VALIDATION_FAILED" }
    }
  ]
}
```

| Field | What it holds |
| --- | --- |
| `message` | A sentence for a person, translated by `Accept-Language`. Never parse it. |
| `path` | The field the entry is about, when there is one. |
| `extensions.code` | One of the codes below. Always present. |

Every answer, a refusal included, carries an `X-Request-Id`. Log it beside the error and quote it when you [contact support](https://docs.mountaya.com/en/apis/conventions/headers.md#request-ids).

- One entry per failed validation: a body with three rejected fields answers three entries. A `400` for a request that does not match its operation is bounded in size: past the bound it lists the first entries, in order, and a last entry with no `path` says how many problems it leaves out. Never parse that entry's wording or rely on the bound's figures.
- A refusal that names what it met carries it at the top-level `extensions.metadata`, beside `errors`: the resource a `409` conflicts with, or the ceiling a `LIMIT_REACHED` refusal met.
- `message` is written for a person, localized by `Accept-Language`, and never a contract. A message raised by request validation (an undeclared field, a malformed value) is in English whatever `Accept-Language` asks for.
- The Map Studio API and the Tile API put the field path on the entry's own `path`, prefixed by where it sits: `["request", "body", …]`, `["request", "params", …]`, `["request", "query", …]`, or `["request", "headers", …]` for a header such as `Idempotency-Key`. A field a body object does not declare is refused at its own path, since request bodies are closed.
- The Data API's `path` is the GraphQL response path (which field of the query failed); the input field path is mirrored onto `extensions.path`, prefixed with `["input", …]`.

## Error codes

| Code | Status | What to do |
| --- | --- | --- |
| `BAD_REQUEST` | 400 | Fix the request: unreadable body, wrong content type, bad parameter. |
| `VALIDATION_FAILED` | 400 | Fix the one field named in `path`. |
| `UNAUTHORIZED` | 401 | Send a valid credential. See [authentication](https://docs.mountaya.com/en/authentication.md). |
| `PAYMENT_REQUIRED` | 402 | Get the product. A retry does not help. See [payment errors](https://docs.mountaya.com/en/apis/conventions/errors.md#payment-errors). |
| `FORBIDDEN` | 403 | Stop. The credential is valid but not permitted. |
| `LIMIT_REACHED` | 429 | A ceiling is full. Free a place or change the agreement. See [ceilings](https://docs.mountaya.com/en/apis/conventions/errors.md#ceilings). |
| `NOT_FOUND` | 404 | No resource with that id is visible to this credential. |
| `METHOD_NOT_ALLOWED` | 405 | Use a method the `Allow` header names. |
| `CONFLICT` | 409 | Read `extensions.metadata` and resolve it. See [conflicts](https://docs.mountaya.com/en/apis/conventions/errors.md#conflicts). |
| `AI_PROVIDER_NOT_CONFIGURED` | 409 | Configure the organization's AI provider, then start the run again. |
| `IDEMPOTENCY_KEY_IN_USE` | 409 | The first request with this key still runs. Wait `Retry-After`, then resend. |
| `IDEMPOTENCY_ANSWER_UNAVAILABLE` | 409 | The write was made, but its answer is gone. Read the resource; do not resend. |
| `REDELIVERY_IN_PROGRESS` | 409 | Wait for the redelivery already running to this endpoint. |
| `SECRET_ROTATION_IN_OVERLAP` | 409 | Wait for the overlap to end, or rotate with none. |
| `PRECONDITION_FAILED` | 412 | The resource changed since you read it. See [conditional writes](https://docs.mountaya.com/en/apis/conventions/conditional-writes.md). |
| `PAYLOAD_TOO_LARGE` | 413 | Send a smaller body. As a Data API entry under `200`, at `["input"]`, it is an itinerary of more than 500,000 positions, which [`itinerary` and `exportItinerary`](https://docs.mountaya.com/en/apis/data/itineraries.md) refuse whatever the body. |
| `TOO_MANY_REQUESTS` | 429 | Wait `Retry-After`, then retry. See [rate limits](https://docs.mountaya.com/en/apis/conventions/rate-limits.md). |
| `INTERNAL_ERROR` | 500 | Retry once, then report it with the request id. |
| `NOT_IMPLEMENTED` | 501 | Declared, not yet served. |
| `BAD_GATEWAY` | 502 | Declared, not sent by any API. |
| `SERVICE_UNAVAILABLE` | 503 | Wait `Retry-After`, or back off, then retry. |
| `GATEWAY_TIMEOUT` | 504 | Retry once, then ask for less. See [timeouts](https://docs.mountaya.com/en/apis/conventions/headers.md#timeouts). |

- Fifteen codes name an HTTP status. Seven ride on one: `VALIDATION_FAILED` replaces `BAD_REQUEST` on the per-field entries of a 400, `AI_PROVIDER_NOT_CONFIGURED` replaces `CONFLICT` on the 409 of an agent run started, or an AI provider configuration changed, while the organization has none configured, `IDEMPOTENCY_KEY_IN_USE` replaces `CONFLICT` on the 409 of a write whose `Idempotency-Key` is still running, `IDEMPOTENCY_ANSWER_UNAVAILABLE` replaces it on the 409 of a write whose `Idempotency-Key` names a write that was made and whose answer cannot be given again, `REDELIVERY_IN_PROGRESS` replaces it on the 409 of a webhook redelivery asked while another to the same endpoint still runs, `SECRET_ROTATION_IN_OVERLAP` replaces it on the 409 of a webhook signing secret rotated with an overlap while the secret an earlier rotation replaced still signs, and `LIMIT_REACHED` replaces `TOO_MANY_REQUESTS` on the 429 of a ceiling, which carries no `Retry-After`. So six codes arrive on a `409`, `CONFLICT` and five that refine it, and two on a `429`.
- `UNAUTHORIZED` (401): the credential is missing, expired, or foreign to this organization, or the operation acts as a member and the session token is minted without `user_id`.
- `FORBIDDEN` (403): a missing scope, a page outside the [allowed domains](https://docs.mountaya.com/en/authentication.md#allowed-domains), another organization, or a member without the role. A `403` never refuses a ceiling.
- `LIMIT_REACHED` (429): the seats, the published itineraries, the published zones, the webhook endpoints or the allowed domains the agreement allows, the invitations waiting at once, or the three itineraries of a personal space. It carries no `Retry-After` and is never retried. See [ceilings](https://docs.mountaya.com/en/apis/conventions/errors.md#ceilings).
- `NOT_FOUND` (404): one you may not view reads the same as one that never existed.
- `METHOD_NOT_ALLOWED` (405): the path exists, the verb does not.
- `AI_PROVIDER_NOT_CONFIGURED` (409): configure it with `POST /v1/organizations/{organization_id}/ai-provider-config`, then start the run again. Changing a configuration that is not set answers it too: create one instead.
- `IDEMPOTENCY_ANSWER_UNAVAILABLE` (409): the first request with this key made its write, and its answer cannot be given again: it was too large to keep, or a `5xx` answered after the write was made. Read `extensions.metadata` for the `status` it was answered with and its `location`, then read the resource again. Do not send the write again.
- `REDELIVERY_IN_PROGRESS` (409): `POST /v1/organizations/{organization_id}/webhook-deliveries` was asked a redelivery (`since`) while another to the same endpoint still runs. One runs at a time for an endpoint, nothing was started, and `extensions.metadata` is the trigger of the one running (`id`, `since`, `created_at`). Ask again once it is over: see [redeliver](https://docs.mountaya.com/en/webhooks/recovery.md#redeliver).
- `SECRET_ROTATION_IN_OVERLAP` (409): a webhook endpoint's signing secret was rotated with an overlap, in the Mountaya app, while the secret an earlier rotation replaced still signs. `extensions.metadata` names when that overlap ends; a rotation with no overlap is taken at any time. No operation of the public API rotates a secret, so a client calling with a key never receives it: see [rotation](https://docs.mountaya.com/en/webhooks/signatures.md#rotation).
- `BAD_GATEWAY` (502) is in every API's vocabulary and no operation answers it: a failure of a service Mountaya relies on is `INTERNAL_ERROR`.
- `SERVICE_UNAVAILABLE` (503): of the three APIs, only the Map Studio API answers it, and only on the operations that declare it (the MCP server answers one too, with `Retry-After`, when it cannot check a connector's token for a moment): the seven billing changes that run one at a time for an organization (opening billing, saving, choosing and detaching a card, the billing details, and running and ending the Data API subscription) while another still runs, an agent run's rating while its run cannot be checked, and the four event streams, `GET /v1/agent/runs/{run_id}/events`, `GET /v1/itineraries/{itinerary_id}/events`, `GET /v1/zones/{zone_id}/events` and `GET /v1/organizations/{organization_id}/events`, while their events, or what the caller's access is checked against, cannot be reached for a moment. A stream's `503` carries `Retry-After: 1` and comes before any stream header: open it again from the last event received, and nothing is missed. The TypeScript SDK's collaboration and agent sessions reopen it themselves.
- Every 5xx is opaque: one entry, a generic message, no field path, no metadata.
- Every `401` carries the same message, whatever the credential lacked, and a `WWW-Authenticate` header naming the credential to send: `ApiKey realm="mountaya"`, or `ShareToken realm="mountaya"` for a request made with a share token, or `Bearer realm="mountaya"` for one that carries neither but sends an `Authorization: Bearer` header. Neither says why the credential was refused, so read the request, not the answer.
- Each API sends its own closed set. A Data API entry's `extensions.code` is always a member of the schema's `ErrorCode` enum. `AI_PROVIDER_NOT_CONFIGURED`, `IDEMPOTENCY_KEY_IN_USE`, `IDEMPOTENCY_ANSWER_UNAVAILABLE`, `REDELIVERY_IN_PROGRESS`, `SECRET_ROTATION_IN_OVERLAP`, `PRECONDITION_FAILED`, and `LIMIT_REACHED` never reach it: it starts no agent run, takes no write, manages no webhook endpoint, and reaches none of those ceilings. It does send `GATEWAY_TIMEOUT`, for a request still running when its 30-second budget runs out, and never `CONFLICT`, `BAD_GATEWAY` or `SERVICE_UNAVAILABLE`. The only codes outside `ErrorCode` are the GraphQL protocol's own, answered before any field runs: `GRAPHQL_PARSE_FAILED`, `GRAPHQL_VALIDATION_FAILED`, `PERSISTED_QUERY_NOT_FOUND`, `DEPTH_LIMIT_EXCEEDED`, and `COMPLEXITY_LIMIT_EXCEEDED`.
- The Tile API only reads, so it never sends `CONFLICT`, `IDEMPOTENCY_KEY_IN_USE`, `IDEMPOTENCY_ANSWER_UNAVAILABLE`, `REDELIVERY_IN_PROGRESS`, `SECRET_ROTATION_IN_OVERLAP`, `PRECONDITION_FAILED`, `LIMIT_REACHED`, or `PAYLOAD_TOO_LARGE`. A tile that cannot read what it draws, an overlay's upstream provider included, answers `INTERNAL_ERROR`, so it never sends `BAD_GATEWAY` either.

## Data API errors arrive under 200

A Data API query that runs answers `200 OK`, even when a field fails. Check `errors` on every response: a partial result carries both `data` and `errors`. The input field at fault is in `extensions.path`.

**Response**

```json
{
  "errors": [
    {
      "message": "Must have at least 2 waypoints",
      "path": ["directions"],
      "locations": [{ "line": 1, "column": 46 }],
      "extensions": {
        "code": "VALIDATION_FAILED",
        "path": ["input", "waypoints"]
      }
    }
  ],
  "data": null
}
```

- A query that reaches the resolvers answers `200 OK` whatever happens next, unless it runs out of time. Inspect `errors` on every response.
- Two failures answer 4xx instead, rejected before any resolver runs: a malformed query, and a credential or quota failure. One answers 5xx: a request still running when its 30-second budget runs out is a `504` coded `GATEWAY_TIMEOUT`, with no data, whatever had resolved, and its root fields count toward no allowance and no invoice.
- Only `directions` relays the routing engine: a request within the 100 km bound on the waypoints' line that the engine still measures past it is `VALIDATION_FAILED` at `["input"]`, and its `message` is the engine's own, in English whatever `Accept-Language` asks for. Any other failure of the routing engine (`matrix`, `isochrones`, the rest of `directions`) or of the geocoder (`geocode`, `reverseGeocode`, `pois`), a refusal included, is `INTERNAL_ERROR`: never the caller's to fix, so retry it with backoff rather than change the request.
- A unified `search` reports a failed target inside its own result, while the others still return. When every target it enabled fails, the field fails as a whole instead: no result and one error, `VALIDATION_FAILED` where every target refused the input and `INTERNAL_ERROR` otherwise, counted toward no allowance and no invoice. See [search](https://docs.mountaya.com/en/apis/data/places.md#search).

## Retry or fix

Retry only what time can fix: a `429` not coded `LIMIT_REACHED`, a `409` coded `IDEMPOTENCY_KEY_IN_USE`, and a `5xx`. Wait `Retry-After` when the answer carries it, and back off with jitter otherwise. Every other `4xx` describes your request, so the same request fails the same way.

Retry a write with the same [`Idempotency-Key`](https://docs.mountaya.com/en/apis/conventions/idempotency.md), so it never runs twice. The [TypeScript client](https://docs.mountaya.com/en/sdks/typescript/errors.md) retries `429`, `502`, `503` and `504` for you, but never a `500`: retry that once yourself.

- Retry `500` once, a `503` after its `Retry-After` or with backoff where it names none, and `504` once; repeated timeouts mean ask for less (fewer waypoints, a smaller bounding box, a narrower page). No operation answers a `502`, so one comes from a proxy on the way: retry it with backoff.
- The TypeScript client retries a `429` (never one coded `LIMIT_REACHED`) while its waits fit `retry.maxWaitMs`, 60 seconds by default, so a spent monthly allowance arrives at once as `MountayaRateLimitError` carrying `retryAfter`. It retries a `502`, a `503`, a `504` and a request that never arrived when the operation is idempotent (every Data API query) or the request carried an `Idempotency-Key` (every write it sends), up to `retry.maxRetries`, 2 by default. It repeats a `409` coded `IDEMPOTENCY_KEY_IN_USE` with the same key. It never retries a `500` or a `412`: a `500` surfaces as `MountayaServerError`, to retry once yourself.
- A credential that could not be checked at all is an opaque `500`, or `504` on the Map Studio and Tile APIs once the time budget has run out, never a `401` or a `402`. Retry it.
- Never retry a `412`: read the resource again and decide whether the change still applies.

## Ceilings

A `429` coded `LIMIT_REACHED` means a ceiling is full, such as your seats or your published itineraries. It carries no `Retry-After`, because waiting does not lift it. Free a place, such as unpublishing an itinerary, or change the agreement, then send the request again.

**Response**

```json
{
  "errors": [{ "message": "The organization has no seat left", "extensions": { "code": "LIMIT_REACHED" } }],
  "extensions": { "metadata": { "limit": "seats", "allowed": 10, "used": 10 } }
}
```

- Every ceiling is refused with `429` and no `Retry-After`. The refusal names the ceiling at the top-level `extensions.metadata`, with the figures it was read against: `limit`, `allowed` and `used`.

| `limit` | Status | What is full |
| --- | --- | --- |
| `seats` | 429 | The members your agreement allows, counting the invitations still waiting for an answer. Unlimited unless the agreement names a number. |
| `published-itineraries` | 429 | The itineraries your agreement lets you have published at once, none until it names a number. Only a first publish is refused. |
| `published-zones` | 429 | The zones your agreement lets you have published at once, none until it names a number. Only a first publish is refused. |
| `webhook-endpoints` | 429 | The webhook endpoints your agreement lets you hold, enabled and disabled: 2 unless it says otherwise, 6 at most. |
| `allowed-domains` | 429 | The [allowed domains](https://docs.mountaya.com/en/authentication.md#allowed-domains) your agreement lets you list: 1 unless it says otherwise, or no limit. A `localhost` entry is not counted. Only a settings write adding a counted entry is refused. |
| `pending-invitations` | 429 | The 500 invitations an organization may have waiting at once. |
| `personal-itineraries` | 429 | The three itineraries a personal space keeps. |

- Each is a count of something held, never a rate, although it shares the rate limits' `429`: tell the two apart by the entry's code, never by the missing `Retry-After`. It clears by freeing a place, such as unpublishing an itinerary or a zone or withdrawing an invitation, or by changing the agreement; no wait lifts it, so never retry it as it stands.
- A ceiling's refusal is not kept against its `Idempotency-Key`, as no `429` is: the same request sent again with its key runs once a place is free.

## Payment required

A `402` means your organization does not hold the product the request needs. [Products and access](https://docs.mountaya.com/en/concepts.md#products) says how to get each one.

- `PAYMENT_REQUIRED` means the organization does not hold the product. Products: Map Studio, Map Publishing, Embedded Studio, the Tile API and White label come with an agreement; the Data API and the MCP server with a card.
- A `402` is one kind of error whatever its entries say, and the [TypeScript client](https://docs.mountaya.com/en/sdks/typescript/errors.md) raises every one as `MountayaBillingError`. Its entry is coded `PAYMENT_REQUIRED`, and the message names the fact: a product not held, or billing. A ceiling is never a `402`.
- The Data API is the one API that asks for a card. A self-serve organization whose payment method is gone is refused there with `PAYMENT_REQUIRED` too, and the message says so; the call succeeds once a card is added. An organization whose products its agreement grants is never asked for one, and neither the Tile API nor the Map Studio API asks at all.
- A renewal payment that fails is retried for up to about seven days, and the Data API stays on meanwhile. Past that the subscription ends, and the Data API answers `PAYMENT_REQUIRED` until the organization opens it again. A subscription that has never paid an invoice gets no such window: the Data API answers `PAYMENT_REQUIRED` from its first failed payment, and comes back if a retry of it succeeds.
- Opening the Data API again, by saving a card or by running the subscription from the billing settings, first charges every invoice the organization still owes, those of an ended subscription included, to that card or to its default payment method. An invoice still unpaid refuses the opening with `PAYMENT_REQUIRED`, whose message says invoices are outstanding: nothing opens, and a card being saved is kept without becoming the default. A card that failed to pay an invoice another organization still owes is refused the same way; a card only saved there is not.

## Conflicts

A `409 Conflict` names what the write collided with at `extensions.metadata`: a name already taken, an address already invited, or a part of an itinerary another member is editing. Only the Map Studio API sends one.

### A collaborator holds the lock

Editing an itinerary or a zone locks the part being changed. A write to a part someone else holds is refused with `409`, and `extensions.metadata.holder.id` names that member. Wait for them to finish, or pick another part.

- A name already taken: creating, importing, duplicating, and renaming an itinerary, and creating and renaming a zone or a collection, can collide on a name. The metadata key follows the resource: an itinerary reports `{ "itinerary": { "id": … } }`, a zone `{ "zone": { "id": … } }`, and a collection `{ "collection": { "id": … } }`. One branch reads all three.
- An address already in the organization: inviting an address that already belongs to a member, or that has an invitation waiting, is a `409` naming which: `{ "member": { "user_id": … } }` or `{ "invitation": { "id": … } }`.
- The lock: every write to a segment, a segment group, or a waypoint declares it, and so do publishing, updating a zone, and the collaboration signals. One shape covers them all:

```json
{
  "errors": [{ "message": "This segment is being edited by another member", "extensions": { "code": "CONFLICT" } }],
  "extensions": { "metadata": { "holder": { "id": "7f3c1d92-4a08-4b6e-9c15-2d84e0b7a361" } } }
}
```

- A `holder.id` of `00000000-0000-0000-0000-000000000000`, on a collaboration signal, means nobody holds it: the signal needed a lock you had not taken. Take the lock rather than wait. Publishing needs every lock on the itinerary or the zone released, so there the holder can be you.
- A body the write refuses is a `400` before any lock is looked at, so a malformed edit is told what is wrong with it even while a collaborator holds the part.
- A state that forbids the act: a `409` that names no resource carries no metadata. Rotating a share link that does not exist is one. The shape of an itinerary's chain is another, where each was a `400` before contract v0.7.0: merging the last segment of a chain, or two segments of different modes or of different segment groups; deleting a segment inside the chain, rather than at one of its ends; grouping a segment that already belongs to another group, which the entry names by its position in `segment_ids`.
- An act on a state that is already so is never a conflict: unpublishing what is not published, removing a share link that is not there, or revoking a revoked key answers `200` and changes nothing.
- The Data API and the Tile API change no state, so neither ever answers `409`.

## Which check fails first

A request that is wrong in several ways is answered for the first check it fails, and that one alone. Fix what the answer names and send it again. The credential is checked before the body, so a bad key is a `401` however malformed the body is.

A request is answered for the first check it fails. Each API runs its checks in this fixed order.

**Map Studio API**, under a publishable key, with a session token or without one:

1. `413 PAYLOAD_TOO_LARGE`: the body is over its operation's ceiling. Send a smaller body.
2. The URL: a path not in its canonical form answers `308` to it for `GET` and `HEAD` and `404 NOT_FOUND` for any other method, an unpublished path `404 NOT_FOUND`, and a method the path does not take `405 METHOD_NOT_ALLOWED`, whose `Allow` names the ones it does. Fix the URL or the method.
3. The key: `429 TOO_MANY_REQUESTS`, with `Retry-After`, for a key not resolved moments earlier when the client's IP address has had too many unknown publishable keys refused within the minute; then `401 UNAUTHORIZED` for no key, an unknown or revoked one, or a secret key. Send your publishable key in `X-API-Key`.
4. `401 UNAUTHORIZED`: the key's organization has been cancelled. Nothing about the request clears it.
5. `403 FORBIDDEN`: the `Origin`, or failing that the `Referer`, names a page outside your [allowed domains](https://docs.mountaya.com/en/authentication.md#allowed-domains). Add the page's host, or call from your backend, which sends neither header.
6. `401 UNAUTHORIZED`: the session token is unknown, expired, or minted for another key; missing where the operation, or your `require_session_token` rule, needs one; minted for any surface but `studio-embedded` on a `studio-embedded` operation; minted without `user_id` on an operation whose `x-acting-user` is `required`; or minted for `studio-embedded` without `user_id` on a `management` operation, which is answered as a key alone is. Mint a fresh one, with `user_id` for such an operation and `surface: "studio-embedded"` for a `studio-embedded` one.
7. `400`: the parameters, headers, and body the operation declares, checked together, one `VALIDATION_FAILED` entry per refused value. A field the body does not declare is refused here. Fix what `path` names.
8. `403 FORBIDDEN`: `organization_id` in the path names an organization other than the key's own. Name the key's organization.
9. `402 PAYMENT_REQUIRED`: the organization does not hold the product the operation's scope belongs to. It clears when the agreement changes, not when the request does.
10. `403 FORBIDDEN`: the key carries neither the scope the operation declares nor one that includes it. Give the key that scope, or send the request under a key that carries it, since a key carrying `management` carries no other.
11. `403 FORBIDDEN`: the user the session token names is not a member, or holds a role the operation does not admit. Mint the token for a member who holds the role.
12. The `Idempotency-Key`: the same key with another request is a `400` at the header, whether or not the first one still runs; a stored answer is replayed; the same request still running is a `409 IDEMPOTENCY_KEY_IN_USE`; and a write that was made and whose answer cannot be given again is a `409 IDEMPOTENCY_ANSWER_UNAVAILABLE`. None of these counts toward a limit. Then the limits: `429 TOO_MANY_REQUESTS`, with `Retry-After`.
13. The operation's own checks, which its reference states, in this order: a resource the credential cannot view (`404`), a role that does not admit the act (`403`), a value the operation itself refuses (`400`), a conflict (`409`), a ceiling (`429` coded `LIMIT_REACHED`, with no `Retry-After`), and last a stale `If-Match` (`412`), answered only for a write that would otherwise go through. One limit sits among these checks rather than in step 12: the 200 invitations a day an organization sends are counted, and refused with `429`, after the invitation's `400` and its role `403`s and before its `409` and its ceilings, so only an owner or admin ever spends them.

Under a share token, steps 1 and 2 are the same. Then the token (`429` with `Retry-After` for a token not resolved moments earlier when the client's IP address has had 60 unknown share tokens refused within the minute, then `401` for a malformed, unknown, rotated, or disabled one), the calling page (`403` for any page outside Mountaya's own domain), the parameters (`400`), the limits (`429` with `Retry-After`, per client IP address and then per organization that owns the link), and the operation's own checks (`404` outside the token's grant).

**Tile API**, under a publishable key, with a session token or without one:

1. The method and the path, before the credential is read: `405 METHOD_NOT_ALLOWED` for any method but `GET`, `HEAD`, and a CORS preflight, with `Allow`; a path not in its canonical form answers `308` to it. Send a `GET` to the canonical path.
2. The key: `429 TOO_MANY_REQUESTS`, with `Retry-After`, for a key not resolved moments earlier when the client's IP address has had too many unknown publishable keys refused within the minute; then `401 UNAUTHORIZED` for no credential, or a key that is unknown, revoked, or not a publishable key.
3. `401 UNAUTHORIZED`: the key's organization has been cancelled.
4. `403 FORBIDDEN`: the calling page is outside your allowed domains.
5. `401 UNAUTHORIZED`: the session token is unknown, expired, or minted for another key, or missing while `require_session_token` is on.
6. `402 PAYMENT_REQUIRED`: the organization does not hold the Tile API, or Map Publishing for a request from a page on Mountaya's own domain.
7. `403 FORBIDDEN`: the key does not carry `tiles`, or, for a request from a page on Mountaya's own domain, `publishing` or `studio-embedded`.
8. `429 TOO_MANY_REQUESTS`, each with `Retry-After`. For your own clients and the hosted embed, a spent monthly allowance first, then, for a key sent without a session token or with one minted without `user_id`, the bound on its client IP address, then the per-minute limit; for a token minted for `studio-embedded`, its member's bound, or the bound on its client IP address for a token minted without `user_id`, then its organization's. Every answer from this step on carries the rate-limit fields, and none before it does.
9. The URL: an unpublished path `404 NOT_FOUND`.
10. `400`: a malformed or out-of-range parameter.
11. The route's own checks: the zoom bounds and the geographic boundaries (`400`), the overlay allowlist, the overlay time control and `organization_id` (`403`), and a resource the credential cannot view (`404`).

Under a share token, step 1 is the same. Then `429` with `Retry-After`, the seconds left in the minute, for a token not resolved moments earlier when the client's IP address has had 60 unknown share tokens refused within the minute; then the token (`401`); the calling page (`403` outside Mountaya's own domain); the limits (`429` with `Retry-After` for the bound on the client's IP address, then for the bound every link of the link's organization shares, since a share link counts toward no per-minute limit and no monthly allowance); and steps 9 to 11, without the zoom bounds and the boundaries. An aggregate tile answers empty.

**Data API:**

1. `405 METHOD_NOT_ALLOWED`: any method but `POST`, before the credential is read. `Allow` names `POST`.
2. The key: `429 TOO_MANY_REQUESTS`, with `Retry-After`, for a key not resolved moments earlier when the client's IP address has had too many unknown publishable keys refused within the minute; then `401 UNAUTHORIZED` for no publishable key, a secret key in its place, or a key that is unknown or revoked.
3. `401 UNAUTHORIZED`: the key's organization has been cancelled.
4. `403 FORBIDDEN`: the calling page is outside your allowed domains.
5. `401 UNAUTHORIZED`: the session token is malformed, expired, or minted for another key, or there is none.
6. `402 PAYMENT_REQUIRED`: the organization does not hold the Data API.
7. `403 FORBIDDEN`: the key does not carry `data`, or `mcp` on a request through the MCP server.
8. `402 PAYMENT_REQUIRED`: the organization is billed by card and has no payment method on file.
9. `429 TOO_MANY_REQUESTS`, each with `Retry-After`. For your own clients, a spent monthly allowance first, then the per-minute limit; for a token minted for `studio-embedded`, its member's bound, or the bound on its client IP address for a token minted without `user_id`, then its organization's.
10. `413 PAYLOAD_TOO_LARGE`: a body over 32 MiB.
11. `400 BAD_REQUEST`: a body that is not one JSON object sent as `application/json`, a field named twice and text that is not valid UTF-8 included.
12. The GraphQL protocol: the persisted query, then the document, then the depth limit, then the complexity ceiling.
13. The fields: `VALIDATION_FAILED`, `NOT_FOUND`, and the rest, under `200 OK` beside whatever data resolved.

A request made with a token minted for `studio-embedded`, an Embedded Studio's, takes every step above, the `data` scope and the Data API product included. The token's surface decides only how the request is recorded and which bounds hold it at step 9: see [rate limits](https://docs.mountaya.com/en/apis/conventions/rate-limits.md).

Five consequences explain most surprising answers:

- The credential comes before the body. A request whose credential is refused is a `401` however malformed its body, and the body is never read.
- The calling page comes before the session token. A page outside your allowed domains is a `403` even when its session token is missing too.
- The session token comes before the product and the scope. A key lacking both a session token and a scope is a `401`, not a `403`.
- The product comes before the scope. A key lacking the scope, in an organization lacking the product, is a `402`, not a `403`.
- A credential that could not be checked at all is an opaque `500`, or `504` on the Map Studio and Tile APIs once the time budget has run out, never a `401` or a `402`. Retry it.

## Next steps

- [Rate limits](https://docs.mountaya.com/en/apis/conventions/rate-limits.md): What a `429` means and how long to wait.
- [Idempotency](https://docs.mountaya.com/en/apis/conventions/idempotency.md): Retry a write without making it twice.
