# Runtime API

> Start a flow's run over HTTP, follow it and download what it made, manage the workspace's API keys and budget, and read and write its configuration.

Source: https://docs.go-lumen.ai/reference/api/runtime

**Authentication.** Bearer token: an OIDC access token or a workspace API key (`Authorization: Bearer lmn_...`). Access is checked against the caller's role in the workspace. A route that differs says so under its heading.

Paths are relative to the API host. `{ns}` is the workspace namespace, `tenant-<workspace>`.

## Routes

| Method | Path | What it does |
| --- | --- | --- |
| ANY | [`/apis/lumen.ai/v1alpha1/namespaces/{ns}/{resource}`](#any-apis-lumen-ai-v1alpha1-namespaces-ns-resource) | This route reads and writes the workspace's configuration resources (flows, connectors, sheets, forms and the others in the Resources reference) over HTTP, the way kubectl does: list and create at the collection, get, replace, patch and delete at a name. |
| ANY | [`/apis/lumen.ai/v1alpha1/namespaces/{ns}/{resource}/{name}`](#any-apis-lumen-ai-v1alpha1-namespaces-ns-resource-name) | This route reads and writes the workspace's configuration resources (flows, connectors, sheets, forms and the others in the Resources reference) over HTTP, the way kubectl does: list and create at the collection, get, replace, patch and delete at a name. |
| GET | [`/apis/runtime.lumen.ai/v1alpha1/namespaces/{ns}/apikeys`](#get-apis-runtime-lumen-ai-v1alpha1-namespaces-ns-apikeys) | This route lists the workspace's API keys: each key's id, name, scopes, expiry and last use, never its secret. |
| POST | [`/apis/runtime.lumen.ai/v1alpha1/namespaces/{ns}/apikeys`](#post-apis-runtime-lumen-ai-v1alpha1-namespaces-ns-apikeys) | This route creates an API key with a name, scopes, an expiry and, optionally, the flows it may start. |
| DELETE | [`/apis/runtime.lumen.ai/v1alpha1/namespaces/{ns}/apikeys/{id}`](#delete-apis-runtime-lumen-ai-v1alpha1-namespaces-ns-apikeys-id) | This route revokes an API key by its id. |
| GET | [`/apis/runtime.lumen.ai/v1alpha1/namespaces/{ns}/budget`](#get-apis-runtime-lumen-ai-v1alpha1-namespaces-ns-budget) | This route reads the workspace's monthly credit budget and what has been used of it this month. |
| PUT | [`/apis/runtime.lumen.ai/v1alpha1/namespaces/{ns}/budget`](#put-apis-runtime-lumen-ai-v1alpha1-namespaces-ns-budget) | This route sets the workspace's monthly credit budget, a decimal number of credits. |
| GET | [`/apis/runtime.lumen.ai/v1alpha1/namespaces/{ns}/runs`](#get-apis-runtime-lumen-ai-v1alpha1-namespaces-ns-runs) | This route lists the workspace's runs, newest first. |
| POST | [`/apis/runtime.lumen.ai/v1alpha1/namespaces/{ns}/runs`](#post-apis-runtime-lumen-ai-v1alpha1-namespaces-ns-runs) | This route starts a run of a flow that has a manual trigger. |
| GET | [`/apis/runtime.lumen.ai/v1alpha1/namespaces/{ns}/runs/{name}`](#get-apis-runtime-lumen-ai-v1alpha1-namespaces-ns-runs-name) | This route reads one run: its phase, the outcome and timing of each step, the values the flow produced, the credits it used and the files it ended with. |
| GET | [`/apis/runtime.lumen.ai/v1alpha1/namespaces/{ns}/runs/{name}/files/{file}`](#get-apis-runtime-lumen-ai-v1alpha1-namespaces-ns-runs-name-files-file) | This route answers with a short-lived download link for one of a run's output files. |
| GET | [`/apis/runtime.lumen.ai/v1alpha1/namespaces/{ns}/toolapprovals`](#get-apis-runtime-lumen-ai-v1alpha1-namespaces-ns-toolapprovals) | This route lists the workspace's tool calls waiting for a person, or decided by one, newest first: phase (Pending, Approved, Rejected, Expired, Cancelled) and run filter them, limit bounds them (100 by default, 500 at most). |
| GET | [`/apis/runtime.lumen.ai/v1alpha1/namespaces/{ns}/toolapprovals/{name}`](#get-apis-runtime-lumen-ai-v1alpha1-namespaces-ns-toolapprovals-name) | This route reads one tool approval. |
| POST | [`/apis/runtime.lumen.ai/v1alpha1/namespaces/{ns}/toolapprovals/{name}`](#post-apis-runtime-lumen-ai-v1alpha1-namespaces-ns-toolapprovals-name) | This route answers POST toolapprovals/`{id}`:approve and :reject, with an optional note ({"note": "..."}): approve runs exactly the call that waits, reject tells the agent (or fails the step) with the note. |
| GET | [`/apis/runtime.lumen.ai/v1alpha1/whoami`](#get-apis-runtime-lumen-ai-v1alpha1-whoami) | This route says who the token belongs to: the user or key, the workspace namespace, the role and the scopes. |

## Route details

#### `ANY /apis/lumen.ai/v1alpha1/namespaces/{ns}/{resource}`

This route reads and writes the workspace's configuration resources (flows, connectors, sheets, forms and the others in the Resources reference) over HTTP, the way kubectl does: list and create at the collection, get, replace, patch and delete at a name. Bodies are the YAML manifests as JSON.

#### `ANY /apis/lumen.ai/v1alpha1/namespaces/{ns}/{resource}/{name}`

This route reads and writes the workspace's configuration resources (flows, connectors, sheets, forms and the others in the Resources reference) over HTTP, the way kubectl does: list and create at the collection, get, replace, patch and delete at a name. Bodies are the YAML manifests as JSON.

#### `GET /apis/runtime.lumen.ai/v1alpha1/namespaces/{ns}/apikeys`

This route lists the workspace's API keys: each key's id, name, scopes, expiry and last use, never its secret. A workspace administrator calls it.

#### `POST /apis/runtime.lumen.ai/v1alpha1/namespaces/{ns}/apikeys`

This route creates an API key with a name, scopes, an expiry and, optionally, the flows it may start. The answer carries the key itself, once: store it right away, it cannot be read again. A workspace administrator calls it.

#### `DELETE /apis/runtime.lumen.ai/v1alpha1/namespaces/{ns}/apikeys/{id}`

This route revokes an API key by its id. The key stops working at once. A workspace administrator calls it.

#### `GET /apis/runtime.lumen.ai/v1alpha1/namespaces/{ns}/budget`

This route reads the workspace's monthly credit budget and what has been used of it this month.

#### `PUT /apis/runtime.lumen.ai/v1alpha1/namespaces/{ns}/budget`

This route sets the workspace's monthly credit budget, a decimal number of credits. An empty value removes the budget. A workspace administrator calls it.

#### `GET /apis/runtime.lumen.ai/v1alpha1/namespaces/{ns}/runs`

This route lists the workspace's runs, newest first. Filter with flow, phase (one or more, comma separated), since and until; sort with sort; page with limit and continue. With watch=true the connection stays open and answers one JSON line per change.

#### `POST /apis/runtime.lumen.ai/v1alpha1/namespaces/{ns}/runs`

This route starts a run of a flow that has a manual trigger. The body names the flow in spec.flow and may send files in spec.inputs, each with a name, a content type and its bytes in base64. The answer is the queued run. A run is subject to the same budgets and credit limits as a run started by any trigger.

#### `GET /apis/runtime.lumen.ai/v1alpha1/namespaces/{ns}/runs/{name}`

This route reads one run: its phase, the outcome and timing of each step, the values the flow produced, the credits it used and the files it ended with.

#### `GET /apis/runtime.lumen.ai/v1alpha1/namespaces/{ns}/runs/{name}/files/{file}`

This route answers with a short-lived download link for one of a run's output files. Reading a run is enough to download what it made.

#### `GET /apis/runtime.lumen.ai/v1alpha1/namespaces/{ns}/toolapprovals`

This route lists the workspace's tool calls waiting for a person, or decided by one, newest first: phase (Pending, Approved, Rejected, Expired, Cancelled) and run filter them, limit bounds them (100 by default, 500 at most). Anyone who may read the workspace's runs may read them.

#### `GET /apis/runtime.lumen.ai/v1alpha1/namespaces/{ns}/toolapprovals/{name}`

This route reads one tool approval.

#### `POST /apis/runtime.lumen.ai/v1alpha1/namespaces/{ns}/toolapprovals/{name}`

This route answers POST toolapprovals/`{id}`:approve and :reject, with an optional note ({"note": "..."}): approve runs exactly the call that waits, reject tells the agent (or fails the step) with the note. Only a workspace admin decides; an approval that is no longer pending (decided, expired, or its run ended) answers 409.

#### `GET /apis/runtime.lumen.ai/v1alpha1/whoami`

This route says who the token belongs to: the user or key, the workspace namespace, the role and the scopes. Use it to find the namespace of a key.
