# Agent

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

Conversational route building.

 Start a run, stream its events, send it further input, and record whether its answer was useful. The agent drives the same operations a person would; it has no privileged surface of its own.

## Start a new agent run

### POST /v1/agent/runs

- Operation: `postAgentRun`
- Requires: scope `studio-embedded` · 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

Starts a new agent run for the user the session token names. The run is created and then continues on its own: this call returns as soon as it has an identifier, live output arrives over the run's event stream (`getAgentRunEvents`), and follow-up input is sent to the running conversation (`postAgentRunInput`).

The run is scoped to `organization_id`, the organization that owns the opened resource, which must be the key's organization: any other is a **403**, whether or not it exists. The server enforces the gate, and any client-side check is presentation only: the user the session token names must hold a write role (owner, admin or contributor) in that organization, so a viewer is refused with **403**. The organization must also have an AI provider credential configured, else **409** with the machine code `AI_PROVIDER_NOT_CONFIGURED` (distinct from the 403 authorization failure).

The response is 202 Accepted carrying the run at `data`. Its `id` is a plain UUID and is what the input, events and feedback operations take as their `run_id` path parameter.

A start is made at most once per `Idempotency-Key`: a retried start with the same key resolves to the same run, answered with the first one's 202, and begins no second conversation and no second budget. Without the header every request starts a run of its own, so send one on every start.

Under a publishable key a run calls no server tool: what a server tool reads and computes is the Data API's, which the key's own `data` scope answers for. A non-empty `server_tools` is therefore a **400** naming it, and nothing is started.

Starts are limited to 10 a minute for each user and 100 a minute for each organization, and the bodies of starts and inputs together to 8 MiB a minute for each user and 80 MiB a minute for each organization, a request counting the bytes of its body. Past any of them, the answer is a **429** with `Retry-After`, and no run is started.

Every run is bounded: at most 24 provider turns, and $5.00 of spend on the organization's AI provider, as estimated after each turn. The spend is checked before a turn starts, so the run stops before a turn once its estimated spend has reached $5.00, and the turn that reached it can take it past that figure. Reaching either ceiling ends the run with the `budget-exhausted` reason.

Requires a publishable key with the `studio-embedded` scope AND a session token minted for `studio-embedded` naming a user, a member with a write role, whom the request acts as. A publishable key without a session token minted for `studio-embedded` naming a user, a token minted for another surface included, is refused with **401**.

Records no webhook event. Runs the task `agent.run.start`.

**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**

The resource the run is opened on, the model profile to drive it, and the client-side tool manifest the model may call. The studio snapshot, if sent, seeds the transcript with the current state of the studio the run is opened from.

- `message` (string, in body, required): The user's first message that opens the conversation. It is trimmed before it is validated, so a message of only whitespace is rejected: it would otherwise start a run and spend a provider turn on nothing. The upper bound exists because this message is kept for the run's whole life and replayed on every continuation.

- `organization_id` (string (uuid), in body, required): The organization the run belongs to, which owns the resource the co-pilot is opened on. It must be the key's organization. The user the session token names must hold a write role in it, and its AI provider configuration is what drives the model.

- `profile` (string, in body, optional, default: `studio`, one of: `studio`, `video-director`): Which prompt profile to seed the run with. The agent serves several surfaces and each has to be told which tools it actually holds, so this is chosen at creation and fixed for the life of the run. Omitted, it is `studio`.

- `client_tools` (array of AgentClientToolManifest, in body, optional): The browser's contextual client-tool schemas for this run. Merged with the server tools into the schema list handed to the model; a client tool may not shadow a server tool.

  The bound sits above the whole agent-visible client registry, so no routed set a caller can legitimately build is refused. It exists because the manifest is kept for the run's whole life and replayed on every continuation: an unbounded array here grows without limit for as long as the run lasts. Over the bound is a validation error, never a truncation.
  - `name` (string, required): Stable namespaced name of the client tool, for example `studio.collection.addItinerary`: dot-separated segments of letters, digits and hyphens, at most 64 characters, and unique within the manifest. It is not a display name: it is an identifier the model calls and the browser dispatches on, so the 2 to 30 characters that bound every name a person reads do not apply to it. A name outside this form, or one appearing twice, is a 400.
  - `description` (string, required): Natural-language description of the tool, fed to the model's tool selection. Read by a model rather than shown to a person, so the 100-character ceiling that bounds every description a person reads does not apply to it; it holds at most 2000 characters.
  - `parameters` (object, required): JSON Schema object describing the tool's arguments. It is forwarded to the model as sent, except where the organization's AI provider accepts only a plain object schema: there a top-level `anyOf`, `oneOf` or `allOf` is flattened into one object, `"type": "object"` is added where it is missing, and a value that is not an object becomes an empty object schema. The browser still validates every call against its own schema. At most 32 top-level fields and 16 KiB as sent.
  - `read_only` (boolean, optional): Whether calling the tool only reads state and changes nothing. The run uses this to compact its transcript: a superseded read is dropped, while anything that may have changed the world is retained verbatim. Omitted when unknown, which the run treats as "may mutate" and never drops.
  - `confirms` (boolean, optional): Whether running the tool interrupts the user with a confirmation prompt before it takes effect. It is restated in the tool description the model is given, so the model can sequence an interrupting tool last rather than stalling a multi-step sequence midway. Omitted when false.

- `server_tools` (array of string, in body, optional): Names of the server tools the routed surfaces permit for this run. Omitted, the model sees every server tool; present, the schema list handed to the model carries only the named ones. Names that are not server tools are ignored, so the caller may pass its whole routed tool set. Advisory over what the model can SEE, exactly like the client manifest; execution authorization is unchanged.

  It carries the routed name set verbatim rather than the server tools alone, each name in the client tool name's form, at most 64 characters.

  Under a publishable key a run calls no server tool: what a server tool reads and computes is the Data API's, which the key's own `data` scope answers for. A non-empty list is then a `400` naming `server_tools`.

- `context` (object, in body, optional): The caller's point-in-time studio snapshot, captured once by the browser at run start (active itinerary, current selection, enabled overlays, viewport, unit/locale preferences, and the available-overlay catalog). Its inner shape is not typed here (the client that builds it owns that), and it is passed through as sent with one exception: the overlay list at `catalog.overlays` is dropped, since the model can list overlays itself. It is surfaced to the model as a read-only system message seeding the transcript, so the run starts knowing the current UI state. It is never re-read mid-run. At most 32 top-level fields and 32 KiB as sent; over either is a `400` naming `context`.

**Response** `202`

Accepted: the run is started and continues on its own. `data` is the run, whose `id` the input, events and feedback operations take as their `run_id`. A retried start with the same `Idempotency-Key` is answered this same run.

- `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` (AgentRun, required): An agent run that `postAgentRun` started. The run itself happens after the answer: its events are read from `getAgentRunEvents`, which opens on the run's `id`.
  - `id` (string (uuid), required): Identifier of the run, the `run_id` `postAgentRunInput`, `getAgentRunEvents` and `postAgentRunFeedback` take.
  - `organization_id` (string (uuid), required): The organization the run belongs to, the one the request named.
  - `profile` (string, required, one of: `studio`, `video-director`): The prompt profile the run was seeded with, fixed for its whole life.
  - `created_at` (string (date-time), required): When the run was started.

Response headers:

- `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`. 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`: A plain `PAYMENT_REQUIRED`, with no per-entry refinement: the organization does not hold Embedded Studio, the product the `studio-embedded` scope belongs to and the one a publishable key needs to act as a member. It is agreed rather than bought, so it clears when the organization's agreement changes rather than when the request does. The product is checked before the key's scopes, so a key that lacks the scope as well is answered this rather than a `403`. The reads that take `publishing` are unaffected. It is also a plain `PAYMENT_REQUIRED` when the organization the run acts in does not hold Map Studio: the agent changes the organization's itineraries, collections and zones, which needs Map Studio. Map Studio is granted by the organization's agreement, so this too clears when the agreement changes rather than when the request does.
- `403`: The credential is valid and this operation is not open to it: the key does not carry the `studio-embedded` scope, or the user the session token names is not a member of the key's organization, or holds a role there that reads only, or `organization_id` names an organization other than the key's own, whether or not it exists. 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: `organization_id` names an organization the person is not a member of, or one that does not exist. The two answer alike, so it 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. Nothing is started.
- `409`: The organization has no AI provider credential configured, so there is nothing to run the conversation through. The entry's `extensions.code` is `AI_PROVIDER_NOT_CONFIGURED` rather than `CONFLICT`. Deliberately a 409 rather than the 403 above: the member may start runs, and it is the organization that is one step short of being able to serve one. Configure a provider with `postOrganizationAiProviderConfig` and start the run again. 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.
- `413`: The body is over the 1 MiB ceiling of the agent operations, measured before anything reads it, whatever else is wrong with the request and whatever its credential. That refusal is never stored for the `Idempotency-Key`, so a retry runs again. A body within that ceiling is refused this way too when what the run would be started with would weigh more than 1 MiB and 16 KiB: its content is encoded as JSON with `<`, `>`, `&`, U+2028 and U+2029 each written as a six-byte escape, so tool descriptions and parameters dense with them grow to several times what the body weighs. It is answered once the request has been validated and authorized, after this operation's other checks, and nothing is started. Its one entry names no field. It is stored for the `Idempotency-Key`, so a repeat of the key is refused again in the same words, marked `Idempotent-Replayed: true`.
- `429`: `TooManyRequests`, given in full at the end of this page.
- `500`: Internal Server Error
- `504`: Gateway Timeout

**cURL**

```bash
# The reply is the run, whose id the other agent operations take. Everything
# the run produces arrives on the event stream, not in this response. The
# Idempotency-Key makes a retried start resolve to the same run.
curl -s https://api.mountaya.com/v1/agent/runs \
  -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 '{
    "message": "Plan a three-day hut-to-hut loop from Chamonix.",
    "organization_id": "d5a83e17-92c6-4b0f-a7d3-1e6482f9c05b"
  }' | jq '.data.id'
```

**TypeScript**

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

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

const { data } = await mountaya.agent.runs.postAgentRun({
  body: {
    message: "Plan a three-day hut-to-hut loop from Chamonix.",
    organization_id: "d5a83e17-92c6-4b0f-a7d3-1e6482f9c05b",
  },
});

console.log(data);
```

**Python**

```python
import requests
import uuid

response = requests.post(
    "https://api.mountaya.com/v1/agent/runs",
    headers={
        "X-API-Key": "pk_your_publishable_key",
        "X-Session-Token": "sess_your_session_token",
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={
        "message": "Plan a three-day hut-to-hut loop from Chamonix.",
        "organization_id": "d5a83e17-92c6-4b0f-a7d3-1e6482f9c05b",
    },
    timeout=30,
)
response.raise_for_status()
print(response.json()["data"])
```

Response 202:

```json
{
  "data": {
    "id": "5f4e3d2c-1b0a-4998-8776-655443322110",
    "organization_id": "d5a83e17-92c6-4b0f-a7d3-1e6482f9c05b",
    "profile": "studio",
    "created_at": "2026-10-23T08:14:52Z"
  }
}
```

## Send an input signal into a running agent run

### POST /v1/agent/runs/{run_id}/input

- Operation: `postAgentRunInput`
- Requires: scope `studio-embedded` · 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

Delivers an input signal into a running agent run. The request body shape is selected by its `type` discriminator:

- `user-message`: a follow-up user message delivered into the conversation (AgentUserMessageInput).
- `tool-result`: the outcome of a browser-executed client tool, correlated by tool call id (AgentToolResultInput).
- `confirm`: an approval or rejection of a destructive server tool gated behind a confirmation (AgentConfirmInput).
- `close`: a request that the run finish; the run ends successfully with a `done` terminal event (AgentCloseInput).
- `manifest-update`: a replacement client-tool manifest, sent when the set of tools the browser can service changes mid-run (AgentManifestUpdateInput).

The response is 202 Accepted with no data once the signal is accepted; the run's reaction is observed over the event stream (`getAgentRunEvents`). The run must have been started by the user the session token names. A signal is delivered once per `Idempotency-Key`: a retried request with the same key is answered the first one's 202 and delivers nothing again, while the same body sent without one is a second signal, a second message among them.

A **409** (`CONFLICT`) means the run has already ended, however it ended: it went quiet and completed, was closed, exhausted its budget, was stopped for looping, failed, or was ended by the rate limit of the organization's AI provider. It takes no more input, so start a new run, after a short wait when the provider's rate limit ended it. It is returned only for `user-message` and `close`, which are the caller's own instructions. A `tool-result`, a `confirm` and a `manifest-update` answer something the run asked for, so if the run is gone the pending call is already orphaned and they are accepted with 202 rather than paying for the check. So is a `tool-result` or a `confirm` sent more than two minutes after the frame that asked for it: the run has already given up on that call (`tool-abandoned`) and ignores the late answer.

Inputs are limited to 120 a minute for each user and 1,200 a minute for each organization, and the bodies of inputs and run starts together to 8 MiB a minute for each user and 80 MiB a minute for each organization, a request counting the bytes of its body. Past any of them, the answer is a **429** with `Retry-After`, and the signal is not delivered.

Requires a publishable key with the `studio-embedded` scope AND a session token minted for `studio-embedded` naming a user, the member who started the run. Whether that member may still send to the run is answered by the run itself, as the **404** states, and not by the key or the token. A publishable key without a session token minted for `studio-embedded` naming a user, a token minted for another surface included, is refused with **401**.

Records no webhook event. Runs the task `agent.run.input.send`.

**Path parameters**

- `run_id` (string (uuid), in path, required): Identifier of the agent run the operation acts on, the `id` of the `AgentRun` `postAgentRun` returns. It is a plain UUID.

  A run that does not exist, was started in another organization, or was started by somebody other than the user the session token names is a 404, not a 403: the three answer alike, so the parameter cannot be used to learn which run 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**

The signal to deliver to a waiting run: a user message, a confirmation, a client tool's result, an updated tool manifest, or a close.

**Response** `202`

Accepted. A `tool-result`, `confirm` or `manifest-update` sent to a run that has ended, or answering a call already given up on, is accepted and dropped.

- `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` (any | null, required): Always null: this operation answers with no payload.

Response headers:

- `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`. 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`: A plain `PAYMENT_REQUIRED`, with no per-entry refinement: the organization does not hold Embedded Studio, the product the `studio-embedded` scope belongs to and the one a publishable key needs to act as a member. It is agreed rather than bought, so it clears when the organization's agreement changes rather than when the request does. The product is checked before the key's scopes, so a key that lacks the scope as well is answered this rather than a `403`. The reads that take `publishing` are unaffected. It is also a plain `PAYMENT_REQUIRED` when the organization the run acts in does not hold Map Studio: the agent changes the organization's itineraries, collections and zones, which needs Map Studio. The run answers this one itself, to the member who started it while they hold a write role there, and the answer closes the run. Map Studio is granted by the organization's agreement, so this too clears when the agreement changes rather than when the request does.
- `403`: The credential is valid and this operation is not open to it: the key does not carry the `studio-embedded` scope. The membership and role of the user the session token names in the organization are not asked here: the run answers for them, with the **404**. 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`: No agent run with that identifier is reachable: none exists, or it was started in another organization, or by somebody other than the user the session token names. The three answer alike, so a run id cannot be probed here. A run stays reachable for 24 hours from its start; after that it answers as one that does not exist. It is also unreachable when the member who started it holds no write role in the organization it acts in, because they left it, were removed from it, or hold a role that reads only. That answer is the one a run that does not exist gets, and it closes the run, so no further turn is taken for them.
- `409`: The run has already ended: it went quiet and completed, was closed, exhausted its budget, was stopped for looping, failed, or was ended by the rate limit of the organization's AI provider, after which a new run is best started after a short wait. Only a `user-message` or a `close` is refused this way, with the code `CONFLICT`; a `tool-result`, a `confirm` or a `manifest-update` to an ended run is accepted with 202. The conversation takes no more input, so start a new run with `postAgentRun`. 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.
- `413`: The body is over the 1 MiB ceiling of the agent operations, measured before anything reads it, whatever else is wrong with the request and whatever its credential. That refusal is never stored for the `Idempotency-Key`, so a retry runs again. A body within that ceiling is refused this way too when what the input would be delivered to the run as would weigh more than 1 MiB and 16 KiB: its content is encoded as JSON with `<`, `>`, `&`, U+2028 and U+2029 each written as a six-byte escape, so tool descriptions and parameters dense with them grow to several times what the body weighs. It is answered once the request has been validated and authorized, after this operation's other checks, and nothing is delivered. Its one entry names no field. It is stored for the `Idempotency-Key`, so a repeat of the key is refused again in the same words, marked `Idempotent-Replayed: true`.
- `429`: `TooManyRequests`, given in full at the end of this page.
- `500`: Internal Server Error
- `504`: Gateway Timeout

**cURL**

```bash
# The run asked to run a destructive tool. Approve exactly the call it named.
curl -s https://api.mountaya.com/v1/agent/runs/b6f19d02-84ae-4c37-9153-70de2ac8b4f6/input \
  -H "X-API-Key: pk_your_publishable_key" \
  -H "X-Session-Token: sess_your_session_token" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "confirm",
    "tool_call_id": "call_9f3c2a71",
    "approved": true
  }'

# A follow-up message into the same conversation.
curl -s https://api.mountaya.com/v1/agent/runs/b6f19d02-84ae-4c37-9153-70de2ac8b4f6/input \
  -H "X-API-Key: pk_your_publishable_key" \
  -H "X-Session-Token: sess_your_session_token" \
  -H "Content-Type: application/json" \
  -d '{"type": "user-message", "content": "Make day two shorter."}'
```

**TypeScript**

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

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

const { data } = await mountaya.agent.runs.postAgentRunInput({
  run_id: "b6f19d02-84ae-4c37-9153-70de2ac8b4f6",
  body: {
    type: "confirm",
    tool_call_id: "call_9f3c2a71",
    approved: true,
  },
});

console.log(data);
```

**Python**

```python
import requests
import uuid

response = requests.post(
    "https://api.mountaya.com/v1/agent/runs/b6f19d02-84ae-4c37-9153-70de2ac8b4f6/input",
    headers={
        "X-API-Key": "pk_your_publishable_key",
        "X-Session-Token": "sess_your_session_token",
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={
        "type": "confirm",
        "tool_call_id": "call_9f3c2a71",
        "approved": True,
    },
    timeout=30,
)
response.raise_for_status()
print(response.json()["data"])
```

Response 202:

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

## Stream an agent run's events over Server-Sent Events

### GET /v1/agent/runs/{run_id}/events

- Operation: `getAgentRunEvents`
- Requires: scope `studio-embedded` · acting user required (a session token naming a member)
- Behavior: idempotent, safe to retry

Opens a Server-Sent Events (SSE) stream of the run's live output. The response Content-Type is `text/event-stream` and the connection stays open until the run reaches its terminal `done` event, the credential it was opened with ends, the member's hold on the run is lost, the server cannot keep delivering it, or the client disconnects.

Each event is framed as `id: <stream-id>`, `event: <type>`, and `data: <json>`. The `id:` field is the durable, monotonic stream id within the run; the `event:` field is the event type; the `data:` field is the type-specific JSON payload for that type. A `message-delta` is the one frame without an `id:`: deltas are live-only and never replayed, and the `message` that ends the turn is durable.

To resume after a dropped connection, the client reconnects with the `Last-Event-ID` request header set to the last `id:` it received; the server replays events after that id from the run's durable stream before resuming the live feed. Without the header, the replay starts from the oldest event the stream still holds. The durable stream keeps about the last thousand events, for an hour after the run's latest event and for five minutes after its `done`. Past that a reconnect replays nothing, and the stream of a run that has ended closes at once. A `Last-Event-ID` that is not a stream id (two numbers joined by a hyphen, the form of every `id:`) is a **400**, answered before the stream opens.

The stream ends with its credential. When the session token it was opened with expires, or the publishable key is revoked, loses the `studio-embedded` scope, or its organization is canceled, the stream writes one last record, `event: reconnect` with the data `{"type":"reconnect","reason":"credential-expired"}` or `{"type":"reconnect","reason":"credential-revoked"}`, and closes. It is not a failure and the run goes on: reopen the stream at once with a fresh session token and `Last-Event-ID`, and the events written in between are replayed. A `401` on that reopen means the credential itself is gone, and the stream ends there.

The stream also ends when the member it was opened for loses their hold on the run while it is open: removed from the organization, left without the role a run asks, or in an organization that has lost Map Studio. That is not the credential ending, so no `reconnect` event is written: the stream writes the comment `: session-ended` and closes, and a reopen is answered as the run's grant now stands.

And it ends when the server cannot keep delivering its events, because the reader fell behind or the server's subscription was lost: it writes a last `reconnect` event whose `reason` is `interrupted`, and closes. Reopen at once with `Last-Event-ID`, and the events written in between are replayed.

A replay can hold a call that has its outcome: one the client answered before a page reload, after which it reconnects without the header, or one that timed out while the client was away. A replayed `tool-call` or `confirm-required` whose outcome the replay also holds, a `tool-result` or a `tool-abandoned` for the same `tool_call_id`, carries `settled: true`. The client neither runs it nor asks about it again. One replayed without the marker has no outcome on the stream yet, and the client answers it as it would a live one.

While the stream is open past its replay, the server writes a comment (a line beginning with a colon) every 15 seconds, whatever else the stream carries. A comment is not an event: it has no `id:` and no `data:`, and a client discards it. It keeps the connection, and any proxy in between, from closing a quiet stream as idle.

A run that the rate limit of the organization's AI provider ended answers **409** (`CONFLICT`) here rather than opening a stream, so its closing frames are not replayed. The run is over; after a short wait start a new run with `postAgentRun`.

The `event:` type and the shape of the matching `data:` payload are the AgentRunEvent schema: it is a union discriminated on `type`, so every frame kind, the run's terminal reason, and the per-call abandon reason are stated once and cannot drift from one another.

A `HEAD` request on this path is answered with the headers a `GET` would get, and opens no subscription.

Opening the stream is limited to 60 opens a minute for each user and 1200 for each organization. Past either, the answer is a **429** with `Retry-After`, and no stream opens. Like every read made with a session token, each open also counts toward the 1200 reads a minute each user is allowed and the 6000 each organization is allowed.

At most 20 streams are held open at once for each user, 50 for each client IP address and 1,000 for each organization, counted across every event stream. An open past any of them is a `429` with `Retry-After`, and no stream starts; a stream gives its place back when it ends.

Requires a publishable key with the `studio-embedded` scope AND a session token minted for `studio-embedded` naming a user, the member who started the run. Whether that member may still follow the run is answered by the run itself, as the **404** states, and not by the key or the token. A publishable key without a session token minted for `studio-embedded` naming a user, a token minted for another surface included, is refused with **401**.

**Path parameters**

- `run_id` (string (uuid), in path, required): Identifier of the agent run the operation acts on, the `id` of the `AgentRun` `postAgentRun` returns. It is a plain UUID.

  A run that does not exist, was started in another organization, or was started by somebody other than the user the session token names is a 404, not a 403: the three answer alike, so the parameter cannot be used to learn which run ids exist.

**Headers**

- `Last-Event-ID` (string, in header, optional): The last stream id the client received, `<milliseconds>-<sequence>` as the stream wrote it, for example `1778577393417-0`. A value of any other shape is a `400`, answered before the stream opens. When set, the server replays the events after that id that the stream still holds before resuming the live feed. A stream holds about its last thousand events, for an hour after the latest one, or for five minutes after an agent run's `done` event, so a client that reconnects within that window misses no event that carries an id. An id older than what the stream still holds is not refused: the replay starts at the oldest event held, and nothing marks the gap.

  Live-only signals carry no id and are never replayed: cursors, selections and uncommitted drafts on a collaboration stream, whose presence and locks are sent again as snapshots instead, and the partial text of an agent's answer, which its final message supersedes.

  A browser's own `EventSource` sends this by itself on a reconnect. A client reading the stream some other way sends it explicitly. Without it the stream does not start at the live edge: the server replays every event the stream still holds, from the oldest, before the live feed, so a client that omits it on a reconnect receives again what it has already seen.

  A replayed event is written as it was first sent, with one exception. On an agent run's stream, a replayed `tool-call` or `confirm-required` whose outcome the replay also holds, a `tool-result` or a `tool-abandoned` for the same tool call id, carries `settled: true`, so a client that reads a run again neither runs that call nor asks about that confirmation a second time. One replayed without the marker has no outcome on the stream yet, and the client answers it as it would a live one.

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` `text/event-stream`

A `text/event-stream` of the run's events, framed as `id:`/`event:`/`data:` records, terminated by a `done` event, save for a run stopped from outside, whose stream closes without one; a stream whose credential ends first, or that the server cannot keep delivering, which closes after a `reconnect` event; and a stream whose member loses their hold on the run, which closes after a `: session-ended` comment, a comment and not an event. The schema describes one decoded frame, the `data:` JSON of a single record, not the byte stream as a whole.

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

- `400`: Bad Request
- `401`: Unauthorized
- `402`: A plain `PAYMENT_REQUIRED`, with no per-entry refinement: the organization does not hold Embedded Studio, the product the `studio-embedded` scope belongs to and the one a publishable key needs to act as a member. It is agreed rather than bought, so it clears when the organization's agreement changes rather than when the request does. The product is checked before the key's scopes, so a key that lacks the scope as well is answered this rather than a `403`. The reads that take `publishing` are unaffected. It is also a plain `PAYMENT_REQUIRED` when the organization the run acts in does not hold Map Studio, which the agent needs to change the organization's itineraries, collections and zones. The run answers this one itself, to the member who started it while they hold a write role there, and the answer closes the run.
- `403`: The credential is valid and this operation is not open to it: the key does not carry the `studio-embedded` scope. The membership and role of the user the session token names in the organization are not asked here: the run answers for them, with the **404**. 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`: No agent run with that identifier is reachable: none exists, or it was started in another organization, or by somebody other than the user the session token names. The three answer alike, so a run id cannot be probed here. A run stays reachable for 24 hours from its start; after that it answers as one that does not exist. It is also unreachable when the member who started it holds no write role in the organization it acts in, because they left it, were removed from it, or hold a role that reads only. That answer is the one a run that does not exist gets, and it closes the run, so no further turn is taken for them.
- `409`: The run has already ended, by the rate limit of the organization's AI provider, so no stream is opened and its closing frames are not replayed. The run takes no more input: after a short wait, start a new run with `postAgentRun`. A run that ended any other way opens its stream, which replays what it still holds and closes.
- `429`: `TooManyRequests`, given in full at the end of this page.
- `500`: Internal Server Error
- `503`: The stream cannot be opened right now: the run's events, or what the caller's access to the run is checked against, could not be reached for a moment on Mountaya's side, to check who owns the run and the grant it acts under, or to follow it live. Nothing about the run changed and no event was missed: open the stream again once `Retry-After` has passed, with the `Last-Event-ID` of the last event received, or with none to read the run from its start.

**cURL**

```bash
# Server-Sent Events, so keep the connection open and read frames as they land.
# -N disables curl's buffering; without it nothing prints until the run ends.
curl -sN "https://api.mountaya.com/v1/agent/runs/b6f19d02-84ae-4c37-9153-70de2ac8b4f6/events" \
  -H "X-API-Key: pk_your_publishable_key" \
  -H "X-Session-Token: sess_your_session_token"

# Reconnecting? Send the id of the last frame you processed and the run replays
# from just after it rather than from the beginning.
curl -sN "https://api.mountaya.com/v1/agent/runs/b6f19d02-84ae-4c37-9153-70de2ac8b4f6/events" \
  -H "X-API-Key: pk_your_publishable_key" \
  -H "X-Session-Token: sess_your_session_token" \
  -H "Last-Event-ID: 1778577393417-0"
```

**TypeScript**

```typescript
// `@mountaya/client/events` reads these streams with reconnects and typed frames.
const response = await fetch("https://api.mountaya.com/v1/agent/runs/b6f19d02-84ae-4c37-9153-70de2ac8b4f6/events", {
  headers: { "X-API-Key": publishableKey, "X-Session-Token": sessionToken },
});

const reader = response.body?.pipeThrough(new TextDecoderStream()).getReader();
for (let chunk = await reader?.read(); chunk && !chunk.done; chunk = await reader?.read()) {
  // `id:`, `event:` and `data:` lines, one frame per blank-line-separated record.
  console.log(chunk.value);
}
```

**Python**

```python
import json
import requests

with requests.get(
    "https://api.mountaya.com/v1/agent/runs/b6f19d02-84ae-4c37-9153-70de2ac8b4f6/events",
    headers={
        "X-API-Key": "pk_your_publishable_key",
        "X-Session-Token": "sess_your_session_token",
    },
    stream=True,
    timeout=(10, None),
) as response:
    response.raise_for_status()
    for line in response.iter_lines(decode_unicode=True):
        if line.startswith("data:"):
            print(json.loads(line[5:]))
```

## Record the user's rating of one assistant message in a run

### POST /v1/agent/runs/{run_id}/feedback

- Operation: `postAgentRunFeedback`
- Requires: scope `studio-embedded` · 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

Records a thumbs up or thumbs down against one assistant message. It is the explicit outcome label for the run: the tool sequence already implies whether the work was taken up, but only for runs that ended in an edit, and says nothing about a run that ended in an answer.

The rating is recorded for quality measurement and carries no message content. It is accepted after the run has ended, which is when a user usually presses it, so it is NOT a signal into the run, and for as long as the run stays reachable: 24 hours from its start.

Every press is recorded, and none replaces another: a rating sent again for the same message is kept beside the earlier ones, so a change of mind stays observable, and the latest press for a message is the rating that counts. A retry carrying the same `Idempotency-Key` is answered the first request's 202 and records nothing again, while the same body sent without one is a second press. Recording is best-effort. A run that does not exist, or that the user the session token names did not start, answers 404 and records nothing.

Ratings are limited to 60 a minute for each user and 600 a minute for each organization; past either, the answer is a **429** with `Retry-After`, and nothing is recorded.

Requires a publishable key with the `studio-embedded` scope AND a session token minted for `studio-embedded` naming a user, the member who started the run. The rating is accepted whatever role that member holds in the organization now, and whatever the organization holds beside Embedded Studio, for as long as the run stays reachable: it spends nothing, and reaches none of the organization's data. A publishable key without a session token minted for `studio-embedded` naming a user, a token minted for another surface included, is refused with **401**.

Records no webhook event. Runs the task `agent.run.feedback.send`.

**Path parameters**

- `run_id` (string (uuid), in path, required): Identifier of the agent run the operation acts on, the `id` of the `AgentRun` `postAgentRun` returns. It is a plain UUID.

  A run that does not exist, was started in another organization, or was started by somebody other than the user the session token names is a 404, not a 403: the three answer alike, so the parameter cannot be used to learn which run 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**

The rating for one assistant message in the run, identified by its zero-based index in the conversation.

- `rating` (string, in body, required, one of: `up`, `down`): The thumb being recorded against the assistant message named by `message_index`.

- `message_index` (integer (int32), in body, required): Zero-based index of the rated assistant message within the run's conversation. A run carries several answers, and a rating on the third is not a verdict on the first.

  Bounded at both ends: an index outside 0-65535 is rejected rather than accepted and applied to a different answer than the one rated.

**Response** `202`

Accepted: the rating is recorded beside any this user gave the same message before, and as the latest press it is the one that counts.

- `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` (any | null, required): Always null: this operation answers with no payload.

Response headers:

- `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`, `503`, `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
- `402`: A plain `PAYMENT_REQUIRED`, with no per-entry refinement: the organization does not hold Embedded Studio, the product the `studio-embedded` scope belongs to and the one a publishable key needs to act as a member. It is agreed rather than bought, so it clears when the organization's agreement changes rather than when the request does. The product is checked before the key's scopes, so a key that lacks the scope as well is answered this rather than a `403`. The reads that take `publishing` are unaffected. Map Studio is not asked: a rating changes nothing the organization holds.
- `403`: The credential is valid and this operation is not open to it: the key does not carry the `studio-embedded` scope. The membership and role of the user the session token names in the organization are not asked: a run they did not start is the **404**. 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`: No agent run with that identifier is reachable: none exists, or it was started in another organization, or by somebody other than the user the session token names. The three answer alike, so a run id cannot be probed here. A run stays reachable for 24 hours from its start; after that it answers as one that does not exist.
- `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
- `503`: The ownership of this run could not be checked, so the rating is neither accepted nor refused, and nothing is recorded. The check runs before anything is stored, so sending the same body again after a short delay records the rating once.
- `504`: Gateway Timeout

**cURL**

```bash
# Feedback is per MESSAGE, not per run: message_index picks which assistant turn
# the rating is about.
curl -s -X POST https://api.mountaya.com/v1/agent/runs/b6f19d02-84ae-4c37-9153-70de2ac8b4f6/feedback \
  -H "X-API-Key: pk_your_publishable_key" \
  -H "X-Session-Token: sess_your_session_token" \
  -H "Content-Type: application/json" \
  -d '{
    "rating": "up",
    "message_index": 2
  }'
```

**TypeScript**

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

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

const { data } = await mountaya.agent.runs.postAgentRunFeedback({
  run_id: "b6f19d02-84ae-4c37-9153-70de2ac8b4f6",
  body: { rating: "up", message_index: 2 },
});

console.log(data);
```

**Python**

```python
import requests
import uuid

response = requests.post(
    "https://api.mountaya.com/v1/agent/runs/b6f19d02-84ae-4c37-9153-70de2ac8b4f6/feedback",
    headers={
        "X-API-Key": "pk_your_publishable_key",
        "X-Session-Token": "sess_your_session_token",
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={"rating": "up", "message_index": 2},
    timeout=30,
)
response.raise_for_status()
print(response.json()["data"])
```

Response 202:

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

**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.
