Appearance
Runs
Run an agent
http
POST /v1/agents/{slug}/runsScope: agents:run. Runs the agent's current published version (or the pinned version).
Path parameters
| Name | Description |
|---|---|
slug | the agent's slug |
Headers
| Name | Description |
|---|---|
Idempotency-Key | optional, 1 to 200 characters; see Idempotency |
Body (RunRequest)
| Field | Type | Description |
|---|---|---|
input | object | the agent's input; validated against its inputSchema. Conversational agents need input.message |
files | string[] (≤ 20) | ids of uploaded files (POST /v1/files); not for workflow agents |
version | integer | run this published version number instead of the current one |
stream | boolean | answer with Server-Sent Events |
async | boolean | queue the run and answer 202 at once; not with stream |
externalUserId | string (1–200) | your end user's id, stored on the run and its usage |
metadata | object | free-form data stored on the run |
conversationId | uuid | conversational agents: continue this conversation |
Responses
| Status | Body |
|---|---|
200 | RunResult; also for runs that failed during execution (status: "failed", error), and for idempotent replays |
200 | text/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
| Status | Code | When |
|---|---|---|
| 400 | VALIDATION_FAILED | the body or Idempotency-Key is malformed |
| 400 | INPUT_INVALID | input does not match the input schema (fields lists why) |
| 400 | INPUT_TOO_LONG, INPUT_REJECTED, INPUT_LANGUAGE_NOT_ALLOWED | guardrails |
| 400 | ASYNC_STREAM_CONFLICT | async and stream together |
| 400 | FILE_TYPE_NOT_ACCEPTED, FILE_TOO_MANY_PAGES | a file violates the agent's files settings |
| 400 | AGENT_TYPE_NOT_SUPPORTED_YET | the agent type cannot be run here (realtime agents) |
| 400 | MODEL_UNAVAILABLE | the agent's model is not enabled |
| 402 | QUOTA_EXCEEDED | monthly spend cap reached |
| 403 | AGENT_NOT_ALLOWED | the key is restricted to other agents |
| 404 | NOT_FOUND | no agent with this slug in the project |
| 404 | VERSION_NOT_FOUND, FILE_NOT_FOUND, CONVERSATION_NOT_FOUND | |
| 409 | AGENT_NOT_PUBLISHED | the agent has no published version |
| 409 | IDEMPOTENCY_IN_PROGRESS, IDEMPOTENCY_KEY_REUSED | see Idempotency |
| 413 | FILE_TOO_LARGE | a file is larger than the agent's maxSizeMb |
RunResult
| Field | Type | Description |
|---|---|---|
runId | uuid | |
status | succeeded | failed | cancelled | … | run status |
output | any | parsed JSON when the agent has an outputSchema, else { text }; null when failed |
usage | {inputTokens, outputTokens, priceMicros} | includes the usage of child runs |
latencyMs | number | null | |
conversationId | uuid | conversational 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": []
}| Field | Description |
|---|---|
agent | {id, slug, name} |
versionNumber | the published version that ran (null for console drafts) |
source | api, playground, agent (agent-as-tool child), workflow (workflow node child) |
status | queued, running, waiting, succeeded, failed, cancelled |
parentRunId | the 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?}]}] |
flags | guardrail flags such as prompt_injection |
children | direct child runs (summaries) |
nodes | workflow runs only: the node runs (WorkflowNodeRun) |
workflow | workflow 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}/stepsScope: 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}/cancelScope: agents:run. No body.
- A
queuedrun is cancelled at once:{runId, status: "cancelled", cancelRequested: false}. - A
runningrun gets a cancel request and stops cooperatively;statusstaysrunninguntil it does:{runId, status: "running", cancelRequested: true}. - A workflow run (
queued,runningorwaiting) 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.