Applies to v1.3.18

On-Demand Agent Runs

Purpose

This page shows the two ways to start a hosted agent now, rather than on a schedule or an event: Run in the Portal, which runs the agent as you, and the Runtime's executions API, which an application or script calls with its own credential. It covers waiting for the answer versus returning immediately, reading the result, and cancelling.

Which One To Use

I want to… Use Runs as Delegated access (OBO, token exchange)
try an agent, or run it by hand as myself Run… in the Agent Directory You, the signed-in Portal user Yes, as for any user caller
start an agent from an application, a script or a pipeline POST /runtime/{tenantId}/agents/{agentId}/executions The caller: the token or API key you send Only with a user token
hold a conversation with an agent, or let another agent delegate to it A2A — see Calling Agents Over A2A The caller Only with a user token

Run and the API are attached: the run belongs to the caller who started it, the agent's access policy is evaluated for that caller, and a user's own token keeps reaching the downstream systems that need it, exactly as over A2A.

Manual Presets

A manual preset is a trigger of kind Manual: saved instructions, parameters and execution limits that anyone allowed to call the agent can start from. It has no run identity — whoever starts it is the identity. Create one on the Agent Triggers page like any other trigger; then name it in Run… (Start from) or in the API (triggerId).

When a preset is used, the run's input is its instructions, then the caller's own text, then the parameters — the preset's merged with the caller's, the caller's value winning for any key both set.

Run In The Portal

In Apps & Tools → Agent Directory, select a hosted agent and choose Run… in its summary — or open the agent and choose Run… in the page's header:

  1. Start from — a manual preset of this agent, or No preset — just my message.
  2. Message — what you want done. Required unless a preset is chosen.
  3. Parameters — an optional JSON object.
  4. Wait for the answer here — tick it to wait and see the result in the dialog; otherwise the dialog's Open the execution link selects the execution on the Agent Triggers page's Executions tab.

The agent runs as you, and the dialog says so. The Portal sends your own Portal session to the Runtime — it never substitutes another identity — so you can run an agent only if its access policy would let you call it. Your Portal session is issued by the platform itself: an access policy that admits only callers from your corporate identity provider's issuer does not match it. If the Runtime refuses, the dialog shows its reason.

The Runtime Executions API

Three routes, under the Runtime's usual tenant-first address. They accept a bearer token or an API key, like the tools API (see Authentication); an API key is accepted for its own tenant.

Method and path Purpose
POST /runtime/{tenantId}/agents/{agentId}/executions Starts a run of a hosted agent as the caller
GET /runtime/{tenantId}/agents/executions/{executionId} Reads an execution's status and result
POST /runtime/{tenantId}/agents/executions/{executionId}/cancel Cancels an execution

{agentId} is the agent's id in the Agent Directory.

Starting a run

BASE='https://apimapper.example.com/runtime/<tenant-id>'

curl -X POST "$BASE/agents/<agent-id>/executions" \
  -H "Authorization: Bearer $TOKEN" \
  -H 'Content-Type: application/json' \
  -H 'X-Correlation-Id: change-CHG-20481' \
  -d '{
        "text": "Summarize the open incidents for EMEA raised in the last 24 hours.",
        "parameters": { "region": "EMEA" }
      }'
Field Type Notes
triggerId string (uuid), optional A manual preset of this agent to start from
text string, optional Your message, up to 32 000 characters. Required when there is no triggerId
parameters object, optional A JSON object, up to 32 768 characters; its keys win over the preset's
returnImmediately boolean, default true false waits for the turn to finish

By default the call returns as soon as the run exists:

HTTP/1.1 202 Accepted
Content-Type: application/json

{
  "executionId": "5b2e8c41-9a7d-4f3e-8c11-6d0f2a9b7e35",
  "taskId": "c4a1f0d2-77e3-4b6a-a0c8-1e9d5f3b2a64",
  "status": "TASK_STATE_SUBMITTED",
  "resultText": null,
  "failureReason": null
}

status here is the A2A task state. taskId is the A2A task the run drives.

Waiting for the answer

With "returnImmediately": false the call holds the connection until the turn finishes or pauses — up to the agent's turn budget, 300 seconds by default — and answers 200:

{
  "executionId": "5b2e8c41-9a7d-4f3e-8c11-6d0f2a9b7e35",
  "taskId": "c4a1f0d2-77e3-4b6a-a0c8-1e9d5f3b2a64",
  "status": "TASK_STATE_COMPLETED",
  "resultText": "Three incidents are open for EMEA…",
  "failureReason": null
}

A run that failed also answers 200, with status TASK_STATE_FAILED and the reason in failureReason. A run that paused for input answers TASK_STATE_INPUT_REQUIRED; you can continue that conversation only over A2A, with the taskId, if the agent is published (see Answer A Question From The Agent).

Waiting is convenient for short runs and scripts. For anything longer, or behind a proxy with a shorter idle timeout, return immediately and poll.

Reading an execution

curl "$BASE/agents/executions/5b2e8c41-9a7d-4f3e-8c11-6d0f2a9b7e35" -H "Authorization: Bearer $TOKEN"
{
  "execution": {
    "id": "5b2e8c41-9a7d-4f3e-8c11-6d0f2a9b7e35",
    "registeredAgentId": "<agent-id>",
    "triggerId": null,
    "channel": "Manual",
    "deliveryMode": "Attached",
    "status": "Completed",
    "failureKind": null,
    "statusReason": null,
    "identityKind": "Caller",
    "callerSubject": "9f1c…",
    "taskId": "c4a1f0d2-77e3-4b6a-a0c8-1e9d5f3b2a64",
    "correlationId": "…",
    "attempt": 1,
    "acceptedAtUtc": "2026-10-31T09:20:11Z",
    "startedAtUtc": "2026-10-31T09:20:11Z",
    "endedAtUtc": "2026-10-31T09:20:39Z",
    "toolCallCount": 2,
    "inputTokens": 5310,
    "outputTokens": 412,
    "modelCalls": 3
  },
  "resultText": "Three incidents are open for EMEA…",
  "resultRetained": true
}

(Abbreviated: the execution also carries its tenant, run identity, retry and schedule fields.)

execution.status is the execution's own status — Pending, Queued, Running, Completed, InputRequired, Failed, TimedOut, Cancelled or Skipped — described in Monitoring & Troubleshooting. Poll until it is none of Pending, Queued or Running; every few seconds is enough. resultText is the agent's answer for a completed run; resultRetained is false when the run completed but its task has since been purged by retention.

Who can read an execution. The caller that started it, and any caller the agent's access policy authorizes for at least one of its skills — which also covers executions started by schedules, webhooks and other callers. Anyone else gets 404, never 403, so an execution id confirms nothing to a caller with no right to it.

Cancelling

curl -X POST "$BASE/agents/executions/5b2e8c41-9a7d-4f3e-8c11-6d0f2a9b7e35/cancel" -H "Authorization: Bearer $TOKEN"
{ "executionId": "5b2e8c41-9a7d-4f3e-8c11-6d0f2a9b7e35", "outcome": "Requested" }
outcome Meaning
Cancelled It had not started, and is now cancelled
Requested It is running; the replica running it stops it within one lease renewal — about 20 seconds by default
AlreadyEnded It had already finished

The same visibility rule applies as for reading. Cancelling a run that already called tools does not undo what those tools did.

Errors

Status Body Cause
400 Problem details, urn:apimapper:agents:input-required Neither text nor triggerId
400 urn:apimapper:agents:text-too-long, …:invalid-parameters, …:preset-not-found Text over 32 000 characters; parameters not a JSON object or too long; triggerId is not a manual preset of this agent
401 As on every Runtime route No valid token or API key — see Common Authentication Failures
403 The start response, with status TASK_STATE_FAILED and the reason in failureReason The agent's access policy refuses this caller
404 Problem details, urn:apimapper:agents:agent-not-found or …:execution-not-found No hosted agent with this id in the tenant; or an execution that does not exist or is not visible to you
409 The start response, as for 403 The agent is inactive or cannot be resolved
429 The start response, as for 403; Retry-After: 30 The agent is at its concurrency limit, or this Runtime replica's work queue is full. An on-demand run is refused rather than queued, because your credential exists only for this request
429 Problem details; Retry-After Rate limit: starting runs shares the tool-invocation limit, 20 per minute by default

Never retry a start that may have reached the platform — a timeout or a dropped connection — without first checking: a second request starts the agent a second time, and an agent that called tools may already have acted. Retry a 429 after Retry-After.

From The SDKs

Each client library, from version 1.3.0, has an agent client alongside the tool client, with methods to start, read and cancel executions, a typed error for refusals that carries the status, the problem type and Retry-After, and a helper that signs webhook deliveries. It uses the same base URL, tenant and credential as the tool client, and it never retries a start.

Language Agent client Refusal Reference
.NET IApiMapperAgentClient, registered by AddApiMapperClient ApiMapperAgentRequestException Hosted Agents
TypeScript ApiMapperAgentClient ApiMapperAgentRequestError Hosted Agents
Python ApiMapperAgentClient ApiMapperAgentRequestError Hosted Agents
Java ApiMapperAgentClient ApiMapperAgentRequestException Hosted Agents

From any other language, call the routes above with any HTTP client.