Deploy and run
A playbook version is a draft until you deploy it. Deploying points an environment, dev or live, at one version. Runs follow the version deployed in the environment they run in.
Versions
Every playbook has one or more named versions, listed newest first.
| Call | What it does |
|---|---|
GET /playbooks/{uuid}/versions |
List the versions, with their drawings and notes. |
GET /playbooks/{uuid}/versions/{version} |
Read one version. |
POST /playbooks/{uuid}/versions |
Make a new version. |
PATCH /playbooks/{uuid}/versions/{version} |
Save a version's drawing. See Build a playbook. |
A new version is a copy of an existing one, so you change it without touching what is running:
POST /playbooks/{uuid}/versions
{ "from": "0.1.0", "version": "0.2.0", "note": "Added the flag step" }
| Field | Meaning |
|---|---|
from |
The version to copy. Leave out to copy the newest. A name that does not exist answers 404. |
version |
The new version's name (required). 1 to 64 characters: letters, digits, dot, underscore and dash, starting with a letter or digit. A name already used answers 409 a version with this name already exists. |
note |
Optional: what changed. |
The version running in live is read-only. Edit a copy instead.
Deploy
env is dev or live. A deploy:
- checks the version against the validation rules as the agents are now, and refuses with
422and the list of problems if there are any; - points the environment at the version and records the deploy in the playbook's history;
- answers with the playbook, whose
dev_versionandlive_versionshow what runs where (empty means not deployed there).
A version with more than 20 rules is refused. Deploying the version that already runs in that environment answers 409 workforce: version already deployed there.
Check a version without deploying it:
Dev and live
The two environments are separate: a run started in dev follows the version deployed to dev, and a run in live the version deployed to live. A common flow is to deploy to dev, run it with Run now, judge the result, and only then deploy the same version to live. The dashboard asks you to confirm a deploy.
A run keeps the version it started with, even if a newer version is deployed while it runs.
Before a deploy to live you can rerun your past corrections on the new version and read what it would do. See Check before going live.
Roll back
Rollback points the environment back at the version that was deployed there before the current one. The target is validated again, so a rollback is refused with 422 if the agents have changed so that the old version no longer passes. Rolling back twice swaps between the two versions. When nothing was deployed there before, the answer is 409 workforce: nothing to roll back to.
Rules are part of the version, so a deploy or a rollback changes the rules the environment follows with it.
Deploy history
lists every deploy and rollback, newest first. Each entry has env, version (now running), previous (what it replaced), kind (deploy or rollback), by and at. It is paged (page, limit; limit is at most 100, default 20).
Delete a playbook
DELETE /playbooks/{uuid} deletes a playbook and its versions. It is refused with 409 while:
- an assignment still uses the playbook (
workforce: playbook is used by an assignment), or - a workflow still starts it with a Run playbook step. The body then lists the workflows:
{
"message": "Workflows still start this playbook. Remove or change those steps, then delete it.",
"code": 409,
"workflows": [ { "uuid": "...", "name": "Nightly invoices", "versions": ["3", "4"] } ]
}
If Kortex cannot tell which workflows use the playbook, the answer is 503 and the playbook is not deleted: Couldn't check which workflows use this playbook. Try again.
Start a run
A run needs a target that can work:
- Every agent in it must be at work (status
active), not paused or disabled. - For a playbook, a version must be deployed in the environment you run in. Otherwise the answer is
404 not found. - The plan must include Workforce.
Run now
Start a free run of one agent, or a run of a playbook, by hand:
POST /playbooks/{uuid}/runs
{
"env": "dev",
"instructions": "Check invoice INV-2041.",
"input": { "invoice_id": "INV-2041" }
}
| Field | Meaning |
|---|---|
env |
dev or live. Required. |
instructions |
What this run should do. Required by the API. |
input |
Optional JSON data for the run to work on. The agents read it as data, not as instructions. |
The answer is 201 with the new run, status queued; the run starts at once and you read its progress (below). 409 means an agent is paused or disabled; 503 runs cannot be started right now means try again.
Starting a run needs workforce::manage.
Run again
repeats a run's target, environment, instructions and input. A playbook run follows the version deployed now, not the one the first run used; the new run records which run it repeats (rerun_of).
Assignments
An assignment is standing work: one agent, or one playbook, with instructions and a trigger. A playbook assignment follows the version deployed to the assignment's environment.
In the dashboard, a playbook's page has a Schedule panel. Add a schedule there with a name, the instructions for each run, the environment, and how it starts: by hand, every N minutes (at least 5), or on a cron. For a cron, pick the time zone its times are read in from the list; it starts at your own time zone. The panel shows each schedule's last and next run in your time zone. A new schedule is paused until you switch it on.
POST /assignments
{
"name": "Check invoices",
"playbook_uuid": "<playbook uuid>",
"env": "live",
"instructions": "Check the invoices that arrived since the last run.",
"trigger": { "kind": "schedule", "every_minutes": 60 },
"overlap": "skip"
}
| Field | Meaning |
|---|---|
name |
Required. |
agent_uuid / playbook_uuid |
Exactly one of the two. |
env |
dev or live. |
instructions |
What each run should do. A run cannot be started from an assignment without them. |
trigger |
{ "kind": "manual" } (no schedule fields), or { "kind": "schedule", ... } with exactly one of every_minutes (at least 5) or cron (five fields, no more often than every 5 minutes). timezone is an IANA name, such as Europe/Belgrade, and defaults to UTC. It applies to cron only: 0 8 * * * runs at 08:00 in that zone, and an every_minutes schedule keeps no zone. |
overlap |
What to do when the previous run is still going: skip (default), queue (run after it, at most one waiting) or allow. |
A new assignment is created paused. Switch it on with POST /assignments/{uuid}/activate and off with POST /assignments/{uuid}/pause. POST /assignments/{uuid}/run fires it right now, ignoring its schedule and its pause. PATCH /assignments/{uuid} replaces every field.
A scheduled fire starts nothing when the assignment is paused, the project is stopped, the plan has no Workforce, or an agent cannot work. Scheduled runs that find nothing to do end with the stop reason nothing_to_do, and the run list hides them unless you ask for them.
GET /assignments/{uuid}/projection and POST /assignments/projection estimate what a schedule's quiet checks cost (checks_per_day, idle_runs_30d, avg_idle_credits, projected_idle_credits_per_day) from the last 30 days.
Start a run from a workflow
The Run playbook step starts a playbook run from a workflow, then carries on at once. It does not wait for the run to finish, and the workflow never receives the run's result. If the workflow needs the answer later, it reads the run through the API (GET /runs/{uuid}). A workflow that needs an answer immediately uses the Kortex Agent Completion step instead.
| Input | Required | Meaning |
|---|---|---|
playbook_uuid |
yes | The playbook to run. |
instructions |
no | What the run should do. Supports variable substitution. When empty the run's instructions are Started by a workflow step. |
data |
no | Data for the run to work on, such as a value from an earlier step. In expression mode the value is passed as it is, for example an object. The agents read it as data, not as instructions. |
| Output | Meaning |
|---|---|
run_uuid |
The run that was started. |
status |
The run's status when the step answered, normally queued. |
playbook_uuid |
The playbook. |
The run goes to the environment the workflow itself runs in: a dev run of the workflow starts a dev run, and anything else starts a live one. The run is marked as started by a workflow, and the run's page in the dashboard has an Open in Workforce link from the workflow history.
The step is checked when it runs, against the workflow's run identity: the identity must hold workforce::manage and be allowed to use every agent in the deployed version. A Maintainer passes both.
These are the messages the step can fail with:
| Message | Status | Meaning and fix |
|---|---|---|
Pick a playbook for this step. |
400 | playbook_uuid is empty. Choose a playbook. |
run_identity is required / invalid run_identity |
400 | The workflow has no usable run identity. |
The playbook this step starts was removed. Pick another playbook. |
404 | The playbook no longer exists. |
This workflow's run identity can't run this playbook. |
403 | The identity lacks workforce::manage, or may not use one of the playbook's agents. Fix its access in Kortex access, or move the workflow to another identity. |
Workforce isn't on this project's plan. |
403 | The plan does not include Workforce. |
An agent in this playbook is paused. Put it back to work, then run the workflow again. |
409 | Activate the agent. |
An agent in this playbook is turned off. Put it to work, then run the workflow again. |
409 | The agent is disabled. Put it to work. |
This playbook has no version deployed to the environment the workflow runs in. Deploy one, then run the workflow again. |
409 | Deploy a version to dev or live, matching the workflow's environment. |
This playbook has no agent to do the work. Add one, then run the workflow again. |
409 | The deployed version has no step with an agent. |
Runs can't be started right now. Try again. |
503 | A temporary failure. Run the workflow again. |
Couldn't start the playbook run. |
500 | Any other failure. |
Read a run
| Call | What it returns |
|---|---|
GET /runs |
A page of runs, newest first. |
GET /runs/running |
The runs in flight now. |
GET /runs/stats?days=7&tz=Europe/Belgrade |
Run counts and token use over the last N days (default 7). Days are whole calendar days in tz, today included, so 7 means today and the 6 days before. tz is an IANA time zone name and defaults to UTC; an unknown name is 400. Each day in the answer is the date in that zone. |
GET /runs/{uuid} |
One run with its steps. |
GET /runs/{uuid}/steps/{index} |
One step in full. |
GET /runs filters, all optional: agent, playbook, assignment (uuids), status, env (dev or live), from and to (RFC 3339 times), idle=1 (also show runs that found nothing to do), page and limit. An unknown status is 400 invalid status.
GET /runs/{uuid}?after=<step index> returns only the steps after that index, so a client can poll a live run cheaply. Step indexes start at 1.
What a run holds
| Field | Meaning |
|---|---|
uuid, env |
The run and where it ran. |
status, stop_reason |
Where the run is, and why it ended. See below. |
summary |
What the run produced, in words. |
result |
What the last steps returned as data, keyed by step id. See The result of a run. Absent when no last step has a result schema. |
error_message |
Why a failed run failed. |
trigger_kind |
What started it: manual, schedule, chat or workflow. triggered_by names the person, when there is one. |
playbook_uuid, playbook_name, playbook_version |
For a playbook run, which version it followed. |
assignment_uuid, rerun_of |
The assignment it came from, or the run it repeats. |
instructions |
The task text the run was given. |
step_count, skill_calls, prompt_tokens, completion_tokens, credits, duration_ms |
What it cost. |
started_at, ended_at, paused_at |
Timings. |
Run statuses
| Status | Meaning |
|---|---|
queued |
Started, not picked up yet. |
running |
Working. |
awaiting_approval |
Every path that can still move is waiting for a person to approve or deny a tool call. |
awaiting_answer |
Waiting for a person to answer a question. |
paused |
Paused by a person. |
completed |
Ended. Read stop_reason to see how: the run may have finished the work, run out of a limit, or handed over to a person. |
failed |
Ended with an error; see error_message. |
killed |
Stopped by a person. |
expired |
Ended because nobody decided an approval or answered a question in time. The stop reason is approval_expired. |
Only the statuses above are produced today. The API also accepts timeout as a filter value, but a run that runs out of time ends completed with the stop reason budget_time.
Stop reasons
stop_reason |
Meaning |
|---|---|
completed |
The agent finished the work. |
nothing_to_do |
The agent checked and found nothing to do. Hidden from the run list by default. |
escalated |
The agent handed the work to a person and ended the run. |
budget_steps, budget_tokens, budget_time, budget_skill_calls, budget_credits |
A limit was reached. See Limits. |
budget_runs |
The agent reached its daily limit of runs. |
auto_paused |
The platform paused the agent: a run spent more than its share of the daily credit budget, or the agent was already paused automatically. The run is completed. See Trust and limits. |
approval_expired |
Nobody decided a waiting approval or answered a question in time; the run was closed. The run is expired. |
killed |
A person killed the run, or paused the agent it was waiting to use. The run is killed. |
rule_failed |
A rule could not be checked against the run's input, for example a field it reads is missing. The run is failed. See When a rule fails. |
result_invalid |
The agent did not return the result in the shape the playbook asks for. The run is failed. See The result of a run. |
error |
Something went wrong. |
The result of a run
When a last step of the playbook has a result schema, the run carries result: an object keyed by the id of each last step that returned data.
{
"uuid": "…",
"status": "completed",
"summary": "Answered the ticket.",
"result": { "reply": { "priority": "high", "text": "hello" } }
}
resultis absent when no last step has a schema.- The prose
summaryis unchanged and is still written. - A run that stops early on a limit still carries the values already returned.
- If the agent cannot return JSON that matches the schema after one retry, the run ends
failedwith the stop reasonresult_invalid, and that step has no entry inresult. - The Run playbook workflow step does not wait, so a workflow does not receive
result. Read the run later, or use the Kortex Agent Completion step when the workflow needs an answer straight away.
What the agent is told about its last work
Each run starts with one line saying when the agent last worked on the same task, so a scheduled job can pick up where it left off. The dashboard shows it on the run page as Last worked, and the API as snapshot.last_worked.
| Case | The line |
|---|---|
| Nothing ran before | This is your first run., or This is the first time you work on this assignment. |
| An earlier run ended | You last worked on Monday 2026-11-16, 09:00 to 09:12 (Europe/Belgrade). That run ended: completed. |
The earlier run is the last one that ended in the same environment for the same assignment. A run without an assignment is matched by agent, or by playbook. Times are in the assignment's time zone, or UTC without one. The line is fixed when the run first starts.
Steps
A step is one thing the run did. kind says what:
kind |
Meaning |
|---|---|
think |
The agent reasoned and chose what to do next. Its input records the feedback_given and rules_given it was handed; see What a run records. |
retrieve |
The agent read from a knowledge base. |
skill |
The agent called a tool. |
approval |
A tool call that needed a person's approval. |
question |
A question the agent asked a person. |
condition |
A condition chose a path. |
rule |
A condition that decides by rules chose a path. Its output lists each rule, what it gave and the lines followed. |
finish |
A step ended with its summary. |
Each step has an index, a status (pending, running, completed, failed, denied, skipped), node_id (the playbook step it belongs to), name and label, input and output, error, timings, retries, token use, and, when a person was involved, an approval block (see People in the loop). Very large inputs and outputs are cut down in the run view; GET /runs/{uuid}/steps/{index} returns the full step.
Feedback on a playbook or an assignment
Judgements of a playbook's runs are read for the playbook, and an assignment's for the assignment:
GET /playbooks/{uuid}/feedback/summaryandGET /assignments/{uuid}/feedback/summarycount good and bad judgements per step, with the commonest categories and the tools that went wrong most.GET /playbooks/{uuid}/feedback?node=<step id>&limit=andGET /assignments/{uuid}/feedback?limit=list the judgements, newest first.
Make a judgement a rule with POST /feedback/{uuid}/promote: into a version of the playbook (or a new fork of one), or onto the assignment. Each answers 201. Promoting into the version that runs in Live is refused: fork a new version. See Feedback and rules.
An assignment that runs no playbook can hold its own rules (at most 20), set with PATCH /assignments/{uuid}. One that runs a playbook cannot: put the rules on the playbook.
Control a run
All need workforce::manage and answer 204.
| Call | What it does |
|---|---|
POST /runs/{uuid}/pause |
Pause. Nothing further starts until it is resumed. A run paused for 7 days is closed. |
POST /runs/{uuid}/resume |
Resume a paused run. 409 workforce: run is not paused otherwise. |
POST /runs/{uuid}/kill |
Kill. The step in progress finishes, nothing further starts, and the run ends killed. A killed run cannot be resumed. |
POST /workforce/stop-all |
Stop everything: pause every agent and every run in the project. Answers { "paused_agents": n, "paused_runs": n }. |
POST /workforce/release-all |
Lift stop-everything. Agents and runs stay paused until you activate and resume them. |
GET /workforce/controls |
{ "stopped": true|false }. |
While stop-everything is on, a paused run cannot be resumed (409 workforce: project is stopped) and scheduled runs are skipped. Release it first. Pausing, resuming or killing a run that has already ended answers 409 workforce: run has ended.