Skip to Content
Topics

Workflows (beta)

View as Markdown

A workflow is automation in Kenso: one trigger, a list of steps and limits. With the CLI you keep a workflow as a JSON file in your folder or repo: write it, check it, push it to the draft, test the draft, publish the version you tested, and run it on records with a credit cap and a results file.

The commands are beta: they show where your workspace has the workflows feature. Help hides them until your workspace has it; kenso --help --all-commands shows them. kenso workflows test and kenso workflows run also need workflows_runtime. Without it test stops with runtime_off (exit 4), "Workflows cannot run in this workspace yet.", with no retry, and a run that kenso workflows run starts stays queued, which --wait reports at its timeout.

CommandWhat it does
workflows init [name]Write a new workflow file, blank or from a template, and a kenso.json
workflows pull <workflowId>Write a saved workflow's definition to a file and bind the file
workflows check <file>Validate the file and estimate one record; saves nothing
workflows push <file>Create the workflow or save the file to its draft; with --publish, publish it
workflows test <file>Run the saved draft once on one record
workflows diff <file>Compare the file with the published version or the draft
workflows schemaPrint a JSON Schema for workflow files, for editors
workflows run <file or id>Run the published workflow on ids or a CSV, estimate first
workflow-runs logs <runId>One row per step of a run: status, credits, error

The other workflow commands are generated from the API, one per route: kenso workflows publish, unpublish, get and list, kenso workflow-versions, kenso workflow-runs list, get, cancel, restart, retry and replay, kenso workflow-templates and kenso workflow-step-types. kenso <command> --help shows their flags.

The file

A workflow file is one JSON object in the kenWorkflow: "1" format, named <name>.workflow.json:

JSON
{
  "kenWorkflow": "1",
  "name": "Qualify accounts",
  "description": "Scores each account against a simple ICP.",
  "trigger": { "type": "trigger.manual@1", "with": { "recordType": "account" } },
  "steps": [
    { "id": "qualify", "type": "ai.qualify@1", "with": { "criteria": "B2B SaaS, 50+ people", "tier": "cheap" } }
  ],
  "limits": { "creditsPerMonth": 100, "creditsPerRun": 5, "runsPerDay": 50, "atLimit": "ask" }
}

The format (trigger, steps, references, formulas, limits) is the workflows skill's references/definition-format.md. kenso workflows schema prints a JSON Schema (draft 2020-12) of the file with each step type's inputs, for an editor, offline; the server's validate stays the authority. kenso workflow-step-types get prints one step type's inputs and an example.

Terminal
kenso workflows schema --out workflow.schema.json
kenso workflow-step-types get --type ai.qualify@1
kenso mcp call load_skill --args '{"name":"workflows","reference":"references/definition-format.md"}'

kenso.json

kenso.json binds workflow files to workflow ids and pins the folder's workspace. init, pull and push write it; you rarely edit it by hand.

JSON
{
  "workspaceId": "3047",
  "profile": "client-a",
  "workflows": { "workflows/qualify.workflow.json": 412 }
}
  • All three keys are optional. workspaceId is a string of digits. profile is a profile name. workflows maps a path relative to kenso.json (forward slashes) to a workflow id. One file holds one workflow and one workflow is bound to one file: binding a second is already_bound (exit 7). Other keys are kept when the CLI rewrites the file.
  • The CLI looks for it from the current folder up to the first folder that holds .git, else up to your home folder, never above it; for a command given a file, from that file's folder. It skips a kenso.json another user owns, or that anyone can write or sits in a folder anyone can write (such as /tmp): another user could have put it there to pick your workspace. A skipped file is named on stderr, and init, pull, push or run on a workflow file beside it stops with folder_file_untrusted (exit 2) instead of reading or writing over its bindings. Some mounts show every file as anyone's to write (WSL /mnt/c, SMB, exFAT): keep workflow files on a Linux folder there.
  • The workspace is --workspace, else KENSO_WORKSPACE_ID, else kenso.json, else the profile's. The profile is --profile, else KENSO_PROFILE, else kenso.json, else the active profile. kenso.json never changes the API URL or the key.
  • A file command run in another workspace than the one kenso.json names stops with workspace_mismatch (exit 2): its workflow ids belong to that workspace.
  • It never holds a key or an API URL. A file with apiKey, key, token, a value starting with kenso_, or apiUrl is folder_file_invalid (exit 2), "kenso.json never holds a key or an API URL: remove <name>.", and nothing reads it. Invalid JSON, or a key of the wrong type, is the same error with the path and the key.
  • kenso whoami and kenso auth status print workspaceSource (flag, env, folder, profile or none) and, for folder, folderFile.
Terminal
kenso whoami -o json

The first run

From a template to records:

Terminal
kenso workflow-templates list
kenso workflows init qualify --template <templateKey>
kenso workflows push qualify.workflow.json
kenso workflows check qualify.workflow.json --mode publish
kenso workflows test qualify.workflow.json --record account:<accountId>
kenso workflows push qualify.workflow.json --publish --expected-hash <definitionHash>
kenso workflows run qualify.workflow.json --ids ids.txt --dry-run
kenso workflows run qualify.workflow.json --ids ids.txt --max-credits 10 --yes

Fill the template's <fill in: ...> placeholders and set limits in the file before the first push. check --mode publish names everything publish would refuse, with a fix for each issue.

The commands

init

Terminal
kenso workflows init qualify --template <templateKey> --dir workflows

Writes <name>.workflow.json: the template's definition with --template, else a blank definition with trigger.manual@1 and no steps. Writes kenso.json with the resolved workspace when no folder file is found. It never replaces a file (file_exists, exit 7), sends no request without --template, and creates nothing in Kenso. Prints {file, template, folderFile, folderFileCreated, workspaceId}.

pull

Terminal
kenso workflows pull 412 --out qualify.workflow.json

Writes the draft's definition (else the published one; --published takes the published one) to --out or <slug of the name>.workflow.json, with 2-space indents and a final newline, and binds the file in kenso.json. An existing file is replaced only when kenso.json binds it to this workflow (else file_exists, exit 7). When the workflow is bound to another file already, the new file is an unbound copy. Prints {file, workflowId, draftVersion, draftHash, publishedHash, status}.

check

Terminal
kenso workflows check qualify.workflow.json --mode publish

Sends the file as the definition to validate (saving nothing) and to the estimate for one record. Prints {valid, issues, perRecord, draftHash, inSync, next}: each issue has path, code, message, fix and severity; perRecord is {expectedCredits, maxCredits}; draftHash is the saved draft's hash, and inSync says whether the file equals that draft. Exit 0 when valid, 5 when not. --mode draft (the default) checks structure, schemas, references and formulas; --mode publish also checks limits, secrets and connected apps. An unbound file is workflow_not_bound (exit 2), "check needs a workflow id: a draft runs nothing and costs nothing.", with next: kenso workflows push <file>.

push

Terminal
kenso workflows push qualify.workflow.json --note "Raise the size floor"
kenso workflows push qualify.workflow.json --dry-run

An unbound file creates the workflow and binds the file. A bound file is saved to the draft when it differs from it, on top of the draft version just read; an identical file saves nothing. Prints {workflowId, saved, draftVersion, draftHash, published, status, next}. --dry-run prints wouldSend: which of create, update and publish it would send. --publish publishes after the save, and --expected-hash goes with it (see The hash rule).

test

Terminal
kenso workflows test qualify.workflow.json --record account:<accountId> --wait 50

Runs the saved draft once on one record: --record <type:id> (person:812; the types are account, person, lead and place), else the newest record of the trigger's type. --wait is the seconds the API waits for the run, 0 to 50 (50 by default). AI and data steps run for real and are charged; sends and CRM writes are simulated. A file that differs from the draft is refused (draft_out_of_sync, exit 7, next: kenso workflows push <file>). Prints {testPassed, timedOut, definitionHash, publishPassRecorded, run: {id, status, creditsCharged}, hint, next}; after a pass, next is the publish command with --expected-hash <definitionHash>. Exit 1 when the test did not pass.

diff

Terminal
kenso workflows diff qualify.workflow.json --against draft

Compares the file with the published version (the default; the draft when nothing is published) or with the draft. Prints {against, same, nameChanged, triggerChanged, limitsChanged, stepsAdded, stepsRemoved, stepsChanged} with step ids. Exit 0 either way.

schema

Terminal
kenso workflows schema --out workflow.schema.json

Prints, or writes to --out, the JSON Schema of a workflow file. It needs no sign-in and no network, and --out replaces only a schema it wrote.

The hash rule

definitionHash is computed by the server for a saved draft and leaves plain out; the CLI never computes one. When the CLI compares a file with a saved definition, it compares them as JSON with keys sorted at every level: whitespace and key order never count.

  • Publish needs a passed test on the draft's hash. Without one the CLI stops with test_required (exit 7), "Publish needs a passed test on this exact draft.", and next: kenso workflows test <file>.
  • --expected-hash <hash> makes push compare the draft's hash after the save with the value. A mismatch is hash_mismatch (exit 7), "The draft's hash is <actual>, not <expected>.", and nothing is published; the saved draft stays. Pass the hash kenso workflows test printed.
  • Under a coding agent, --publish without --expected-hash is refused (usage_error, "an agent publishes only the version it tested: pass --expected-hash"). A person at a terminal may publish without it.
  • The gap. The publish route takes no hash, so a save that lands between the CLI's hash check and the publish call can be published. The server's version_conflict on a concurrent save and its rule that publish needs a passed test bound it.
  • A save that meets a newer draft is version_conflict (exit 7), "Someone saved this workflow since you read it.", with next: kenso workflows diff <file> --against draft.
  • A definition the server refuses on save or publish is invalid_definition (exit 5) with its issues (path, code, message); on a publish, next is kenso workflows check <file> --mode publish, which adds a fix to each.

Run on records

Terminal
kenso accounts list --limit 50 -o ids > ids.txt
kenso workflows run qualify.workflow.json --ids ids.txt --dry-run
kenso workflows run qualify.workflow.json --ids ids.txt --max-credits 10 --wait --out results.csv --yes
kenso workflows run 412 --file people.csv --record-type person --dry-run
  • Target. A number is a workflow id. A file must be bound in kenso.json and equal to the published version, else unpublished_changes (exit 7), "This file differs from the published version.", with next naming the push that publishes it (with --expected-hash when the saved draft holds the file). A workflow that is not live is invalid_state (exit 7) with next: kenso workflows publish --workflow-id <id>. Nothing publishes by itself.
  • Record type is the trigger's (trigger.manual@1 takes its with.recordType); --record-type (account, person, lead or place) overrides it. A trigger that names no record type needs the flag (not_runnable_on_records, exit 2).
  • Input. --ids is one id per line (- reads stdin). --file is a CSV: with an id column, those ids; without one and with record type person, each row is matched or created as a person in chunks of 200, with the columns kenso people import accepts and no email finding. Any other record type without an id column is ids_required (exit 2), which names kenso contacts import or kenso accounts import. Duplicated ids run once. A saved list runs through a workflow whose trigger is trigger.saved_list@1 or trigger.csv@1; --list is not a flag.
  • Dry run. --dry-run, and a run without --yes, estimate per chunk of up to 1,000 records, start nothing, and print {dryRun, workflowId, records, recordType, credits: {needed, available, sufficient}, perRecord, expectedCredits, cap, next}. needed is the estimate's maximum and available the workspace's balance. A value that could not be read is null, and the plan adds estimateError or balanceError with the reason. A CSV without ids is estimated on its row count and creates no person.
  • Confirmation. Without --yes, a person at a terminal is asked once with the plan on screen. Under a coding agent the command prints the plan and stops, with next naming the same command with --yes.
  • --max-credits <n> is enforced by the CLI; the server is sent no cap. The ceiling per record is the definition's limits.creditsPerRun when set (cap.kind: "hard"), else the estimate's maximum per record (cap.kind: "estimate"). The CLI starts the first floor(n / ceiling) records and reports the rest as not_started with reason over --max-credits. The plan and the summary print cap: {maxCredits, kind, perRecord, willStart, notStarted}. A cap below one record's ceiling starts nothing: cap_too_low (exit 6), with next naming the smallest cap that starts one record. A workspace out of credits starts nothing either (out_of_credits, exit 6).
  • --wait follows each started run, up to 8 reads at a time, until it leaves queued, running and waiting, or --timeout (90s, 10m, 1h; default 30m) passes. A run still waiting at the timeout is reported as waiting. --timeout goes with --wait.
  • --out <results.csv> (needs --wait) writes one row per input record when the batch ends: row, id, status, runId, runStatus, creditsCharged, missReason, error, then one column per step id holding that step's output as compact JSON. The path is checked before the first request: its folder must exist, and an existing file is refused (file_exists, exit 7) unless it is this run's own.
  • Summary. One JSON object with records, started, deduplicated, notStarted, succeeded, failed, waiting, missed (reason to count), creditsCharged ("pending" without --wait or while runs are open), cap, resultsCsv, appUrl (the workflow's page in the app, in the run's workspace: https://app.ken.so/<workspaceId>/workflows/<id>) and next, and the same counts on one stderr line. With --wait, a run that failed makes next its kenso workflow-runs logs <runId>.
  • Never twice. A run is known by its input file's content, the workflow it resolves to and the workspace, not by how the command was typed: ids.txt, ./ids.txt and a copy of the file are one input, and so are a bound file and its workflow id. The same run again starts nothing and answers from the finished run's folder with alreadyDone: true; with --wait and --out it reads that run's runs and writes the results file. A run on that input that would start records differently (another --max-credits, or a people file whose matches changed) is refused with already_started (exit 7) once the earlier run sent starts: not-started.txt in its folder holds the ids it did not start, and next runs only those. A run on that input that another kenso process is running now is run_in_progress (exit 7).

The run folder

Each applied run writes a run folder (~/.kenso/runs/<id>) that records every chunk's response, as every batch command does: see Batch runs. kenso runs resume <runId> never resends a chunk it has an answer for. A chunk that was sent and has no recorded answer is not resent either: resume stops with chunk_outcome_unknown (exit 5), the chunk's first and last row, and next: kenso workflow-runs list --workflow-id <id> --created-after <chunk start time>, so you can see what started.

Terminal
kenso runs resume <runId>
kenso workflow-runs list --workflow-id 412 --created-after 2026-11-21T10:00:00Z

Read a run

Terminal
kenso workflow-runs logs <runId>
kenso workflow-runs logs <runId> --step qualify --full

One row per step run in start order: {nodeId, stepType, status, attempt, startedAt, endedAt, ms, credits, error}, NDJSON when piped. --step keeps one node; --full adds each step's input, output and attempts. A header line on stderr gives the run's status, workflow, record and the credits it charged, and needs attention: <reason> when one is set. A failed run ends with next: kenso workflow-runs restart --run-id <id> --dry-run, because retry refuses a run that has ended.

Step outputs are kept 7 days

A succeeded run's step outputs are dropped 7 days after it finishes, unless the workflow keeps success details. --out writes them when the batch ends, so run with --wait --out when you need the results later.

Exit codes

ExitWhen
0Done. For run, every record started and, with --wait, none failed
1test: the test did not pass
2Usage: workflow_not_bound, folder_file_invalid, folder_file_untrusted, workspace_mismatch, not_runnable_on_records, ids_required, or --publish without --expected-hash under a coding agent
4test: runtime_off, the workspace cannot run workflows yet
5check found the file not valid, the server refused a definition (invalid_definition), run has records that failed, were not found or were not started, or resume met chunk_outcome_unknown
6run: the cap started nothing (cap_too_low), or the workspace is out of credits
7A conflict: file_exists, already_bound, draft_out_of_sync, hash_mismatch, test_required, version_conflict, unpublished_changes, invalid_state, an existing --out file, or a run on an input an earlier run started (already_started) or another process is running (run_in_progress)

Every error is one JSON line on stderr with code, message, hint and next: see Output and errors.

On this page