Skip to content

Runs ​

Run an agent ​

http
POST /v1/agents/{slug}/runs

Scope: agents:run. Runs the agent's current published version (or the pinned version).

Path parameters ​

NameDescription
slugthe agent's slug

Headers ​

NameDescription
Idempotency-Keyoptional, 1 to 200 characters; see Idempotency

Body (RunRequest) ​

FieldTypeDescription
inputobjectthe agent's input; validated against its inputSchema. Conversational agents need input.message
filesstring[] (≤ 20)ids of uploaded files (POST /v1/files); not for workflow agents
versionintegerrun this published version number instead of the current one
streambooleananswer with Server-Sent Events
asyncbooleanqueue the run and answer 202 at once; not with stream
externalUserIdstring (1–200)your end user's id, stored on the run and its usage
metadataobjectfree-form data stored on the run
conversationIduuidconversational agents: continue this conversation

Responses ​

StatusBody
200RunResult; also for runs that failed during execution (status: "failed", error), and for idempotent replays
200text/event-stream when stream: true (events)
202{runId, status: "queued"} for async: true; workflow runs still running or waiting after the sync wait (60 s by default)
bash
curl "$HEVKAR_BASE_URL/v1/agents/support-triage/runs" \
  -H "Authorization: Bearer $HEVKAR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"input": {"message": "My invoice is wrong"}, "externalUserId": "user_42"}'
ts
const result = await hevkar.agents.run('support-triage', {
  input: { message: 'My invoice is wrong' },
  externalUserId: 'user_42',
});
// streaming: hevkar.agents.stream(slug, params) · async: hevkar.agents.runAsync(slug, params)
ts
const result = await fetch(`${baseUrl}/v1/agents/support-triage/runs`, {
  method: 'POST',
  headers: { Authorization: `Bearer ${apiKey}`, 'Content-Type': 'application/json' },
  body: JSON.stringify({ input: { message: 'My invoice is wrong' }, externalUserId: 'user_42' }),
}).then((r) => r.json());
json
{
  "runId": "4f0f7c1e-2b5a-4d0e-9a51-7a3c1f2d9e10",
  "status": "succeeded",
  "output": { "text": "I'm sorry about that. Could you send me the invoice number?" },
  "usage": { "inputTokens": 512, "outputTokens": 38, "priceMicros": 180 },
  "latencyMs": 1210,
  "conversationId": "c3a1…"
}

Errors ​

StatusCodeWhen
400VALIDATION_FAILEDthe body or Idempotency-Key is malformed
400INPUT_INVALIDinput does not match the input schema (fields lists why)
400INPUT_TOO_LONG, INPUT_REJECTED, INPUT_LANGUAGE_NOT_ALLOWEDguardrails
400ASYNC_STREAM_CONFLICTasync and stream together
400FILE_TYPE_NOT_ACCEPTED, FILE_TOO_MANY_PAGESa file violates the agent's files settings
400AGENT_TYPE_NOT_SUPPORTED_YETthe agent type cannot be run here (realtime agents)
400MODEL_UNAVAILABLEthe agent's model is not enabled
402QUOTA_EXCEEDEDmonthly spend cap reached
403AGENT_NOT_ALLOWEDthe key is restricted to other agents
404NOT_FOUNDno agent with this slug in the project
404VERSION_NOT_FOUND, FILE_NOT_FOUND, CONVERSATION_NOT_FOUND
409AGENT_NOT_PUBLISHEDthe agent has no published version
409IDEMPOTENCY_IN_PROGRESS, IDEMPOTENCY_KEY_REUSEDsee Idempotency
413FILE_TOO_LARGEa file is larger than the agent's maxSizeMb

RunResult ​

FieldTypeDescription
runIduuid
statussucceeded | failed | cancelled | …run status
outputanyparsed JSON when the agent has an outputSchema, else { text }; null when failed
usage{inputTokens, outputTokens, priceMicros}includes the usage of child runs
latencyMsnumber | null
conversationIduuidconversational agents only
error{code, message}when the run failed or was cancelled

Get a run ​

http
GET /v1/runs/{id}

Scope: runs:read. Returns the RunDetail. Poll this for async runs.

json
{
  "id": "4f0f7c1e-2b5a-4d0e-9a51-7a3c1f2d9e10",
  "agent": { "id": "…", "slug": "invoice-extractor", "name": "Invoice extractor" },
  "agentVersionId": "…",
  "versionNumber": 3,
  "source": "api",
  "status": "succeeded",
  "apiKeyId": "…",
  "externalUserId": "user_42",
  "conversationId": null,
  "parentRunId": null,
  "usage": { "inputTokens": 1830, "outputTokens": 120, "priceMicros": 1210 },
  "latencyMs": 8420,
  "error": null,
  "createdAt": "2026-11-21T10:15:00.000Z",
  "finishedAt": "2026-11-21T10:15:08.420Z",
  "input": { "language": "de" },
  "output": { "invoiceNumber": "RE-2026-118", "total": 249.9, "currency": "EUR" },
  "toolCalls": [],
  "files": [
    {
      "id": "…",
      "name": "invoice.pdf",
      "mimeType": "application/pdf",
      "size": 48213,
      "pages": 2,
      "strategy": "vision"
    }
  ],
  "retrieval": [],
  "metadata": { "orderId": "A-1001" },
  "flags": [],
  "children": []
}
FieldDescription
agent{id, slug, name}
versionNumberthe published version that ran (null for console drafts)
sourceapi, playground, agent (agent-as-tool child), workflow (workflow node child)
statusqueued, running, waiting, succeeded, failed, cancelled
parentRunIdthe calling run for child runs
toolCalls[{name, args, ok, result?, error?}]
files[{id, name, mimeType, size, pages, strategy: "vision" | "ocr"}]
retrieval[{query, chunks: [{chunkId, documentId, dataSourceId, score, similarity, text?, documentTitle?, dataSourceName?}]}]
flagsguardrail flags such as prompt_injection
childrendirect child runs (summaries)
nodesworkflow runs only: the node runs (WorkflowNodeRun)
workflowworkflow runs only: the graph {nodes, edges, vars?} the run executes, frozen when it started

Inputs and outputs are deleted after the project's retention period.

Errors: 404 NOT_FOUND, 403 AGENT_NOT_ALLOWED (the key is restricted to other agents).

Get run steps ​

http
GET /v1/runs/{id}/steps

Scope: runs:read. Child runs and, for workflow runs, node runs and pauses:

jsonc
{
  "children": [/* run summaries */],
  "nodes": [/* WorkflowNodeRun, ordered by start; empty for non-workflow runs */],
  "waits": [/* WorkflowWait */],
}

See Workflow runs for the node and wait shapes.

Cancel a run ​

http
POST /v1/runs/{id}/cancel

Scope: agents:run. No body.

  • A queued run is cancelled at once: {runId, status: "cancelled", cancelRequested: false}.
  • A running run gets a cancel request and stops cooperatively; status stays running until it does: {runId, status: "running", cancelRequested: true}.
  • A workflow run (queued, running or waiting) is cancelled at once with its steps, waits and child runs.
ts
await hevkar.runs.cancel(runId);

Errors: 409 RUN_NOT_CANCELLABLE (the run already finished), 404 NOT_FOUND.

Hevkar public API v1