Skip to content

Cancel a run

View as Markdown
POST
/v1/runs/{runId}/cancel
curl --request POST \
--url https://example.com/v1/runs/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/cancel \
--header 'Authorization: Bearer <token>'

Takes write on the run’s project; a runner there may cancel a run that acts for them (one they started, or their own schedule did). Cancelling a run that already reached a terminal state returns 409 run-already-terminal.

runId
required
string format: uuid

RunId — opaque branded string (a UUID).

Idempotency-Key
string
>= 1 characters

Caller-supplied idempotency key, scoped to the caller: the same key from someone else in the workspace is their own request (from 0.1.5). Retries with the same key return the original response byte-identical (per docs/API-ROUTE-CONVENTIONS.md §3.1). A retry sent while the first request still runs is answered 409 idempotency-key-in-flight with Retry-After, on a runtime whose store holds keys (from 0.1.5); retry after it, and you get the first request’s answer. An answer that carries a secret (a new API key or public run token, a session token, a generated signing secret) isn’t kept: a retry gets 409 idempotency-key-replay-withheld, with the first request’s status and when it succeeded (from 0.1.5). A request whose key store can’t be read before it runs is answered 503 idempotency-store-unavailable with Retry-After: nothing ran, so retry with the same key (from 0.3.0).

Updated run row.

Media typeapplication/json
object
id
required

RunId.

string format: uuid
tenantId
required
string format: uuid
projectId
string format: uuid
flowId
required
string
flowVersion
required

Semver.

string
flowVersionVia

How the run’s flow version was chosen, recorded when the run was created: explicit (the start named it), pinned (the version pinned for the run’s project, its org or the workspace; flowPinnedScope names the pin) or latest (the newest version the run’s project reaches). Absent when the runtime didn’t record it, as on runs from before it did.

string
Allowed values: explicit pinned latest
flowPinnedScope
One of: discriminator: kind

The whole workspace.

object
kind
required
string
Allowed values: tenant
status
required
string
Allowed values: pending running suspended completed failed cancelled
dryRun
required
boolean
createdAt
required
string format: date-time
updatedAt
required
string format: date-time
completedAt
string format: date-time
failureMessage

The failure as the runtime recorded it. Read failure instead: an agent turn records its typed error here in an internal form, and so does a flow run’s step that a tool failed on purpose (tool-failed).

string
failure

Why a failed run failed; present only on a failed run. An agent turn’s failure carries its own code (budget-exceeded, capability-routing-failed, model-invocation-failed, …; rate-limit-exceeded when a budget kept per workspace refused work the turn needed, with details naming the budget; tool-failed when a tool failed a call on purpose, with its code as reason); any other failure is run-failed, with the run’s failure message.

object
code
required
string
message
required
string
cause

What the error came from, when it says: e.g. for capability-routing-failed, the router’s capability-unsatisfiable with its reasons, by provider; for tool-failed, the tool, { toolId }.

reason

The error’s own reason, when it gives one: for a turn that ended at its approval (hitl-cancelled), timeout when nobody decided in time; for tool-failed, the tool’s own code for why (order-not-found). Absent from an older runtime and from errors without one; read code then.

string
details

The error’s own facts, for a code that has them: for rate-limit-exceeded, limit (the budget that refused: schema-compile-time or template-render-time) and budgetMs, the names the API’s 429 uses; for tool-failed, the facts the tool gave, when it gave any. Never the wait: read back later, it’s stale. Absent for any other code, and from an older runtime.

object
key
additional properties
any
output

The run’s output once it completed. Present on single-run responses; on lists only with ?include=output.

contentErasedAt

When an erasure cleared the run’s content (its input, output, failure message and journal payloads): a person’s words were erased. Structure (status, times, ids) stays.

string format: date-time
parentRunId

Set on a child run (a sub-flow run, or the agent turn an agent step started): the run that started it.

string format: uuid
parentNodeId

Set on a child run: the node in the parent run that started it.

string
agent

Set on an agent’s turn (an agent run, or the turn a flow’s agent step started): the agent, the version that ran and the conversation. Absent on other runs, and on turns that ran before Kindgi 0.1.3.

object
id
required

The agent id.

string
version
required

The agent version that ran (semver).

string
conversationId
required
string format: uuid
via

Why this version ran: named by the caller (explicit); held by the flow version a flow’s agent step runs in (flow-pin: the node’s config.version, else the version the flow version pinned when it was published); the conversation’s own (conversation); the version pinned for the run’s scope (pinned); or the latest, nothing being pinned (latest). Absent on runs from before Kindgi 0.1.4.

string
Allowed values: explicit flow-pin conversation pinned latest
pinnedScope
One of: discriminator: kind

The whole workspace.

object
kind
required
string
Allowed values: tenant
waitingFor

Set on a suspended run by GET /v1/runs/{runId}, and by the list with ?include=waitingFor: what it waits for, its journal’s open waits. approvals: those still to be decided, linked to the waits. connections: the connects it waits for. tokens: its waits for another system’s answer. other: the rest. Absent from a runtime before Kindgi 0.1.6, or when the journal can’t be read; kindgi runs resume then works it out itself.

object
approvals
required
Array<object>

An approval the run waits for, as a run reader sees it: its identity and state. Its subject’s details, description, context and decision stay on GET /v1/approvals/{approvalId}, behind the reviewer gate.

object
approvalId
required
string format: uuid
status
required

Still to be decided: pending, assigned, in_review or escalated.

string
requiredRole
required

The reviewer role that may decide it, or above.

string
title
string
createdAt
required
string format: date-time
expiresAt
string format: date-time
subjectKind
required

What waits: e.g. tool-call:pending (a tool call held for review).

string
tool

For a tool call held for review: which tool and which call. Never the call’s arguments.

object
id
required

The tool id.

string
version
required
string
callId
required

The model’s id for the call.

string
approver

The one member who may decide it.

object
kind
required
string
Allowed values: member
userId
required
string
connection

The connection the call would use: the person’s own, or else the company’s connection the call was gated on, which it then runs with or doesn’t run (connection-changed). A person’s account isn’t named: show “this person’s account”, and, to whoever may read the connection (GET /v1/connections/{connectionId}), its account.

object
app
required

The app’s entry id.

string
appName
required
string
as

Whose connection: the company’s, or the person’s. Absent from older approvals.

string
Allowed values: company person
account

The company’s account label at the app: an email address, a login. Absent for a person’s; older approvals have it for theirs too.

string
name

The company connection’s name: its label, else the account’s label. A person’s own connection has none.

string
connectionId

The connection’s id. Whoever may read the connection (its person, a tenant admin) looks its account up by it: GET /v1/connections/{connectionId}. Absent from older approvals.

string format: uuid
connections

The connects the run waits for. Left out when there are none.

Array<object>

A connect the run waits for: the person opens connectUrl, consents at the app, and the run goes on.

object
name
required

The tool’s name for the connection.

string
requestId
required
string format: uuid
waitToken
required
string
app
required

The app’s entry id.

string
appName
required
string
says
required

What each permission asked for allows, in plain words.

Array<string>
connectUrl
required
string format: uri
expiresAt
required
string format: date-time
reconnects

The person connected this app before, and connects it again.

boolean
tokens

Its waits for another system’s answer (a pausing tool’s calls). Absent on a runtime that pauses no run, or when they can’t be read: those waits are then unattributed.

Array<object>

A wait for another system’s answer: a pack tool that declares pauses handed its wait token’s link on. Answer it through the link, or with POST /v1/runs/{runId}/resume and this tokenId. Never the link itself.

object
tokenId
required

The waitpoint id (pause:…), for POST /v1/runs/{runId}/resume.

string
name

What the run waits for, as the tool named it.

string
tool
required

The tool whose call waits.

object
id
required

The tool id.

string
version
required
string
callId

The model’s id for the call, for an agent’s call.

string
nodeId

The flow step that waits, for a flow’s tool step.

string
createdAt
required
string format: date-time
timesOutAt
required

When the wait times out, and the call fails with wait-token-timed-out.

string format: date-time
other
required
Array<object>

child-run (childRunId, childStatus, timesOutAt): a child run must finish. decided-approval (approvalId, approvalStatus): decided, the runtime continues. unattributed (tokenId, timesOutAt): a wait that isn’t an approval’s, a connect’s or one of tokens, or whose approval, connect or token can’t be read. no-open-wait: the journal shows none; the runtime picks the run up again.

object
what
required
string
Allowed values: child-run decided-approval unattributed no-open-wait
childRunId
string format: uuid
childStatus
string
approvalId
string format: uuid
approvalStatus
string
tokenId
string
timesOutAt
string format: date-time
trigger

Set on a run a trigger started: the trigger and the fire that started it. Absent on other runs. kind is the trigger’s kind: schedule, event, webhook (an inbound webhook), mail (new mail in a mailbox) or text (a text to a business number).

object
triggerId
required
string format: uuid
kind
required
string
Allowed values: schedule event webhook mail text
fireId
required

The fire that started the run: one entry of the trigger’s fire history.

string
scheduledFor

A schedule’s fire: the occurrence the run is for.

string format: date-time
version

The trigger’s version the run started with (GET …/versions/{version}), which later edits don’t change. Absent on a run from before versions.

integer
>= 1
startedBy

How the run started, recorded when it was created and never changed: person (a person, signed in or with their own API key), key (a service account’s key), or the kind of trigger that fired it: schedule, webhook, event, mail or text. A child run has its parent’s. Only person counts as attended: in any other run, or one without this field (runs from before runs recorded it), a tool that declares needsApprovalWhenUnattended waits for a person’s yes.

string
Allowed values: person key schedule webhook event mail text
actsFor

Whom the run acts for, whose access it has, recorded when it was created and never changed: user:<id> (a person) or service_account:<id> (a service account), the same strings as an approval’s requestedBy, a conversation’s openedBy and whoami’s actor. A person who starts a run, signed in or with their own API key, is whom it acts for, and so is a service account whose key starts one. A run a schedule, a webhook, a mail or a text trigger fired (startedBy schedule, webhook, mail or text) acts for the trigger’s owner when it fired; a child run for its parent’s; an agent acting for someone for that someone. An approval or a resume doesn’t change it. An id, never a name: show the caller’s own as you, and a name only where the caller may read that person or service account. Absent on a run that acts for no one (a system job, an agent on its own, a test run’s replay run) and on runs from before runs recorded it. Never on a public run token’s progress view or its stream, nor on the run.finished webhook’s run.

string
toolsAllowedUnattended

The tools, by id, whose calls in this run don’t wait for a person’s yes though no person started it: the list of the webhook or schedule that fired it, as it was when the run started, and never changed after. A child run has its parent’s. Absent: none.

Array<string>
replayOf

Set on a replay run (a test run re-running a past run): the run it replays.

string format: uuid
testRunId

Set on a replay run: the test run that started it.

string
versions

Agents and tools a flow runs at other exact versions than the flow version’s pins (“this flow, with acme.scorer at 0.4.0”), without publishing a new flow version: a comparison’s flow candidate (versions on the start body and the run’s comparison), and the flow runs that replay it (a run’s versions). Each id must be an agent or tool the flow uses.

object
tools

Tool id → exact version.

object
key
additional properties
string
agents

Agent id → exact version, for agent nodes with or without a version of their own.

object
key
additional properties
string
segments

The segment path the run was started with (coarse to fine), which picks pinned agent versions. A child run has its parent’s. Absent when there was none.

Array<object>
object
key
required

Lowercase, like an identifier: company, contact-role.

string
/^[a-z][a-z0-9_-]{0,63}$/
value
required
string
>= 1 characters <= 256 characters
traceId

The W3C trace id of the request that started the run: the caller’s (from its traceparent) or one the API minted. The runtime’s records about the run carry it; GET responses answer traceresponse with each request’s own. Absent for a run no request started, and on runs from before runs recorded it.

string
/^[0-9a-f]{32}$/
publicAccessToken

Only in the response to POST /v1/runs, when the deployment issues public run tokens: a read-only token for this run (and its descendants) to hand to a browser, for GET /v1/runs/{runId}/progress and its stream.

string
publicAccessTokenExpiresAt

When publicAccessToken stops working.

string format: date-time
Example
{
"flowVersionVia": "explicit",
"flowPinnedScope": {
"kind": "tenant"
},
"status": "pending",
"agent": {
"via": "explicit",
"pinnedScope": {
"kind": "tenant"
}
},
"waitingFor": {
"approvals": [
{
"approver": {
"kind": "member"
},
"connection": {
"as": "company"
}
}
],
"other": [
{
"what": "child-run"
}
]
},
"trigger": {
"kind": "schedule"
},
"startedBy": "person"
}

Malformed request body.

Media typeapplication/json
object
error
required
object
code
required

Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).

string
message
required
string
details

Optional, kind-specific.

object
key
additional properties
any
requestId
required

Server-assigned request id; also echoed via X-Request-Id header.

string
Examplegenerated
{
"error": {
"code": "example",
"message": "example",
"details": {},
"requestId": "example"
}
}

Missing / malformed / expired / revoked bearer token.

Media typeapplication/json
object
error
required
object
code
required

Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).

string
message
required
string
details

Optional, kind-specific.

object
key
additional properties
any
requestId
required

Server-assigned request id; also echoed via X-Request-Id header.

string
Examplegenerated
{
"error": {
"code": "example",
"message": "example",
"details": {},
"requestId": "example"
}
}

permission-denied: the caller may not make this change. Without an authorization store, key-project-mismatch (details.keyProjectId, details.projectId): the API key or session is limited to a project, and this acts in another one, the record’s or its agent’s or test set’s (with a store, that is permission-denied, or the record isn’t found).

Media typeapplication/json
object
error
required
object
code
required

Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).

string
message
required
string
details

Optional, kind-specific.

object
key
additional properties
any
requestId
required

Server-assigned request id; also echoed via X-Request-Id header.

string
Examplegenerated
{
"error": {
"code": "example",
"message": "example",
"details": {},
"requestId": "example"
}
}

No run with that id under this workspace.

Media typeapplication/json
object
error
required
object
code
required

Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).

string
message
required
string
details

Optional, kind-specific.

object
key
additional properties
any
requestId
required

Server-assigned request id; also echoed via X-Request-Id header.

string
Examplegenerated
{
"error": {
"code": "example",
"message": "example",
"details": {},
"requestId": "example"
}
}

Idempotency-Key was reused with a different body, or resource-state conflict. Or idempotency-key-in-flight (with Retry-After): a request with the same Idempotency-Key still runs, so this one wasn’t run; send it again after Retry-After to get that request’s answer.

Media typeapplication/json
object
error
required
object
code
required

Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).

string
message
required
string
details

Optional, kind-specific.

object
key
additional properties
any
requestId
required

Server-assigned request id; also echoed via X-Request-Id header.

string
Examplegenerated
{
"error": {
"code": "example",
"message": "example",
"details": {},
"requestId": "example"
}
}
Retry-After
integer
>= 1

Whole seconds to wait before sending the request again, at least 1. Sent with the codes the answer names as sending it, so it may be absent.

rate-limit-exceeded with details.limit: "api-requests", on a runtime that sets workspace limits (Kindgi Cloud): this workspace’s limit on API requests a minute is reached, so the request wasn’t run; Retry-After says when to send it again.

Media typeapplication/json
object
error
required
object
code
required

Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).

string
message
required
string
details

Optional, kind-specific.

object
key
additional properties
any
requestId
required

Server-assigned request id; also echoed via X-Request-Id header.

string
Examplegenerated
{
"error": {
"code": "example",
"message": "example",
"details": {},
"requestId": "example"
}
}
Retry-After
integer
>= 1

Whole seconds to wait before sending the request again, at least 1. Sent with the codes the answer names as sending it, so it may be absent.

Server error (unmapped domain code or framework crash).

Media typeapplication/json
object
error
required
object
code
required

Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).

string
message
required
string
details

Optional, kind-specific.

object
key
additional properties
any
requestId
required

Server-assigned request id; also echoed via X-Request-Id header.

string
Examplegenerated
{
"error": {
"code": "example",
"message": "example",
"details": {},
"requestId": "example"
}
}

The Idempotency-Key store (idempotency-store-unavailable) or the authorization store (authz-backend-unavailable) couldn’t be reached before the request ran, or the database was too busy for its authorization check (database-busy), so nothing was changed; Retry-After (whole seconds) says when to try again with the same key. Or tenant-state-unavailable (with Retry-After), on a runtime serving many workspaces: the workspace’s state couldn’t be read, so nothing was changed.

Media typeapplication/json
object
error
required
object
code
required

Stable machine-readable discriminant. Values match domain error codes (see docs/API-ROUTE-CONVENTIONS.md §4.3).

string
message
required
string
details

Optional, kind-specific.

object
key
additional properties
any
requestId
required

Server-assigned request id; also echoed via X-Request-Id header.

string
Examplegenerated
{
"error": {
"code": "example",
"message": "example",
"details": {},
"requestId": "example"
}
}
Retry-After
integer
>= 1

Whole seconds to wait before sending the request again, at least 1. Sent with the codes the answer names as sending it, so it may be absent.

See also