Runtime API
The runtime API is how your own code uses a workspace: start a flow with a manual trigger, send it files, read the run while it works, and download the files it produced. It is plain HTTP and JSON, signed with an API key.
This page is the how-to. The routes this page uses, with the API key and budget routes, are listed in the Runtime API reference.
The basics
| Base URL | https://api.go-lumen.ai |
| Runs | /apis/runtime.lumen.ai/v1alpha1/namespaces/{workspace-namespace}/runs |
| Sign in | Authorization: Bearer lmn_..., an API key |
| Bodies | JSON, Content-Type: application/json |
Your workspace's namespace is tenant- followed by the workspace name, for example tenant-acme. Ask the API which one a key belongs to, and keep the answer:
export LUMEN_API=https://api.go-lumen.ai
export LUMEN_TOKEN=lmn_eu_... # your API key
curl "$LUMEN_API/apis/runtime.lumen.ai/v1alpha1/whoami" \
-H "Authorization: Bearer $LUMEN_TOKEN"
{
"kind": "Whoami",
"user": "apikey:k7Hq2Pz9aB3c (CI deploy)",
"namespace": "tenant-acme",
"role": "apikey",
"scope": "run",
"scopes": ["run"]
}
export NS=tenant-acme
export RUNS="$LUMEN_API/apis/runtime.lumen.ai/v1alpha1/namespaces/$NS/runs"
The key needs the Run scope to start runs. To read runs the key did not start, or to list them, it also needs Read. A key is tied to one region: sent to another region's API it is answered 421 Misdirected Request with the right address.
Start a run
A run starts a flow through its I press Run trigger, the one with the reference manual-run. That is what the Run button in the console and lumen run do. A flow without that trigger cannot be started this way.
curl -X POST "$RUNS" \
-H "Authorization: Bearer $LUMEN_TOKEN" \
-H "Content-Type: application/json" \
-d '{"spec": {"flow": "invoices"}}'
The answer is 201 Created with the run as it was queued:
{
"apiVersion": "runtime.lumen.ai/v1alpha1",
"kind": "Run",
"metadata": {
"name": "7c1f0a5e-3b52-4d6e-9a41-0b2c7e8d1f34",
"namespace": "tenant-acme"
},
"spec": {"flow": "invoices", "trigger": "manual"},
"status": {"phase": "Queued", "documents": 1}
}
metadata.name is the run's id. When the flow has more than one I press Run trigger, name the one to use in spec.trigger. A run costs what a run started by any trigger costs, and it is subject to the same budgets and credit limits.
Send files with the run
A flow that takes files reads them from spec.inputs. Each input has a name, a contentType (guessed from the file name when you leave it out) and data, the file's bytes in base64. All the inputs of one request are one document, as the attachments of one email are.
curl -X POST "$RUNS" \
-H "Authorization: Bearer $LUMEN_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"spec": {
"flow": "invoices",
"inputs": [
{"name": "march.pdf", "contentType": "application/pdf", "data": "'"$(base64 < march.pdf | tr -d '\n')"'"}
]
}
}'
The whole request may be up to 32 MiB, base64 included. Lumen checks the files against the flow:
| Situation | Answer |
|---|---|
| The flow's first step needs files and you sent none | 422, "needs at least one file in spec.inputs" |
| The flow takes no files and you sent some | 422, "takes no files" |
| The flow does not exist | 404 |
| The flow is switched off | 409, "is suspended" |
| The flow is not finished, or a step needs a setting that is missing | 422 with the reason in message |
| The flow already has a run queued or running | 409, "already has a run in flight". Wait for it to finish. |
| The key is limited to other flows | 403 |
Errors are a JSON status object: {"kind": "Status", "code": 422, "reason": "Invalid", "message": "..."}.
Do not send the same run twice
Starting a run is not idempotent: a retry after a timeout can start a second run. The flow's rule that only one run may be in flight at a time protects you in the usual case, since the retry is answered 409. Check the flow's runs before you retry (see List runs).
Read a run
curl "$RUNS/7c1f0a5e-3b52-4d6e-9a41-0b2c7e8d1f34" \
-H "Authorization: Bearer $LUMEN_TOKEN"
Poll until status.phase is one of the end states.
| Phase | Meaning |
|---|---|
Queued | Accepted, waiting for a worker. |
Running | Steps are running. |
Waiting | Paused for a person's approval of an agent's tool call. status.waitingFor is approval. It goes on when an admin decides, and the wait does not count against run time limits. |
Held | Waiting for a budget or credits. status.heldReason and status.heldMessage say why. It starts by itself when the reason clears. |
Succeeded | Finished. |
Failed | A step failed. status.message and status.failedNode say which and why. |
Cancelled | Stopped by a person or a key. |
The run also carries:
| Field | What it holds |
|---|---|
status.queuedAt, startedAt, finishedAt | Times, RFC 3339. |
status.credits | What the run used, as a decimal string, such as "2.5". |
status.steps[] | Each step's node, outcome, message and times. |
status.fields | The values the flow produced, as text. |
status.outputs[] | The files the run ended with: name, contentType, size. |
A key with only the Run scope reads the runs it started itself. Any other run of the workspace answers 404.
Download an output file
Ask for a file by the name in status.outputs. The answer holds a short-lived link:
curl "$RUNS/7c1f0a5e-3b52-4d6e-9a41-0b2c7e8d1f34/files/2026-03-04%20from%20supplier.example.pdf" \
-H "Authorization: Bearer $LUMEN_TOKEN"
{
"kind": "RunFile",
"name": "2026-03-04 from supplier.example.pdf",
"contentType": "application/pdf",
"size": 182044,
"url": "https://...",
"expiresAt": "2026-03-04T10:15:00Z"
}
The link works for 15 minutes and needs no key. Fetch it right away, with curl -O "$URL". A file that Lumen no longer keeps answers 410 Gone.
List runs
With the Read scope:
curl "$RUNS?flow=invoices&phase=Failed,Running&limit=20" \
-H "Authorization: Bearer $LUMEN_TOKEN"
| Query | Meaning |
|---|---|
flow | Only this flow's runs. |
phase | One or more phases, comma separated: Queued, Running, Waiting, Held, Succeeded, Failed, Cancelled. |
since, until | RFC 3339 times. |
sort | started, duration or credits; a leading - sorts descending. |
limit | 1 to 500, default 100. |
continue | The metadata.continue of the previous page. |
Add watch=true to hold the connection open and receive one JSON line per change, {"type": "ADDED" | "MODIFIED", "object": {...}}, as runs start and steps finish.
Cancel a run
A key with the Admin scope, or a workspace admin, can stop a run that has not ended:
curl -X POST "$RUNS/7c1f0a5e-3b52-4d6e-9a41-0b2c7e8d1f34:cancel" \
-H "Authorization: Bearer $LUMEN_TOKEN"
Approvals of tool calls
A run in the Waiting phase is paused for an approval. Its requests are listed at toolapprovals, newest first:
APPROVALS="$LUMEN_API/apis/runtime.lumen.ai/v1alpha1/namespaces/$NS/toolapprovals"
curl "$APPROVALS?phase=Pending&run=7c1f0a5e-3b52-4d6e-9a41-0b2c7e8d1f34" \
-H "Authorization: Bearer $LUMEN_TOKEN"
phase (Pending, Approved, Rejected, Expired or Cancelled), run and limit are optional. Each item has the tool, the connection for an MCP tool, who asked, the reason, the arguments (credential-like values are [redacted]), when it expires and, once decided, who decided and the note. Read one with GET $APPROVALS/{id}.
A workspace admin decides with :approve or :reject and an optional note of up to 500 characters:
curl -X POST "$APPROVALS/ta-4f9k2:approve" \
-H "Authorization: Bearer $LUMEN_TOKEN" \
-H "Content-Type: application/json" \
-d '{"note": "Ann is the right contact"}'
The answer is the updated request. A person who is not an admin gets 403, an unknown id 404, and a request that is no longer pending (decided, expired, or its run ended) 409. See Approve an agent's tool call.
A complete script
Start a run on a file, wait for it, and print the link to its first output:
#!/bin/sh
set -eu
RUN=$(curl -sf -X POST "$RUNS" \
-H "Authorization: Bearer $LUMEN_TOKEN" -H "Content-Type: application/json" \
-d '{"spec":{"flow":"invoices","inputs":[{"name":"march.pdf","data":"'"$(base64 < march.pdf | tr -d '\n')"'"}]}}' \
| jq -r .metadata.name)
while :; do
STATUS=$(curl -sf "$RUNS/$RUN" -H "Authorization: Bearer $LUMEN_TOKEN")
case $(echo "$STATUS" | jq -r .status.phase) in
Succeeded) break ;;
Failed|Cancelled) echo "$STATUS" | jq -r .status.message >&2; exit 1 ;;
esac
sleep 2
done
NAME=$(echo "$STATUS" | jq -r '.status.outputs[0].name')
curl -sf -G "$RUNS/$RUN/files/$(printf %s "$NAME" | jq -sRr @uri)" \
-H "Authorization: Bearer $LUMEN_TOKEN" | jq -r .url
The CLI does the same in one line: lumen run invoices -f march.pdf --wait. See Install the CLI.