# Workflow

> Workflows, built from a description or edited step by step, and run from code.

```python
brief = noclick.Workflow.create("Morning brief")
brief.build("Every day at 8, email me today's calendar").wait()
run = brief.run().wait()
```

Your keys read every workflow your account can open in the app, its own and
those shared with it (`access`), and change, build and run the ones they can
edit (one a team workspace's owner pays for is billed to them). NoClick's
builder (the one in the app) builds and changes one from what you describe: a
`WorkflowBuild` you wait on, which may stop to ask something first, and which
can publish the workflow's app too. A run starts where its trigger does, with
the inputs as the trigger's payload. A run started inside `as_user` (or with
`user=`) is recorded for that user and counts toward their spend cap; its
steps still use the app's connections.

A workflow's graph is also a handle you change directly: `graph()` reads its
steps, each `Step` changes with one call (`update`, `connect`, ...), and
`edit()` sends several changes as one batch that lands whole or not at all,
refused with `noclick.Conflict` when the workflow moved on since the version
you read. Every change is a version, listed by `versions()` and undone with
`restore(history_version=...)`.

## Workflow

```typescript
class Workflow
```

A workflow built in the NoClick app: its trigger, steps and outputs. Run it with
`run(inputs)`; `inputs` names what its trigger takes. `access` is your account's: `owner`,
`editor` or `viewer` (one shared with it); building, running, testing and publishing it take
edit access, billed to whoever pays for it (a team workspace's owner; its app stays its owner's);
pausing and deleting it take owning it and paying for it.

It's also a handle to its graph: `graph()` reads its steps whole, each `Step` changes with one
call, and `edit()` sends several changes as one version, checked against the version you read
(`version`) when you say so. Editing takes edit access, as the app's canvas does: an `editor`
edits a workflow shared with it.

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `string` |  |
| `name` | `string` |  |
| `description` | `string | null` |  |
| `inputs` | `JsonObject` | A JSON schema of what `run` takes: a form's fields, any object for a webhook, empty if nothing. |
| `appUrl` | `string | null` | Where to open it in the NoClick app. |
| `access` | `string` | Your account's access: `owner`, `editor` or `viewer`. |
| `folderId` | `string | null` | The folder of your account's it's in (`Workflow.folders()`); null at the top, and for one shared with you. |
| `stepTypes` | `string[]` | What it's made of, at a glance, in a list too: at most four of its step types, its triggers first, then its agents (one on a coding harness as `agent:<harness>`, `agent:codex`), then the rest, never a note. |
| `createdAt` | `Date | null` |  |
| `updatedAt` | `Date | null` |  |
| `steps` | `WorkflowStep[]` | Its steps in order, each with its settings, connection and trigger state (read with one workflow, not in a list). |
| `edges` | `WorkflowEdge[]` | How its steps are wired. |
| `paused` | `boolean` | Whether a pause switched its triggers off. |
| `readiness` | `WorkflowReadiness` | Whether it's set up to run, what its status means, and the issues in the way. |
| `urls` | `WorkflowUrl[]` | The URLs it answers at. |
| `latestBuild` | `WorkflowBuild | null` | The build `create(..., { instructions })` or `build()` started here (`null` otherwise). |
| `version` | `number | null` | Its version as this handle last read or wrote it: what `edit({ ifVersion })` checks against. Every change to its definition moves it on, and so do NoClick's own records of a trigger's registration. Throws until the workflow is loaded (`hydrate()`), its graph read or an edit made. |
| `lastEdit` | `WorkflowEdit | null` | What this handle's last edit did (`null` until one): its version, summary, each op's results and verdicts. |

Types:

```typescript
type JsonObject = { [key: string]: unknown };

/** How two steps are wired: `kind` is `data`, or `tools` for a step an agent uses as a tool. */
interface WorkflowEdge {
  from: string;
  to: string;
  kind: "data" | "tools";
}

/** Whether a workflow is set up to run: its `status` and the `issues` in the way. */
interface WorkflowReadiness {
  status: string;
  /** What `status` means, in a sentence. */
  meaning: string;
  /**
   * What's in the way of it working, a step whose last run failed among them. An issue's `code` says whose move it
   * is: `missing_credentials` waits on an account, `left_for_user` on a required setting the step leaves for its
   * person to fill in, and `invalid_config` is a setting a run would refuse.
   */
  issues: { step: string | null; code: string; message: string }[];
  /** What doesn't stop it running: an agent's tool with no account connected, which only a call to it needs. */
  warnings: { step: string | null; code: string; message: string }[];
  /** The steps no run has completed yet: set up, but nothing has shown they work. */
  unverified: { step: string | null; code: string; message: string }[];
}

/** A URL a workflow answers at: its `endpoint`, its published `app`, or a hosted `mcp` server. */
interface WorkflowUrl {
  kind: string;
  url: string;
  step: string | null;
  public: boolean;
}
```

### Workflow.create

```typescript
static create(
  name: string,
  options?: {
    instructions?: string;
    description?: string;
    questions?: BuildQuestions;
    client?: NoClick;
  },
): Promise<Workflow>
```

A new workflow in your account. With `instructions` NoClick's builder starts building it:
wait on `latestBuild`. A name your account already has throws `Conflict` (change that one with
`build`). `questions: "assume"`: the builder asks nothing, as `build()` takes it.

Parameters:

- `name` (`string`, required)
- `options.instructions` (`string`)
- `options.description` (`string`)
- `options.questions` (`BuildQuestions`)
- `options.client` (`NoClick`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: The new workflow; `latest_build` is its build when `instructions` describe it.

Types:

```typescript
/** Whether a build asks what it can't decide (`ask`, the default) or asks nothing (`assume`). */
type BuildQuestions = "ask" | "assume";
```

### Workflow.fromName

```typescript
static fromName(
  name: string,
  options?: { description?: string; client?: NoClick },
): Workflow
```

A lazy reference to the workflow called `name` in the app; two with that name throw `Conflict` on first use,
and none `NotFound`. Given `description`, it gets the workflow, then sets its description when it differs,
every time it runs; nothing else about the workflow is touched.

Parameters:

- `name` (`string`, required)
- `options.description` (`string`)
- `options.client` (`NoClick`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: A workflow that loads the first time it's used. Nothing is sent yet.

### Workflow.fromId

```typescript
static fromId(workflowId: string, options?: { client?: NoClick }): Workflow
```

A lazy reference to a workflow by id.

Parameters:

- `workflowId` (`string`, required)
- `options.client` (`NoClick`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: A workflow that loads the first time it's used. Nothing is sent yet.

### Workflow.get

```typescript
static get(
  workflowId: string,
  options?: { client?: NoClick },
): Promise<Workflow>
```

Load a workflow by id now; an unknown id raises `noclick.NotFound`.

Parameters:

- `workflowId` (`string`, required)
- `options.client` (`NoClick`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: The workflow, loaded.

### Workflow.list

```typescript
static list(
  options?: { q?: string; search?: string; limit?: number; client?: NoClick },
): Promise<Workflow[]>
```

The workflows your account can open (its own and those shared with it), most recently changed first; `q` is a
prefix of the name, `search` text its name or description holds (in any case).

Parameters:

- `options.q` (`string`)
- `options.search` (`string`)
- `options.limit` (`number`): Return at most this many.
- `options.client` (`NoClick`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: Every matching workflow, fetched page by page (or the first `limit`).

### Workflow.listPage

```typescript
static listPage(
  options?: PageOptions & { q?: string; search?: string; client?: NoClick },
): Promise<Page<Workflow>>
```

One page of workflows; pass `nextCursor` back as `cursor`.

Parameters:

- `options.cursor` (`string | null`): The `next_cursor` of the page before; omit it for the first page.
- `options.limit` (`number`): Return at most this many.
- `options.q` (`string`)
- `options.search` (`string`)
- `options.client` (`NoClick`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: A page whose `data` holds the workflows and whose `next_cursor` is `None` on the last page.

### Workflow.folders

```typescript
static folders(options?: { client?: NoClick }): Promise<WorkflowFolder[]>
```

Your account's workflow folders, as the app's Automations page shows them: the ones it made in its own workspace,
the shallowest first, then by name. A workflow's `folderId` names the one it's in.

    for (const folder of await Workflow.folders()) console.log("  ".repeat(folder.depth) + folder.name);

Parameters:

- `options.client` (`NoClick`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: Each folder, with its `parent_id` (`None` at the top) and its `workflow_count`.

### Workflow.createFolder

```typescript
static createFolder(
  name: string,
  options?: {
    description?: string;
    parent?: WorkflowFolder | string;
    client?: NoClick;
  },
): Promise<WorkflowFolder>
```

A new folder in your account's workspace, at the top or in `parent` (a folder or its id), as the app makes one. A
name `parent`'s folders already have throws `Conflict`, naming that folder (`folder_id`).

    const reports = await Workflow.createFolder("Reports");
    await Workflow.fromName("Morning brief").moveTo(await Workflow.createFolder("Weekly", { parent: reports }));

Parameters:

- `name` (`string`, required)
- `options.description` (`string`)
- `options.parent` (`WorkflowFolder | string`, default `null`)
- `options.client` (`NoClick`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: The new folder.

### Workflow.deleteFolder

```typescript
static deleteFolder(
  folder: WorkflowFolder | string,
  options?: { client?: NoClick },
): Promise<WorkflowFolder>
```

Delete one of your account's folders (a folder or its id), as the app does: the workflows in it move to its parent
(the top, for one at the top) and the folders in it go with it, their workflows moving to the top. No workflow is
deleted. Answers the folder as it was.

    for (const folder of await Workflow.folders()) {
      if (folder.workflowCount === 0) await Workflow.deleteFolder(folder);
    }

Parameters:

- `folder` (`WorkflowFolder | string`, required)
- `options.client` (`NoClick`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: The folder as it was.

### Workflow.moveTo

```typescript
moveTo(folder: WorkflowFolder | string | null): Promise<this>
```

Move it into one of your account's folders (a folder or its id), or out to the top with `null`, as dragging it does
in the app. It takes what changing it takes: owning it and paying for it. Answers it read again, its `folderId`
the folder it's in now.

    const brief = Workflow.fromName("Morning brief");
    await brief.moveTo(await Workflow.createFolder("Reports"));
    await brief.moveTo(null);   // back to the top

Parameters:

- `folder` (`WorkflowFolder | string | null`, required)

Returns: This workflow, read again (`folder_id` is the folder it's in now).

### Workflow.graph

```typescript
graph(): Promise<WorkflowGraph>
```

Read its definition whole: its name, description and settings, every step with its settings as stored (never a
secret), its notes and edges, at its current `version`, which this handle's `version` now is.

Returns: The `WorkflowGraph`; this handle's `version` is now its.

### Workflow.variables

```typescript
variables(): Promise<WorkflowVariables>
```

Read its variables with their values, which `graph()` and every other read hold back (`settingsWithheld`,
`variablesWithheld`): its `definitions` whole, the graph's own `variables`, and `values` by name.

For the workflow's owner and the teammates who can edit it: signed in, or with one of their account's own secret
keys that names the `workflows:variables` scope (a key with every scope, `*`, holds it only when it's named too)
and acts for no user. Anyone else throws `PermissionDenied`: someone who only views the workflow, a user's
session, an app's code, an agent or an MCP connection. Writing a variable stays its owner's. A step reads a
variable as `{{vars.name}}` without this call.

Returns: The `WorkflowVariables`: its `definitions` whole, the graph's own
`variables`, and `values` by name.

### Workflow.setup

```typescript
setup(): Promise<WorkflowSetup>
```

Read what the workflow needs from its person before it can run: the accounts to connect, the values only they know
and the variables an agent step's shell asked for, derived from the workflow as it stands. Code that builds without
a person reads this and connects or fills in each item itself; a build's result carries it too (`setup`).

Returns: The `WorkflowSetup`: its `items`, whether it's `ready`, and the setup
`request` still waiting on the person.

### Workflow.requestSetup

```typescript
requestSetup(options?: { via?: "auto" | string[] }): Promise<WorkflowSetup>
```

Send what the workflow needs to the account's owner as ONE request: one message and one page, where they connect
each app and fill in each value, each part landing on the workflow as they give it. An app the account holds
exactly one working connection of is connected at once, asking nobody. The same list already waiting isn't sent
again (`sent` null); a different one replaces it. `via`: `"auto"` (the app they last texted NoClick on, else
email), or a list of `web`, `email`, `whatsapp`, `imessage`, `sms`. Needs the `workflows` and `humans` scopes,
acting for the whole account.

Parameters:

- `options.via` (`"auto" | string[]`, default `"auto"`)

Returns: The `WorkflowSetup` as `setup()` reads it, with `sent`: the request's
operation (its `request` naming `delivered_via`), or None.

### Workflow.step

```typescript
step(id: string): Step
```

A handle to one of its steps by id. Nothing is sent: an edit through it names the step by its id, and
`await step.hydrate()` loads its fields from the graph (a step that isn't there throws `NotFound` then).

Parameters:

- `id` (`string`, required)

Returns: The `Step`.

### Workflow.addStep

```typescript
addStep(type: string, options?: AddStepOptions): Promise<Step>
```

Add a step of `type` (`automation-gmail`, `agent`, `trigger-cron`) doing `operation` with `settings`, as one
edit. `id` names it (made from its type when left out); without `position` it's laid out beside the rest. A
type, operation or value that can't be is refused with `InvalidRequest` naming it, and a setting it can't run
without yet is in its `verdict`. Resolves to the new `Step`, with its `verdict` and `notes`.

Parameters:

- `type` (`string`, required)
- `options.operation` (`string`): What it does, one of its type's operations.
- `options.settings` (`JsonObject`)
- `options.name` (`string`): Its name in the app.
- `options.id` (`string`): Its id; made from its type when left out.
- `options.position` (`Position`): Where it sits; left out, it's laid out beside the rest.
- `options.secrets` (`SecretRef[]`): An agent step's secrets, as `StepUpdate.secrets` takes them.
- `options.leftForUser` (`string[]`): Settings left for the step's person to fill in, as `StepUpdate.leftForUser` takes them.

Returns: The new `Step`, with its `verdict` and what the edit said about it (`notes`).

Types:

```typescript
type JsonObject = { [key: string]: unknown };

/** A secret to pass: a `Secret`, its id, or its name (the user's own, else the account's). */
type SecretRef = string | Secret;

/** Where a step sits on the canvas. */
interface Position {
  x: number;
  y: number;
}
```

### Workflow.update

```typescript
update(update: WorkflowUpdate): Promise<this>
```

Change its name, description or settings (by top-level key; only its owner changes those). A field you leave
out is never touched. Resolves to this workflow, which loads again the next time you read a field.

Parameters:

- `update` (`WorkflowUpdate`, required)

Returns: This workflow; it loads again the next time you read a field.

Types:

```typescript
/** What `Workflow.update` changes; a field left out is never touched. */
interface WorkflowUpdate {
  name?: string;
  description?: string;
  /** Its settings to change, by top-level key; only its owner changes them. */
  settings?: JsonObject;
  /**
   * What the app shows of it (its canvas's viewport, the step open in its panel; 16 KB at most), replacing what's
   * kept: never a version, nor a change anyone is told of.
   */
  displayMetadata?: JsonObject;
  /**
   * Its Interface tab's layout as the app draws it (each block's place on the grid, the tabs' order; 256 KB at most),
   * replacing what's kept: part of its graph, so it moves the version.
   */
  interface?: JsonObject;
}

type JsonObject = { [key: string]: unknown };
```

### Workflow.addNote

```typescript
addNote(content: string, options?: AddNoteOptions): Promise<Step>
```

Put a note on the canvas: `near` some steps (`direction`: `above`, the default, `below`, `left` or `right`), or
over a stretch of them from `after` to `before`. Resolves to the note: a `Step` of type `stickyNote`.

Parameters:

- `content` (`string`, required)
- `options.id` (`string`)
- `options.color` (`number`): The app's colours, 0 to 20.
- `options.near` (`StepRef[]`): Steps it sits beside.
- `options.direction` (`"above" | "below" | "left" | "right"`): Which side of `near`: `above` (the default), `below`, `left` or `right`.
- `options.after` (`StepRef`): With `before`: the first step of the stretch it covers.
- `options.before` (`StepRef`): With `after`: the last step of the stretch it covers.
- `options.width` (`number`)
- `options.height` (`number`)
- `options.position` (`Position`): Where it sits, instead of beside steps (`near`, or `after` and `before`).

Returns: The note: a `Step` of type `stickyNote` (its text is `settings["content"]`).

Types:

```typescript
/** A step, or its id. */
type StepRef = Step | string;

/** Where a step sits on the canvas. */
interface Position {
  x: number;
  y: number;
}
```

### Workflow.move

```typescript
move(step: StepRef, position: Position): Promise<Step>
```

Move a step (or a note) on the canvas. Where things sit is never a version of its own. Resolves to the step.

Parameters:

- `step` (`StepRef`, required)
- `position` (`Position`, required)

Returns: The step, at its new `position`.

Types:

```typescript
/** A step, or its id. */
type StepRef = Step | string;

/** Where a step sits on the canvas. */
interface Position {
  x: number;
  y: number;
}
```

### Workflow.edit

```typescript
edit(
  options: EditOptions,
  build: (batch: EditBatch) => unknown,
): Promise<WorkflowEdit | null>
```

Collect several edits with `build` and send them as one batch once it resolves: they're applied in order and
land as one version, or none of them do. With `ifVersion` (a version you read: `version`,
`(await graph()).version`, or the last edit's) the batch is refused with `Conflict` when the workflow moved on
since, and the error carries the workflow as it stands (`graph` and `version`). `includeGraph` has the answer
carry the workflow as written, read as `graph()` reads it. Resolves to the `WorkflowEdit` (`null` when `build`
queued nothing); a `build` that throws sends nothing.

A batch that can't be undone from its versions alone (one that removes a step holding an app, conversations or
files) may be held for the account's owner when an agent, a connected app or a deployed app's code sends it: it
throws `ApprovalRequired`, nothing of it has landed, and NoClick applies it once they approve (its `operation`
settles then, with the batch's answer). The workflow one of your agents runs on is edited as its canvas edits it:
the agent follows its prompt, harness and model, its own step stays (removing it throws `InvalidRequest` naming
the agent, `details.agent_id`), and a key that couldn't change the agent can't change it this way either.

`source: "canvas"` says the edits are a canvas's saves (`EditOptions.source`).

Parameters:

- `build` (`(batch: EditBatch) => unknown`, required)
- `options.ifVersion` (`number`): The version the edits were made against (a read's `version`): refused with `Conflict` when it moved on since.
- `options.includeGraph` (`boolean`): `true`: the answer carries the graph as written.
- `options.source` (`"canvas"`): `canvas`: the edits are a canvas's saves. Each setting `updateStep` sends replaces that setting whole and is kept
as written (never rewritten nor refused for its value; the step's verdict says it isn't ready), an edge joins the
handles it names, a connection sits under the slot it's given (one the step takes), and they join the canvas
session's version (saves within five minutes of its first, whoever made them).
- `options.origin` (`string`): A name the sender gives itself (letters, digits, `-` and `_`, up to 64; a canvas tab's own id): what the
workflow's open canvases hear of this write names it, so the canvas that sent it knows the change is its own.
- `options.settle` (`boolean`): `true`: wait, up to 30 seconds, for what the batch sets going (a trigger's registration: its webhook, its
schedule, its inbox; a removed step's teardown) before the answer: `settled` says whether it finished in time,
the graph (with `includeGraph`) carries what it wrote on the steps (a trigger's `webhook_url`), and
`unregistered` names, by step, why each trigger it left unregistered can't be registered yet.
- `options.keepalive` (`boolean`): In a browser, send the batch so it outlives the page (a closing tab's last save; `RequestOptions.keepalive`).

Returns: An `EditBatch` to use as a context manager (`async with` in async code);
its `result` is the `WorkflowEdit` once the block ends.

### Workflow.settle

```typescript
settle(options?: { includeGraph?: boolean }): Promise<WorkflowEdit>
```

Wait, up to 30 seconds, for what earlier edits set going (their triggers' registrations, removed steps'
teardowns), changing nothing, as an edit with `settle` waits for its own: `settled` says whether it finished in
time, `unregistered` (by step) why each trigger left unregistered can't be yet, and with `includeGraph` the answer
carries the workflow as that left it.

    const settled = await brief.settle({ includeGraph: true });
    console.log(settled.graph?.step("hook").settings.webhook_url);

Parameters:

- `options.includeGraph` (`boolean`)

Returns: A `WorkflowEdit`: `settled` (whether it finished in time), `unregistered` (by step,
why each trigger left unregistered can't be yet) and, with `include_graph`, the workflow
as that left it.

### Workflow.versions

```typescript
versions(
  options?: { limit?: number | null; named?: boolean },
): Promise<WorkflowVersion[]>
```

Its versions, newest first, kept 90 days (a named one for good): the first `limit` (20 by default; `null` for
all), fetched page by page. `named: true` lists only the named ones, its checkpoints.

Parameters:

- `options.limit` (`number | null`): Return at most this many.
- `options.named` (`boolean`)

Returns: The first `limit` versions (20 by default; `None` for all of them), fetched page by page.

### Workflow.nameVersion

```typescript
nameVersion(
  label: string,
  options?: NameVersionOptions,
): Promise<WorkflowVersion>
```

Name a version of its history, keeping it for good while it has a name: the version it's at now (a checkpoint,
as the app saves one; `ifVersion` refuses it with `Conflict` when the workflow moved on since you read it), or
the one `historyVersion` names, or another name for a named one. No later change joins a named version. Naming
the version it's at now when it has a name already throws `Conflict` naming it (`details.label`). Restore it
with `restore({ historyVersion })`. A name someone else gave is changed only by them or the workflow's owner.

Parameters:

- `label` (`string`, required)
- `options.note` (`string`, default `null`): A line about it.
- `options.historyVersion` (`number`): The version of its history to name; left out, the version the workflow is at now (a checkpoint).
- `options.ifVersion` (`number`): For the version it's at now: refused with `Conflict` when the workflow moved on since this version.

Returns: The named `WorkflowVersion`.

### Workflow.unnameVersion

```typescript
unnameVersion(historyVersion: number): Promise<WorkflowVersion>
```

Take a version's name away (a checkpoint deleted): it's kept 90 days from its last write then, as any version.
Only who named it or the workflow's owner takes it away.

Parameters:

- `historyVersion` (`number`, required)

Returns: The `WorkflowVersion`, its `label` `None`.

### Workflow.versionsPage

```typescript
versionsPage(
  options?: PageOptions & { named?: boolean },
): Promise<Page<WorkflowVersion>>
```

One page of its versions, newest first (`named: true`: the named ones); pass `nextCursor` back as `cursor`.

Parameters:

- `options.cursor` (`string | null`): The `next_cursor` of the page before; omit it for the first page.
- `options.limit` (`number`): Return at most this many.
- `options.named` (`boolean`)

Returns: A page whose `data` holds the versions and whose `next_cursor` is `None` on the last page.

### Workflow.versionAt

```typescript
versionAt(historyVersion: number): Promise<WorkflowVersion>
```

One version of its history, by its `historyVersion`, with the definition it holds (its `graph`: name,
description, settings and steps as they were); a version it doesn't have (kept 90 days) throws `NotFound`.

Parameters:

- `historyVersion` (`number`, required)

Returns: The `WorkflowVersion`; its `graph` is the workflow as it was: its name,
description, settings and steps.

### Workflow.build

```typescript
build(
  instructions?: string,
  options?: { publish?: boolean | JsonObject; questions?: BuildQuestions },
): Promise<WorkflowBuild>
```

Change the workflow by describing the change; NoClick's builder makes it, reading the workflow
as it stands. `publish: true` then puts its app live (or pass `{ subdomain, title }`; `publish()`
and `unpublish()` publish without a change). One build at a time: another in progress throws
`Conflict`. A change costs AI usage, as building in the app does. `wait()` resolves to the
`WorkflowBuildResult`; `nextQuestion()` resolves to anything it asks first.

What the builder can't decide it asks the person whose build it is (you as the account's owner,
or the user your key acts for): each input of its question is a human request NoClick sends
them, which any client answers. `questions: "assume"` asks nothing: the builder decides, and its
summary and the workflow's readiness say what it assumed and what's missing.

Parameters:

- `instructions` (`string`)
- `options.publish` (`boolean | JsonObject`)
- `options.questions` (`BuildQuestions`)

Returns: A `WorkflowBuild`: `wait()` gives the `WorkflowBuildResult` (its `steps`, and what was
`published`), and `next_question()` returns anything it asks first.

Types:

```typescript
type JsonObject = { [key: string]: unknown };

/** Whether a build asks what it can't decide (`ask`, the default) or asks nothing (`assume`). */
type BuildQuestions = "ask" | "assume";
```

### Workflow.draft

```typescript
draft(
  steps: readonly DraftStep[],
  options?: DraftOptions,
): Promise<Operation<WorkflowDraftResult>>
```

Have NoClick's drafter (the builder's own) pick `steps`' operations and fill their settings, the steps together.
Each step is a `Step`, its id, or `{ id, goal }`: its goal says what it's for (the drafter reads it, and a drafted
step keeps it). `mode` `full` (the default) picks each step's operation and fills its settings (a step drafts
against the operation each step it reads was given), `operation` picks only the operation, `fields` fills the
settings of the operation a step has, `field` fills the one setting `field` names; `instructions` say what the
workflow does. A step the workflow doesn't have, a note, a step that provides an agent its tools or a setting it
doesn't have throws `InvalidRequest` before anything runs. What's drafted lands as one version of the workflow,
written as an edit with your key is; the drafter never connects an account. It costs its AI usage, at cost. The
operation (kind `workflow.draft`) reports each step as it lands (`progress`); `wait()` resolves to the
`WorkflowDraftResult`, each step's verdict among it, or throws when no step could be drafted.

Parameters:

- `steps` (`readonly DraftStep[]`, required)
- `options.mode` (`"full" | "operation" | "fields" | "field"`, default `"full"`): `full` (the default) picks each step's operation and fills its settings; `operation` picks only the operation;
`fields` fills the settings of the operation a step has; `field` fills the one setting `field` names.
- `options.field` (`string`): The setting mode `field` fills.
- `options.instructions` (`string`): What the workflow does, in words, for the drafter to read beside each step's goal.

Returns: An operation (kind `workflow.draft`) that reports each step as it lands (`progress`); `wait()`
gives the `WorkflowDraftResult`, each step's verdict among it, or raises when no step could be drafted.

Types:

```typescript
/** A step to draft: a `Step`, its id, or `{ id, goal }` (what it's for, which a drafted step keeps). */
type DraftStep = StepRef | { id: StepRef; goal?: string };

/** A step, or its id. */
type StepRef = Step | string;
```

### Workflow.publish

```typescript
publish(options?: PublishOptions): Promise<WorkflowBuild>
```

Put the workflow's app live as it now stands, at `subdomain` (omitted, the address it has); the result's `published` holds its `url`.

Parameters:

- `options.subdomain` (`string`)
- `options.title` (`string`)

Returns: A `WorkflowBuild` whose result's `published` holds the app's `url`.

### Workflow.unpublish

```typescript
unpublish(): Promise<WorkflowBuild>
```

Take the workflow's app down, to the trash: its public URL stops answering. For 30 days its address stays its own,
and restoring it (or `publish()`) brings it back there with the same key; the result's `published` names the
`trashId` that restores it and until when (`restorableUntil`).

Returns: A `WorkflowBuild`; its result's `published` says `unpublished`, with the `trash_id` that
restores it and until when (`restorable_until`).

### Workflow.pause

```typescript
pause(reason?: string): Promise<this>
```

Switch off each of its triggers that's on, with `reason` beside them: nothing starts it on its own until `resume()`. Runs from code still start.

Parameters:

- `reason` (`string`)

Returns: This workflow, read again (`paused` is `True`).

### Workflow.resume

```typescript
resume(): Promise<this>
```

Switch back on each trigger a pause switched off (never one turned off by hand).

Returns: This workflow, read again.

### Workflow.restore

```typescript
restore(
  options?: { historyVersion?: number; ifVersion?: number },
): Promise<this>
```

Bring the workflow back from the trash (within 30 days of `delete()`); its schedules and webhooks register
again. With `historyVersion`, put that version of its history back instead (`versions()` lists them): its graph,
name, description and settings, as a new version of its own (source `restore`), so it's undone by restoring the
one before it. `ifVersion` (the workflow's `version` you read) refuses it with `Conflict`, carrying the workflow
as it stands, when the workflow moved on since. One that takes away a step holding an app, conversations or files
may be held for the account's owner, as a batch is (`ApprovalRequired`). After a version's restore, `version` is
the new one and `lastEdit` says what it did.

Parameters:

- `options.historyVersion` (`number`)
- `options.ifVersion` (`number`)

Returns: This workflow. Out of the trash it's read again; after a version's restore,
`version` is the new one, `last_edit` says what it did (`restored_from`,
`summary`) and its fields load again the next time you read one.

### Workflow.delete

```typescript
delete(): Promise<void>
```

Move the workflow to the trash: its schedules and webhooks stop now, and `restore()` brings it back within 30 days.

Returns: Nothing.

### Workflow.run

```typescript
run(
  inputs?: JsonObject,
  options?: WorkflowRunOptions,
): Promise<Operation<WorkflowRun>>
```

Start a run with `inputs` (checked against the workflow's `inputs` schema; a mismatch throws
`InvalidRequest` naming the field). What would stop the run is refused before anything runs: a
step with no account connected throws `NeedsConnection`, and a workflow that can't start from
code or isn't set up `ActionRequired`. `wait()` resolves to the finished `WorkflowRun`, or
throws the run's error if it failed.

`fromStep` runs that step and what comes after it instead (`only: true`: that step alone), the steps before it
giving the outputs they last stored. A step that provides an agent its tools has no run of its own
(`InvalidRequest`, `details.reason` `tool_provider`).

Parameters:

- `inputs` (`JsonObject`)
- `options.fromStep` (`StepRef`): Run this step and what comes after it instead, the steps before it giving the outputs they last stored, as the
app's Run from here does. A run from a step takes no inputs, unless it's a trigger that does.
- `options.only` (`boolean`): With `fromStep`: run that step alone, nothing after it.
- `options.user` (`UserOption`, default: the current user): `undefined` = the ambient user (`asUser`), `null` = the account itself.
- `options.idempotencyKey` (`string`): Makes a retried create safe: the same key returns the first result. Generated when omitted.
- `options.client` (`NoClick`)

Returns: An operation whose `.wait()` gives the finished `WorkflowRun`, or
raises the run's error if it failed.

Types:

```typescript
type JsonObject = { [key: string]: unknown };

/** A step, or its id. */
type StepRef = Step | string;

/** `undefined` = the ambient user (from `asUser`), `null` = the account itself. */
type UserOption = UserRef | null | undefined;

/** A `User` or your own id for the user. */
type UserRef = string | UserLike;

/** Anything that can name a user lazily (a `User`). */
interface UserLike {
  _userId(): Promise<string>;
}
```

### Workflow.testRuns

```typescript
testRuns(): Promise<WorkflowTestRun[]>
```

The test runs the workflow offers, as its Test Run screen lists them, in the order `rehearse` finds them: for
each trigger an agent comes after, the staged situations NoClick offers for it (under the names the workflow
gave them, with its edits to their messages, less the ones it removed) and the runs it authored
(`edit().addTestRun`). Each `key` and `name` names its run to `rehearse`. Empty for a workflow with no trigger
a test can stage. Reading them costs nothing.

Returns: Each `WorkflowTestRun`, in the order `rehearse` finds them: its `key` and `name` (either names
it to `rehearse`), the `trigger` it stages on and its staged `message`.

### Workflow.rehearse

```typescript
rehearse(
  options: WorkflowRehearseOptions,
): Promise<Operation<WorkflowRehearsal>>
```

A test run of the workflow, as the app's Test Run plays one: a staged event arrives at one of its triggers and
the agents it reaches take a real turn (their models, instructions and tools) while a simulated world answers
every tool call, so nothing is sent, no account is touched and its connections needn't be connected yet (its
agents' model connections must be). The steps after an agent that would reach an account never run.

`testRun` plays one the workflow offers, by its name or key, as its Test Run screen lists them (`testRuns()`
reads them): a staged
situation for one of its triggers, or one authored for it (`edit().addTestRun`). Or stage a message you type on
`trigger` (a trigger `Step`, its id or its type): `body`, with `title`, `author` and `handle`. `scenario` says
what the simulated world is like. One the workflow doesn't offer throws `NotFound` naming the ones it does.
Billed as the app's Test Run is; an account has up to 10 queued or running at once (`QuotaExceeded` past that).
`wait()` resolves to the `WorkflowRehearsal`: the agent's `reply` and the `toolCalls` it made with what the
world answered.

Parameters:

- `options.trigger` (`StepRef`): Instead of `testRun`: the trigger step (a `Step`, its id or its type) to stage `body` on.
- `options.body` (`string`): With `trigger`: the staged message's body.
- `options.title` (`string`): With `trigger`: its subject or title.
- `options.author` (`string`): With `trigger`: who it's from, by name.
- `options.handle` (`string`): With `trigger`: who it's from, by address or handle.
- `options.scenario` (`string`): What the simulated world is like; its answers keep to it. Omitted, the staged situation's own.
- `options.user` (`UserOption`, default: the current user): `undefined` = the ambient user (`asUser`), `null` = the account itself.
- `options.testRun` (`string`): A test run the workflow offers, by its name or key, as its Test Run screen lists them.
- `options.client` (`NoClick`)

Returns: The run's operation (kind `workflow.rehearse`); `.wait()` gives the `WorkflowRehearsal`: the
agent's `reply` and the `tool_calls` it made with what the world answered.

Types:

```typescript
/** A step, or its id. */
type StepRef = Step | string;

/** `undefined` = the ambient user (from `asUser`), `null` = the account itself. */
type UserOption = UserRef | null | undefined;

/** A `User` or your own id for the user. */
type UserRef = string | UserLike;

/** Anything that can name a user lazily (a `User`). */
interface UserLike {
  _userId(): Promise<string>;
}
```

### Workflow.runs

```typescript
runs(options?: WorkflowRunsOptions): Promise<WorkflowRun[]>
```

Recent runs, newest first, however they started. Outside `asUser` you read runs recorded for
your account; `userFilter` reads your users'. The first `limit` (20 by default). Narrowed by `status`, by how they
started (`source`), by the kind of event that started them (`trigger`), to those that wait or don't (`waiting`),
and by text in their error (`search`).

Parameters:

- `options.status` (`WorkflowRunStatus | readonly WorkflowRunStatus[]`)
- `options.limit` (`number`): Return at most this many.
- `options.userFilter` (`UserFilter`): Which users the read covers (`user_id` query), instead of acting as one (`user`).
- `options.user` (`UserOption`, default: the current user): `undefined` = the ambient user (`asUser`), `null` = the account itself.
- `options.source` (`WorkflowRunSource | readonly WorkflowRunSource[]`)
- `options.trigger` (`WorkflowRunTrigger | readonly WorkflowRunTrigger[]`)
- `options.waiting` (`boolean`)
- `options.search` (`string`)
- `options.client` (`NoClick`)

Returns: The first `limit` matching runs (20 by default; `None` for all of them).

Types:

```typescript
type WorkflowRunStatus = "running" | "succeeded" | "failed";

/** How a run started: from code (`api`, the workflow's `endpoint`), in the app, on a schedule, or by an event at one
 *  of its triggers. */
type WorkflowRunSource = "api" | "endpoint" | "app" | "schedule" | "trigger";

/**
 * The kind of event that started a run whose `source` is `trigger`: a delivery to one of its trigger steps (`webhook`:
 * a webhook's, or an app's event), mail (`email`), a phone call (`call`), an agent's turn (`agent`), a visitor on its
 * agent's shared page (`shared_link`), or another run's failure it handles (`error`).
 */
type WorkflowRunTrigger = "webhook" | "email" | "call" | "agent" | "shared_link" | "error";

/**
 * Which users a read covers: `ALL_USERS`, `NO_USER`, a `User` or your id for one. Sent as the
 * `user_id` query parameter, never as the `NoClick-User` header, so it filters without acting as the user.
 */
type UserFilter = typeof ALL_USERS | typeof NO_USER | UserRef;

/** A `User` or your own id for the user. */
type UserRef = string | UserLike;

/** Anything that can name a user lazily (a `User`). */
interface UserLike {
  _userId(): Promise<string>;
}

/** `undefined` = the ambient user (from `asUser`), `null` = the account itself. */
type UserOption = UserRef | null | undefined;
```

### Workflow.getRun

```typescript
getRun(runId: string): Promise<WorkflowRun>
```

One run, with what each step did (`steps`: status, error and output, in order); an unknown id throws `NotFound`.
While it runs, each step reads as it moves (`running`, then how it ended with its output); `watch` says when, with a
`workflow_run` change naming the run (`change` `step` when a step moved, `run` when it started or ended).

Parameters:

- `runId` (`string`, required)

Returns: The `WorkflowRun`; an unknown id raises `noclick.NotFound`.

### Workflow.stopRun

```typescript
stopRun(runId: string, options?: CallOptions): Promise<WorkflowRun>
```

Stop a run that's running, however it started, as the app's stop does: the step it's on stops at once and nothing
after it runs. A run from code is its operation's cancel (the operation reads `canceled`). Takes what starting one
takes; inside `asUser` (or with `user`) only that user's runs. Resolves to the run once it stopped (or as it stands
after a few seconds). A run that already ended throws `Conflict`, as does any other that waits with nothing running
(an approval, a delay).

Parameters:

- `runId` (`string`, required)
- `options.user` (`UserOption`, default: the current user): `undefined` = the ambient user (`asUser`), `null` = the account itself.
- `options.client` (`NoClick`)

Returns: The run once it stopped (or as it stands after a few seconds). A run that already
ended raises `noclick.Conflict`, as does any other that waits with nothing running
(an approval, a delay).

Types:

```typescript
/** `undefined` = the ambient user (from `asUser`), `null` = the account itself. */
type UserOption = UserRef | null | undefined;

/** A `User` or your own id for the user. */
type UserRef = string | UserLike;

/** Anything that can name a user lazily (a `User`). */
interface UserLike {
  _userId(): Promise<string>;
}
```

### Workflow.runCounts

```typescript
runCounts(options?: ReadOptions): Promise<WorkflowRunCounts>
```

How many runs `runs()` lists: in all, `byStatus` (and how many of the running ones are `waiting`), `bySource` and
`byTrigger`. Outside `asUser` you count the runs recorded for your account; `userFilter` counts your users'.

Parameters:

- `options.userFilter` (`UserFilter`): Which users the read covers (`user_id` query), instead of acting as one (`user`).
- `options.user` (`UserOption`, default: the current user): `undefined` = the ambient user (`asUser`), `null` = the account itself.
- `options.client` (`NoClick`)

Returns: The `WorkflowRunCounts`.

Types:

```typescript
/**
 * Which users a read covers: `ALL_USERS`, `NO_USER`, a `User` or your id for one. Sent as the
 * `user_id` query parameter, never as the `NoClick-User` header, so it filters without acting as the user.
 */
type UserFilter = typeof ALL_USERS | typeof NO_USER | UserRef;

/** A `User` or your own id for the user. */
type UserRef = string | UserLike;

/** Anything that can name a user lazily (a `User`). */
interface UserLike {
  _userId(): Promise<string>;
}

/** `undefined` = the ambient user (from `asUser`), `null` = the account itself. */
type UserOption = UserRef | null | undefined;
```

### Workflow.latestOutputs

```typescript
latestOutputs(
  options?: CallOptions & { steps?: readonly StepRef[]; full?: boolean },
): Promise<LatestOutputs>
```

Each step's latest output, whatever run it's from, as the app's canvas shows the workflow when it opens: cut short
as a run's steps are unless `full`, never a secret. `steps` reads only those steps' (their ids). Inside `asUser`
(or with `user`) only that user's runs are read.

Parameters:

- `options.steps` (`readonly StepRef[]`)
- `options.full` (`boolean`)
- `options.user` (`UserOption`, default: the current user): `undefined` = the ambient user (`asUser`), `null` = the account itself.
- `options.client` (`NoClick`)

Returns: The `LatestOutputs`: `outputs` by step id, with what each `withheld`.

Types:

```typescript
/** `undefined` = the ambient user (from `asUser`), `null` = the account itself. */
type UserOption = UserRef | null | undefined;

/** A `User` or your own id for the user. */
type UserRef = string | UserLike;

/** Anything that can name a user lazily (a `User`). */
interface UserLike {
  _userId(): Promise<string>;
}

/** A step, or its id. */
type StepRef = Step | string;
```

### Workflow.approvals

```typescript
approvals(
  options?: Omit<WorkflowApprovalListOptions, "client">,
): Promise<WorkflowApproval[]>
```

Its Approval steps, newest first: those its runs wait at (`status: "pending"`), and those approved, declined or
expired: the first 20, or the first `limit` (at most 100). NoClick asks your account's owner to answer each;
your code answers one with a key naming `approvals:answer` (`approval.approve()`, `approval.decline()`).

Parameters:

- `options.status` (`WorkflowApprovalStatus`): One status; omitted, every one.
- `options.limit` (`number`): The first this many (20 unless you say, at most 100).
- `options.user` (`UserOption`): `undefined` = the ambient user (`asUser`), `null` = the account itself.
- `options.userFilter` (`UserFilter`): Which users the read covers (`user_id` query), instead of acting as one (`user`).

Returns: The first `limit` (20 by default, at most 100), each a `noclick.WorkflowApproval`.

Types:

```typescript
/** `undefined` = the ambient user (from `asUser`), `null` = the account itself. */
type UserOption = UserRef | null | undefined;

/** A `User` or your own id for the user. */
type UserRef = string | UserLike;

/** Anything that can name a user lazily (a `User`). */
interface UserLike {
  _userId(): Promise<string>;
}

type WorkflowApprovalStatus = "pending" | "approved" | "declined" | "expired";

/**
 * Which users a read covers: `ALL_USERS`, `NO_USER`, a `User` or your id for one. Sent as the
 * `user_id` query parameter, never as the `NoClick-User` header, so it filters without acting as the user.
 */
type UserFilter = typeof ALL_USERS | typeof NO_USER | UserRef;
```

### Workflow.endpoint

```typescript
endpoint(options?: { public?: boolean }): Promise<WorkflowEndpoint>
```

The workflow's HTTP endpoint, turned on if it wasn't. `public: true` lets a publishable key
call it from a web page, with per-visitor rate limits; `public: false` requires a secret key
again; leave it out to keep what it is.

Parameters:

- `options.public` (`boolean`)

Returns: The endpoint: its `url`, whether it's `public`, and the `method` to call it with.

## WorkflowRun

```typescript
interface WorkflowRun
```

One run of a workflow. `status` is `running` (a run waiting on an approval or a delay too:
`waitingOn` says on what, `null` while it runs on), `succeeded` or `failed` (`error` says why).
`outputs` holds what its final steps produced (each step that finished with nothing after it
running), by step name. `source` is how it started: `api`, `endpoint`, `schedule`, `trigger` (an
event, whose kind `trigger` names: `webhook`, `email`, …) or `app`; `inputs` and `operationId` are
set for a run started from code. `steps` says what each step did, read with one run
(`Workflow.getRun`); empty in a list.

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `string` |  |
| `workflowId` | `string | null` |  |
| `status` | `WorkflowRunStatus` |  |
| `inputs` | `JsonObject` |  |
| `outputs` | `JsonObject` |  |
| `error` | `string | null` |  |
| `source` | `string | null` |  |
| `userId` | `string | null` |  |
| `operationId` | `string | null` |  |
| `startedAt` | `Date | null` |  |
| `finishedAt` | `Date | null` |  |
| `steps` | `RunStep[]` |  |
| `raw` | `JsonObject` | The response JSON exactly as the API sent it. |
| `trigger` | `WorkflowRunTrigger | null` |  |
| `waitingOn` | `WorkflowRunWait | null` |  |

Types:

```typescript
type WorkflowRunStatus = "running" | "succeeded" | "failed";

type JsonObject = { [key: string]: unknown };

/**
 * The kind of event that started a run whose `source` is `trigger`: a delivery to one of its trigger steps (`webhook`:
 * a webhook's, or an app's event), mail (`email`), a phone call (`call`), an agent's turn (`agent`), a visitor on its
 * agent's shared page (`shared_link`), or another run's failure it handles (`error`).
 */
type WorkflowRunTrigger = "webhook" | "email" | "call" | "agent" | "shared_link" | "error";

/** What a running run waits on: an approval, a delay, or (a run from code) an agent's turn. */
type WorkflowRunWait = "approval" | "delay" | "agent_turn";
```

## RunStep

```typescript
interface RunStep
```

What one step did in a run: `status` is `succeeded`, `failed` (`error` says why) or `skipped`;
`output` is what it produced, with long lists and text cut short and never a secret (`withheld`
names, by path, what was left out). `Step.output` reads it whole.

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `string` |  |
| `name` | `string` |  |
| `status` | `string` |  |
| `error` | `string | null` |  |
| `output` | `unknown` |  |
| `withheld` | `string[]` |  |

## StepOutput

```typescript
interface StepOutput
```

What one step produced in one run (`Step.outputs`, `Step.output`). `runId` is the run's id (`Workflow.getRun` reads
a run from code by it), `source` how it started (as `WorkflowRun.source` says it), `status` the step's there
(`succeeded`, `failed` with `error`, `skipped`). A trigger's deliveries are its outputs too: `noEvent` marks a manual
run's placeholder for one that got no event. `iteration` is set for one iteration of a step that runs in a loop.

A listing gives a one-line `preview` (`path=value` pairs); one read gives the `output`, with long text and lists cut
short (`truncated`) unless read `full`, or the part at `path`. Never a secret: `withheld` names, by path, what was
left out (a request's `Authorization` header, a key, a token).

| Attribute | Type | Description |
| --- | --- | --- |
| `stepId` | `string` |  |
| `runId` | `string` |  |
| `workflowId` | `string | null` |  |
| `iteration` | `number | null` |  |
| `source` | `string | null` |  |
| `status` | `string | null` |  |
| `error` | `string | null` |  |
| `createdAt` | `Date | null` |  |
| `noEvent` | `boolean` |  |
| `preview` | `string | null` |  |
| `output` | `unknown` |  |
| `path` | `string | null` |  |
| `full` | `boolean` |  |
| `truncated` | `boolean` |  |
| `withheld` | `string[]` |  |
| `raw` | `JsonObject` | The response JSON exactly as the API sent it. |

Types:

```typescript
type JsonObject = { [key: string]: unknown };
```

## WorkflowEndpoint

```typescript
interface WorkflowEndpoint
```

The URL a workflow answers at: send `method` (`POST`) with the inputs as a JSON body, and the
run's outputs come back (a run longer than 30 seconds answers `202` with its operation). A
`public` endpoint also takes a publishable key (`nk_pub_...`) that lists it, so a web page can
call it; otherwise it needs a secret key.

| Attribute | Type | Description |
| --- | --- | --- |
| `url` | `string` |  |
| `public` | `boolean` |  |
| `method` | `string` |  |
| `raw` | `JsonObject` | The response JSON exactly as the API sent it. |

Types:

```typescript
type JsonObject = { [key: string]: unknown };
```

## WorkflowBuild

```typescript
class WorkflowBuild extends Operation
```

A build of a workflow from a description (kind `workflow.build`). It's an `Operation`: `wait()`
resolves to the `WorkflowBuildResult`, or throws why the build failed.

While it builds, `step` is `building`. When the builder needs something it's `awaiting_human`
(step `asking`) and `question` says what: each input is a human request NoClick sent the person
whose build it is, and the build goes on once they answer; or answer it all now with `answer()`.
`wait()` stops at a question it hasn't shown you, throwing `AnswerRequired` with it;
called again, it waits through that question for its answer. `nextQuestion()` resolves as soon as
there is one.

| Attribute | Type | Description |
| --- | --- | --- |
| `workflowId` | `string | null` |  |
| `question` | `BuildQuestion | null` | What the build waits on (`null` unless it's asking). |

### WorkflowBuild.nextQuestion

```typescript
nextQuestion(options?: { timeoutS?: number }): Promise<BuildQuestion | null>
```

Resolve once the build asks something (its `question`) or finishes (`null`: `wait()` gives the result).

Parameters:

- `options.timeoutS` (`number`)

Returns: The question to answer, or `None` once the build is done.

### WorkflowBuild.answer

```typescript
answer(
  values?: JsonObject,
  options?: {
    message?: string;
    skip?: boolean;
    secretValues?: Record<string, Record<string, string>>;
  },
): Promise<this>
```

Answer the question the build waits on, all at once, by input id: the build goes on now. Each
value answers its input's human request as your key; those you leave unanswered are withdrawn.
A choice, words, or for a `credential` input a connection's ref or name; an `env` input's values
go in `secretValues` (`{ [inputId]: { KEY: value } }`), kept as the account's secret and never
shown to a model. An account or a secret takes a key acting for the whole account. `message`
tells the builder anything else, `skip: true` goes on without answering. Resolves to this build,
`running` again.

Parameters:

- `values` (`JsonObject`)
- `options.message` (`string`)
- `options.skip` (`boolean`)
- `options.secretValues` (`Record<string, Record<string, string>>`)

Returns: This build, `running` again.

Types:

```typescript
type JsonObject = { [key: string]: unknown };
```

## WorkflowBuildResult

```typescript
interface WorkflowBuildResult
```

A finished build: what the builder says it did (`summary`), the workflow's `steps` as they now
stand, and, when it published the workflow's app, `published` (`state` is `published`,
`renamed` or `unpublished`; unpublished, `trashId` restores it until `restorableUntil`).

Beside the builder's words, facts no model wrote: whether it `built` anything (`false`: the
workflow is as it was, whatever `summary` says), the `version` it ended on (what
`edit({ ifVersion })` takes), its `readiness` as `Workflow.readiness` reads it, and each step's
verdict by step id (`verdicts`: `config_valid`, `validation_error`, `missing_required`, `left_for_user` and
`references`, as an edit answers them). `references` lists, across the workflow, each read of another step's
output that gets no value, said in a sentence (`message`): `{step, field, source, key, known_keys, message}` for a
key the `source` step's known output lacks (a run reads nothing there and still succeeds, so a test run never
shows it), or `{step, field, source, reference, missing, near, message}` for a step the workflow doesn't have; a
step whose output nothing has shown isn't judged. `sentBack` counts the times the build went back to the builder
for settings the run engine rejects or reads that get no value (at most 2) before it finished. A fact NoClick
couldn't read is `null` and named in `unread`: then nothing says the workflow is ready.

| Attribute | Type | Description |
| --- | --- | --- |
| `workflowId` | `string | null` |  |
| `summary` | `string | null` |  |
| `steps` | `WorkflowStep[]` |  |
| `appUrl` | `string | null` |  |
| `published` | `{ state: string; url: string | null; trashId: string | null; restorableUntil: string | null } | null` |  |
| `built` | `boolean | null` |  |
| `version` | `number | null` |  |
| `readiness` | `WorkflowReadiness | null` |  |
| `verdicts` | `Record<string, JsonObject> | null` |  |
| `references` | `JsonObject[] | null` |  |
| `sentBack` | `number` |  |
| `unread` | `string[]` |  |
| `raw` | `JsonObject` | The response JSON exactly as the API sent it. |

Types:

```typescript
/** Whether a workflow is set up to run: its `status` and the `issues` in the way. */
interface WorkflowReadiness {
  status: string;
  /** What `status` means, in a sentence. */
  meaning: string;
  /**
   * What's in the way of it working, a step whose last run failed among them. An issue's `code` says whose move it
   * is: `missing_credentials` waits on an account, `left_for_user` on a required setting the step leaves for its
   * person to fill in, and `invalid_config` is a setting a run would refuse.
   */
  issues: { step: string | null; code: string; message: string }[];
  /** What doesn't stop it running: an agent's tool with no account connected, which only a call to it needs. */
  warnings: { step: string | null; code: string; message: string }[];
  /** The steps no run has completed yet: set up, but nothing has shown they work. */
  unverified: { step: string | null; code: string; message: string }[];
}

type JsonObject = { [key: string]: unknown };
```

## WorkflowDraftResult

```typescript
interface WorkflowDraftResult
```

A finished draft: the workflow's `version` once the drafted steps were written (one version of its history,
`historyVersion`; `changed` false when the drafter changed nothing), a `summary` of what changed, and for each step
it drafted (`steps`, by id) the verdict an edit answers (`config_valid`, `validation_error`, `missing_required`,
`left_for_user`, `references`) beside `drafted`, its `operation`, the `settings` it wrote, the ones it left for a
person (`unfilled`: a choice read from the connected account, a value only they know; a required one reads as
`left_for_user` until it's filled in) and, for a step it couldn't draft (left as it was), its `error`.

| Attribute | Type | Description |
| --- | --- | --- |
| `workflowId` | `string` |  |
| `mode` | `string` |  |
| `version` | `number | null` |  |
| `historyVersion` | `number | null` |  |
| `changed` | `boolean` |  |
| `summary` | `string | null` |  |
| `steps` | `Record<string, JsonObject>` |  |
| `raw` | `JsonObject` | The response JSON exactly as the API sent it. |

Types:

```typescript
type JsonObject = { [key: string]: unknown };
```

## WorkflowStep

```typescript
interface WorkflowStep
```

One step of a workflow, as the app shows it: its `name`, its kind (`type`, like
`automation-gmail` or `trigger-cron`) and the `operation` it does there (`null` for a step with
one thing to do). Read with one workflow, a step also says whether it's `enabled`, its `settings`
(never a secret; long values cut short), its `connection` (`null` for a step that takes no
account) and, for a trigger, its `trigger` state (`null` for any other step).

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `string` |  |
| `name` | `string` |  |
| `type` | `string` |  |
| `operation` | `string | null` |  |
| `enabled` | `boolean` |  |
| `settings` | `JsonObject` |  |
| `connection` | `StepConnection | null` |  |
| `trigger` | `StepTrigger | null` |  |

Types:

```typescript
type JsonObject = { [key: string]: unknown };

/** Whether a step that takes an account has one, and whether it works (`healthy` is `null` when NoClick can't tell). */
interface StepConnection {
  attached: boolean;
  healthy: boolean | null;
  hint: string | null;
}

/** A trigger step's state: what keeps it from firing, and when it fires next. */
interface StepTrigger {
  error: string | null;
  pausedReason: string | null;
  nextRun: string | null;
}
```

## WorkflowApproval

```typescript
class WorkflowApproval
```

An Approval step a run of one of your workflows waits at (or waited at), as its owner sees it.

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `string` |  |
| `workflowId` | `string` |  |
| `workflowName` | `string | null` |  |
| `runId` | `string` | The run that waits at it (`workflow.getRun(runId)`). |
| `step` | `string` | The Approval step's id in the workflow. |
| `title` | `string | null` | What it asks, as the step's title says it. |
| `fields` | `WorkflowApprovalField[]` | Its form's fields. |
| `values` | `JsonObject` | The form's values by field name: as the run asked, then as it was answered. |
| `status` | `WorkflowApprovalStatus` |  |
| `createdAt` | `Date | null` |  |
| `expiresAt` | `Date | null` | When the approver it waits on must answer by (7 days after it was asked, unless the step's `expires_in_s` says otherwise; an escalation gives the next approver theirs). |
| `approver` | `JsonObject` | Who it waits on (or waited on last): `kind` `owner`, `person` (with `email`), `user` (`user_id`), `agent` (`agent_id`) or `code`: the step's approver, else your account's, else the owner. |
| `onTimeout` | `"decline" | "escalate" | null` | What happens if they don't answer by `expiresAt`: `decline` (the run ends) or `escalate` (the next approver up answers it, finally the owner). |
| `decidedAt` | `Date | null` |  |
| `decidedBy` | `"owner" | "person" | "agent" | "code" | "app" | null` | Who decided: `owner` (signed in, or from NoClick's link or the web chat), `person` (a person or user named approver, from the link NoClick emailed them), `agent` (an agent named approver), `code` or `app` (someone who may edit the workflow, in the NoClick app); null while it waits. |
| `decidedByKey` | `{ key_id: string; key_name: string | null } | null` | The key whose code decided (`key_id`, `key_name`); null otherwise. |
| `decidedByAgent` | `{ agent_id: string; name: string | null } | null` | The agent named approver that decided (`agent_id`, `name`); null otherwise. |
| `note` | `string | null` | What whoever decided wrote with it. |
| `sentTo` | `string[]` | Where NoClick sent the owner its link: `whatsapp`, `imessage`, `email`, or `web` (a card in the chat). |

Types:

```typescript
/** One field of an Approval step's form. */
interface WorkflowApprovalField {
  name: string;
  type: string;
  label: string;
  description: string;
  required: boolean;
  options: string[] | null;
}

type JsonObject = { [key: string]: unknown };

type WorkflowApprovalStatus = "pending" | "approved" | "declined" | "expired";
```

### WorkflowApproval.fromId

```typescript
static fromId(
  workflow: WorkflowRef,
  approvalId: string,
  options?: Pick<CallOptions, "client">,
): WorkflowApproval
```

A lazy reference to one of a workflow's Approval steps by its id (an event's `data.id`).

Parameters:

- `workflow` (`WorkflowRef`, required)
- `approvalId` (`string`, required)
- `options.client` (`NoClick`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: The approval; it loads the first time it's used.

### WorkflowApproval.list

```typescript
static list(
  workflow: WorkflowRef,
  options?: WorkflowApprovalListOptions,
): Promise<WorkflowApproval[]>
```

A workflow's Approval steps, newest first: the first 20, or the first `limit` (at most 100). Read as your
account, with a key holding `workflows` or `approvals:answer`.

Parameters:

- `workflow` (`WorkflowRef`, required)
- `options.status` (`WorkflowApprovalStatus`): One status; omitted, every one.
- `options.limit` (`number`): The first this many (20 unless you say, at most 100).
- `options.client` (`NoClick`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.
- `options.userFilter` (`UserFilter`): Which users the read covers (`user_id` query), instead of acting as one (`user`).
- `options.user` (`UserOption`): `undefined` = the ambient user (`asUser`), `null` = the account itself.

Returns: Each approval as its owner sees it.

Types:

```typescript
type WorkflowApprovalStatus = "pending" | "approved" | "declined" | "expired";

/**
 * Which users a read covers: `ALL_USERS`, `NO_USER`, a `User` or your id for one. Sent as the
 * `user_id` query parameter, never as the `NoClick-User` header, so it filters without acting as the user.
 */
type UserFilter = typeof ALL_USERS | typeof NO_USER | UserRef;

/** A `User` or your own id for the user. */
type UserRef = string | UserLike;

/** Anything that can name a user lazily (a `User`). */
interface UserLike {
  _userId(): Promise<string>;
}

/** `undefined` = the ambient user (from `asUser`), `null` = the account itself. */
type UserOption = UserRef | null | undefined;
```

### WorkflowApproval.approve

```typescript
approve(options?: WorkflowApprovalAnswer): Promise<this>
```

Approve it from your own code, with one of your account's secret keys that names the `approvals:answer` scope:
the run goes on down the step's approved branch, once, with `values` (by field name) as the form's values where
you give them. Throws `PermissionDenied` for a key without the scope or one acting for a user, `Conflict` once
it was answered, and `Expired` once it lapsed unanswered.

Parameters:

- `options.note` (`string`): Why, kept with the answer.
- `options.values` (`JsonObject`): The form's values as you answer it, by field name; left out, as the run asked.

Returns: This approval, answered: `status` is `approved`, `decided_by` is `code`.

Types:

```typescript
type JsonObject = { [key: string]: unknown };
```

### WorkflowApproval.decline

```typescript
decline(options?: WorkflowApprovalAnswer): Promise<this>
```

Decline it from your own code, as `approve` answers it: the run goes on down the step's rejected branch.

Parameters:

- `options.note` (`string`): Why, kept with the answer.
- `options.values` (`JsonObject`): The form's values as you answer it, by field name; left out, as the run asked.

Returns: This approval, answered: `status` is `declined`.

Types:

```typescript
type JsonObject = { [key: string]: unknown };
```

## WorkflowRehearsal

```typescript
interface WorkflowRehearsal
```

A workflow's test run, as the app's Test Run plays one: a staged event arrived at one of its triggers
(`trigger`: `{step_id, type, name}`) and the agents it reached took a real turn while a simulated world
answered every tool call, so nothing was sent and no account was touched. `testRun` is the run it played
(`{key, name, custom}`; `null` for a message you typed). `reply` is the agent's closing words; `toolCalls` the
calls it made, each with its `tool`, `arguments` and the `result` the world answered (and `outbound`, the message
it would have sent, for a call that carries one); `transcript` the run step by step (`role` `assistant` steps, its
`text`, and `tool` steps; a coding harness's own shell and file steps carry `source` `harness`). `scenario` is the
world it ran in, `note` says when it wrote nothing or what it did to act was simulated, and `costUsd` is what it
cost you.

| Attribute | Type | Description |
| --- | --- | --- |
| `workflowId` | `string | null` |  |
| `testRun` | `JsonObject | null` |  |
| `trigger` | `JsonObject | null` |  |
| `reply` | `string` |  |
| `toolCalls` | `JsonObject[]` |  |
| `transcript` | `JsonObject[]` |  |
| `scenario` | `string | null` |  |
| `note` | `string | null` |  |
| `costUsd` | `number | null` |  |
| `operationId` | `string | null` |  |
| `raw` | `JsonObject` | The response JSON exactly as the API sent it. |

Types:

```typescript
type JsonObject = { [key: string]: unknown };
```

## WorkflowTestRun

```typescript
interface WorkflowTestRun
```

A test run a workflow offers (`Workflow.testRuns`), as its Test Run screen lists it: a staged situation for one of
its triggers, or one the workflow authored (`custom`; `edit().addTestRun`). `key` and `name` each name it to
`rehearse`. `trigger` is what it stages on: the trigger step's `type`, the type's `label` in the app and the step's
`operation`. `message` is the staged message as the run would stage it (`title`, `body`, and where it has them
`author`, `handle`, `meta` and `time`): an offered situation's with the workflow's edits, an authored run's own.

| Attribute | Type | Description |
| --- | --- | --- |
| `key` | `string` |  |
| `name` | `string` |  |
| `custom` | `boolean` |  |
| `trigger` | `{ type: string; label: string | null; operation: string | null }` |  |
| `message` | `JsonObject` |  |
| `raw` | `JsonObject` | The response JSON exactly as the API sent it. |

Types:

```typescript
type JsonObject = { [key: string]: unknown };
```

## WorkflowGraph

```typescript
class WorkflowGraph
```

A workflow's definition as it was read, at `version`: its `name`, `description` and `settings` (its variables,
its Test Runs and the rest), its `steps` (each a `Step` you can change), its `notes` (steps of type `stickyNote`)
and its `edges`.

A secret is never read back, and writing a step or the settings back without one keeps it: `withheld` names, by
step id, the paths of the settings left out (`api_key`, `auth.password`, `headers[0].value`), `settingsWithheld`
those of the workflow's own settings (`variable_definitions[1].value`: a variable's value, whatever its name; one
with no value yet reads as blank, so you can tell which still need one), and `variablesWithheld` the graph's own
variables. The graph a `Conflict` carries holds the steps and edges alone: its `name`, `description`,
`settings` and `settingsWithheld` are `null`. `displayMetadata` is what the app shows of the workflow (its
canvas's viewport, the step open in its panel), read with `graph()`: never part of a version.

| Attribute | Type | Description |
| --- | --- | --- |
| `workflowId` | `string` |  |
| `version` | `number` |  |
| `name` | `string | null` |  |
| `description` | `string | null` |  |
| `settings` | `JsonObject | null` |  |
| `settingsWithheld` | `string[] | null` |  |
| `steps` | `Step[]` |  |
| `notes` | `Step[]` |  |
| `edges` | `GraphEdge[]` |  |
| `withheld` | `Record<string, string[]>` |  |
| `variablesWithheld` | `string[]` |  |
| `raw` | `JsonObject` | The response JSON exactly as the API sent it. |
| `displayMetadata` | `JsonObject | null` |  |
| `access` | `"owner" | "editor" | "viewer" | null` | What you may do with it, as the app's canvas judges it: `owner`, `editor` or `viewer` (null for a conflict's). |
| `agent` | `{ id: string; name: string; yours: boolean } | null` | The agent whose own flow it is (`yours`: your account's own agent), else null. |

Types:

```typescript
type JsonObject = { [key: string]: unknown };

/**
 * How two steps of a graph are wired: `kind` is `data`, or `tools` for a step wired into an agent as its tools;
 * `handle` names which output of `from` it leaves (`null` for its only one), `targetHandle` which input of `to` it
 * joins, for a step with several (a code step's `state`).
 */
interface GraphEdge {
  id: string | null;
  from: string;
  to: string;
  kind: "data" | "tools";
  handle: string | null;
  targetHandle: string | null;
}
```

### WorkflowGraph.step

```typescript
step(ref: string): Step
```

One of its steps or notes, by id, else by its name in the app. None by that id or name throws `NotFound`; a
name two steps share throws `Conflict` (name it by id).

Parameters:

- `ref` (`string`, required)

Returns: The step. None by that id or name raises `noclick.NotFound`; a name two steps
share raises `noclick.Conflict` (name it by id).

## Step

```typescript
class Step
```

One step of a workflow's graph: its trigger, an app's operation, an agent, a note. `Workflow.graph()` reads them
all; `Workflow.step(id)` is a handle to one by id (`await step.hydrate()` loads its fields).

Its fields are as stored: `type` (`automation-gmail`, `agent`, `trigger-cron`), its `name` in the app, the
`operation` it does, whether it's `enabled`, its `settings` (never a secret: `withheld` names the ones left out),
its `connections` (each slot's connected account, by id), where it sits (`position`) and the output it gives on
test runs instead of running (`mockOutput`). A note on the canvas is a step of type `stickyNote` (its text is
`settings.content`), listed in `WorkflowGraph.notes`.

Each method is one edit, applied as its own version: the step comes back as written, with what the edit said
about it (`notes`) and whether it's ready to run (`verdict`). To change several things at once, or only if the
workflow hasn't changed since you read it, use `Workflow.edit()`.

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `string` | Its id in the workflow, which edits name it by. |
| `workflow` | `Workflow` | The workflow it's a step of. |
| `type` | `string` | What kind of step it is: `automation-gmail`, `agent`, `trigger-cron`, `stickyNote` for a note. |
| `name` | `string | null` | Its name in the app (`null` when it has none and the app shows its type). |
| `operation` | `string | null` | What it does, one of its type's operations (`null` for a step with one thing to do). |
| `enabled` | `boolean` | Whether it runs: a step switched off (`update({ enabled: false })`) is passed over. |
| `settings` | `JsonObject` | Its settings, by field name, as stored (a secret is never read back: see `withheld`). |
| `connections` | `Record<string, string>` | The accounts connected to it: each slot (a connection type, like `gmail_oauth`) to the id of the account there, which the connection holding it names as its `credentialId`. |
| `position` | `Position | null` | Where it sits on the canvas. |
| `mockOutput` | `unknown` | What it outputs on test runs instead of running (`mock()`), or `null`. |
| `withheld` | `string[]` | The settings left out of `settings` because they hold a secret (a key, a token, a password), each by its path: `api_key`, `auth.password`, `headers[0].value`. An update that leaves them out keeps them. |
| `verdict` | `JsonObject | null` | Whether it's ready to run, as the last edit through this handle that touched it judged: `config_valid`, and when it isn't, `validation_error`, `missing_required` and `left_for_user` (the required settings it leaves for its person to fill in, a value only they know: they wait on that person and are never part of the error); an agent's `agent_credential_hint`; and `references` (see `references`). `null` until an edit judged it (a read doesn't). |
| `references` | `JsonObject[]` | Each read of another step's output in its settings (`{{ $('x').key }}`) that won't resolve at run time, as the last edit through this handle that touched it judged: `{field, step, key, known_keys}` for a key `x`'s output isn't known to have (`known_keys`: what it has, from what `x` declares, its latest output in this workflow, or what your account's own runs of its type showed), or `{field, step, reference, missing, near}` for a step `x` the workflow doesn't have (`near`: the one it likely means). A read of a step whose output nothing has shown yet isn't judged. Empty when every read resolves, or before an edit judged it. |
| `notes` | `JsonObject` | What the last edit through this handle answered for its change, beyond the step's id: `changed` for an update, the edge for a connect, and anything the edit did on its own, such as `resolutions`, `harness_switch`, `coerced_values` or `stripped_trigger_refs`. |

Types:

```typescript
type JsonObject = { [key: string]: unknown };

/** Where a step sits on the canvas. */
interface Position {
  x: number;
  y: number;
}
```

### Step.options

```typescript
options(field: string, query?: StepOptionsQuery): Promise<StepOptions>
```

The choices `field` takes, as the app's dropdown lists them: read from the account the step connects to (a
Google account's spreadsheets, a Slack workspace's channels) by the step's own lookup, with its settings as saved
and `settings` laid over them (what a list that depends on another reads, like the tabs of a spreadsheet you
haven't saved yet). `search` narrows them where the service can search. A page at a time: pass `pageToken` its
`nextPageToken`. A connection whose owner reviews its calls holds the lookup for them (`ApprovalRequired`).
A step the workflow doesn't hold yet (one a canvas added and hasn't saved) lists its choices by its `type`, and
`connection` names the account to read from in place of the one the step holds. Takes read access to the workflow:
whoever can change it reads through the step's account as a run does, anyone else only through an account that's
theirs to use.

Parameters:

- `field` (`string`, required)
- `query` (`StepOptionsQuery`)

Returns: The `StepOptions`: `options` (each a `StepOption`), `next_page_token` and
`withheld`.

Types:

```typescript
/** What `Step.options` sends beside the field. */
interface StepOptionsQuery {
  /** The step's settings as its form holds them, over the saved ones: what a list that depends on another reads. */
  settings?: JsonObject;
  /** Narrows the choices, where the service can search them. */
  search?: string;
  /** The `nextPageToken` of the page before. */
  pageToken?: string;
  /** The step's type (`automation-slack`), for a step the workflow doesn't hold yet (one a canvas hasn't saved). */
  type?: string;
  /** The connected account to read from, in place of the one the step holds: its ref (`Connection.ref`) or id. */
  connection?: string;
}

type JsonObject = { [key: string]: unknown };
```

### Step.value

```typescript
value(field: string, options?: { settings?: JsonObject }): Promise<StepValue>
```

A widget's value on the step, as the app loads it beside the step's settings: a trigger's address, minted and
registered where its events come from (`webhook_url`), an app's event subscription (`subscription_status`), the
files in a filesystem step's volume (`file_browser`), an alarm's schedules (`active_alarms`), an MCP step's
hosted link (`hosted_url`). `settings` are laid over the step's saved ones. One that mints or registers something
changes the account, and takes what changing the workflow takes; one that only reads (a list, an id from the
step's account) takes read access. A hosted MCP link's URL is its capability, so no MCP connection loads it.

Parameters:

- `field` (`string`, required)
- `options.settings` (`JsonObject`)

Returns: The `StepValue`: `value`, or `values` where it fills several settings at once,
and `withheld`.

Types:

```typescript
type JsonObject = { [key: string]: unknown };
```

### Step.update

```typescript
update(update: StepUpdate): Promise<this>
```

Change its settings, name or operation, or switch it off or on. `settings` merge into what it has (a nested
object merges, any other value replaces, and `null` takes that setting out, a secret included); a field you leave
out is never touched. An agent given another
`model` on another harness drops the old harness's own settings and connections, as the app does
(`notes.harness_switch` says what went). A value that can't be is refused with `InvalidRequest` naming the
field, and nothing changes. Resolves to this step as written, with `notes` and `verdict`.

Parameters:

- `update` (`StepUpdate`, required)

Returns: This step as written, with `notes` and `verdict`.

Types:

```typescript
/** What `Step.update` (and a batch's `updateStep`) changes; a field left out is never touched. */
interface StepUpdate {
  /**
   * Settings to change, merged into the step's (a nested object merges, any other value replaces, and `null` takes
   * that setting out, a secret included).
   */
  settings?: JsonObject;
  name?: string;
  operation?: string;
  /** `false` switches the step off; `true` back on. */
  enabled?: boolean;
  /**
   * An agent step's secrets: the account's own, in its shell's environment on every run, as `Secret` objects or
   * their names, replacing the ones it had (`[]` takes them all off). Only a key acting for the whole account of the
   * workflow's owner gives a step one, and an agent's own tools as your approval settings let them
   * (`attach_connection`, allowed by default); any other caller keeps or drops what it was given. Their values never
   * show in a read of the workflow, nor to the agent's model.
   */
  secrets?: SecretRef[];
  /**
   * Settings to leave for the step's person to fill in, by name: a value only they know (their own address, number
   * or URL). Each is cleared and noted on the step, so a required one reads `left_for_user` in the step's `verdict`
   * and the workflow's readiness, never an invalid setting, until it's given a value; giving it one takes it off the
   * note. It's how code or an agent that builds a workflow says "this one is yours" without making a value up. A
   * name that isn't one of the step's settings, or one given a value in the same call, is refused; so is a value
   * that only stands in for one (`YOUR_PHONE_NUMBER`, `<your website url>`), naming this instead.
   */
  leftForUser?: string[];
}

type JsonObject = { [key: string]: unknown };

/** A secret to pass: a `Secret`, its id, or its name (the user's own, else the account's). */
type SecretRef = string | Secret;
```

### Step.patch

```typescript
patch(field: string, patch: string): Promise<this>
```

Change part of one long text setting (an agent's instructions, a step's code) with a patch: `@@` lines naming
text that's there, then `-` lines to remove and `+` lines to add.

Parameters:

- `field` (`string`, required)
- `patch` (`string`, required)

Returns: This step as written.

### Step.remove

```typescript
remove(): Promise<void>
```

Take the step out of the workflow, with its edges. A trigger's schedule or webhook stops with it. Removing a step
that holds an app, conversations or files deletes them for good, so it may be held for the account's owner
(`ApprovalRequired`), as a batch is (`Workflow.edit`).

### Step.connect

```typescript
connect(
  other: StepRef,
  options?: { kind?: "data" | "tools"; handle?: string; targetHandle?: string },
): Promise<this>
```

Wire this step into `other`. `kind: "data"` runs `other` after it with its output; `kind: "tools"` makes its
operations tools of `other`, an agent (or an MCP step). `handle` names which of this step's outputs, for a step
with several, and `targetHandle` which of `other`'s inputs (a code step's `state`). Connecting what's already
connected changes nothing; `notes` holds the edge.

Parameters:

- `other` (`StepRef`, required)
- `options.kind` (`"data" | "tools"`, default `"data"`)
- `options.handle` (`string`)
- `options.targetHandle` (`string`)

Returns: This step; `notes` holds the edge (`edge_id`, `kind`).

Types:

```typescript
/** A step, or its id. */
type StepRef = Step | string;
```

### Step.disconnect

```typescript
disconnect(other: StepRef, options?: { handle?: string }): Promise<this>
```

Remove the edge from this step to `other`; one that isn't there throws `InvalidRequest`.

Parameters:

- `other` (`StepRef`, required)
- `options.handle` (`string`)

Returns: This step.

Types:

```typescript
/** A step, or its id. */
type StepRef = Step | string;
```

### Step.setConnection

```typescript
setConnection(
  connection: Connection | string | null,
  options?: { slot?: string },
): Promise<this>
```

Connect an account to the step: one of the account's own connections, as a `Connection` (connected in the app,
`credential:<id>`, or a named one), its ref or id, or a named connection's name; the step takes the account it
holds. Its slot is the account's own type unless `slot` names it; `null` with `slot` takes the account in that
slot off. One of a user's connections, one holding no working account, or one your account may not use is
refused (`InvalidRequest` naming it), as is one of a type the step doesn't take; a caller that doesn't act for
the whole account (a user's key, an app's code) only keeps one the workflow already uses. An agent's own tools
attach your account's own connections in your account's own workflows, never another member's, a user's or one
held for someone else, as your approval settings let them (`attach_connection`: allowed by default; asked, the
edit waits for the owner's yes, `ApprovalRequired`).

Parameters:

- `connection` (`Connection | string | null`, required)
- `options.slot` (`string`)

Returns: This step, its `connections` as written.

### Step.mock

```typescript
mock(output: unknown): Promise<this>
```

Have the step give `output` on test runs instead of running, so the steps after it can be tried.

Parameters:

- `output` (`unknown`, required)

Returns: This step, its `mock_output` set.

### Step.unmock

```typescript
unmock(): Promise<this>
```

Have the step run for real on test runs again.

Returns: This step.

### Step.run

```typescript
run(
  options?: Omit<WorkflowRunOptions, "fromStep">,
): Promise<Operation<WorkflowRun>>
```

Run the workflow from this step: it and what comes after it (`only: true`: it alone), the steps before it giving
the outputs they last stored. `Workflow.run` with `fromStep` says more.

Parameters:

- `options.only` (`boolean`): With `fromStep`: run that step alone, nothing after it.
- `options.user` (`UserOption`, default: the current user): `undefined` = the ambient user (`asUser`), `null` = the account itself.
- `options.idempotencyKey` (`string`): Makes a retried create safe: the same key returns the first result. Generated when omitted.
- `options.client` (`NoClick`)

Returns: An operation whose `.wait()` gives the finished `WorkflowRun`.

Types:

```typescript
/** `undefined` = the ambient user (from `asUser`), `null` = the account itself. */
type UserOption = UserRef | null | undefined;

/** A `User` or your own id for the user. */
type UserRef = string | UserLike;

/** Anything that can name a user lazily (a `User`). */
interface UserLike {
  _userId(): Promise<string>;
}
```

### Step.outputs

```typescript
outputs(
  options?: CallOptions & { search?: string; limit?: number | null },
): Promise<StepOutput[]>
```

What the step produced, run by run, newest first, each a `StepOutput` with its run, how that run started, the
step's status there and a one-line `preview`. A trigger's deliveries are its outputs (`noEvent` marks a manual
run's placeholder). `search` keeps those holding the text (any case), reading 100 at a time. Inside `asUser` (or
with `user`) only the runs recorded for that user are read. The newest `limit` (10 by default; `null` for every
one).

Parameters:

- `options.search` (`string`)
- `options.limit` (`number | null`): Return at most this many.
- `options.user` (`UserOption`, default: the current user): `undefined` = the ambient user (`asUser`), `null` = the account itself.
- `options.client` (`NoClick`)

Returns: The newest `limit` (10 by default; `None` for every one).

Types:

```typescript
/** `undefined` = the ambient user (from `asUser`), `null` = the account itself. */
type UserOption = UserRef | null | undefined;

/** A `User` or your own id for the user. */
type UserRef = string | UserLike;

/** Anything that can name a user lazily (a `User`). */
interface UserLike {
  _userId(): Promise<string>;
}
```

### Step.output

```typescript
output(runId: string, options?: StepOutputOptions): Promise<StepOutput>
```

What the step produced in one run (`runId`, as `outputs()` or `Workflow.runs()` name it): its `output`, long text
and lists cut short unless `full`, or only the part at `path` (`payload.items[0].id`, as a preview names it).
`iteration` reads one iteration of a step that runs in a loop. Never a secret (`withheld`); a path to one throws
`InvalidRequest`, as does a path that isn't there (naming what is). A run the step stored nothing in throws
`NotFound`.

Parameters:

- `runId` (`string`, required)
- `options.path` (`string`)
- `options.full` (`boolean`)
- `options.iteration` (`number`)
- `options.user` (`UserOption`, default: the current user): `undefined` = the ambient user (`asUser`), `null` = the account itself.
- `options.client` (`NoClick`)

Returns: The `StepOutput`; a run the step stored nothing in raises `noclick.NotFound`.

Types:

```typescript
/** `undefined` = the ambient user (from `asUser`), `null` = the account itself. */
type UserOption = UserRef | null | undefined;

/** A `User` or your own id for the user. */
type UserRef = string | UserLike;

/** Anything that can name a user lazily (a `User`). */
interface UserLike {
  _userId(): Promise<string>;
}
```

### Step.previewExpression

```typescript
previewExpression(
  expression: string,
  options?: CallOptions & { samples?: JsonObject },
): Promise<ExpressionPreview>
```

What an expression in one of the step's settings gives, evaluated as a run evaluates it (what goes inside `{{ }}`,
like `$('hook').order_id` or `$json.items.length`), as the app's editor previews it while you type. It's evaluated
against what every other step last stored (never a secret, so an expression reaching one finds nothing there),
or against `samples`, each step's output by step id (`vars` the workflow's variables). `$json` is the step's one
input's output, when it has one. Changes nothing; an expression that fails resolves with `ok` false and its
`error`.

Parameters:

- `expression` (`string`, required)
- `options.samples` (`JsonObject`)
- `options.user` (`UserOption`, default: the current user): `undefined` = the ambient user (`asUser`), `null` = the account itself.
- `options.client` (`NoClick`)

Returns: The `ExpressionPreview`; an expression that fails has `ok` False and its `error`.

Types:

```typescript
/** `undefined` = the ambient user (from `asUser`), `null` = the account itself. */
type UserOption = UserRef | null | undefined;

/** A `User` or your own id for the user. */
type UserRef = string | UserLike;

/** Anything that can name a user lazily (a `User`). */
interface UserLike {
  _userId(): Promise<string>;
}

type JsonObject = { [key: string]: unknown };
```

### Step.clearState

```typescript
clearState(): Promise<ClearedStepState>
```

Forget what the step keeps between runs, as the app's Clear state does: its state (an RSS step's seen items, a
State step's values) and its conversations (an agent step's threads), so its next run starts fresh. Clearing an
agent step deletes its conversations for good: a deletion, which through MCP waits for your account's owner (preview
it with `POST /v1/delete_previews`). Takes what changing the workflow takes, and always acts for your account, never
one of your users: an agent step's threads are every user's.

Returns: How many state records and conversations were deleted.

### Step.publish

```typescript
publish(options?: PublishOptions): Promise<StepPublication>
```

Put this interface step's app live as the app's canvas does, with no build: at `subdomain` the first time
(`morrow` is morrow.noclick.app); again, the saved edits at the address it has (a `subdomain` other than its own
throws `Conflict`: `renameApp` moves it). An app in the trash comes back where it was. Takes what changing the
workflow takes, and through MCP `deploy`, as `Workflow.publish` does.

Parameters:

- `options.title` (`string`)
- `options.subdomain` (`string`)

Returns: The `StepPublication`: `state` `published`, the app's `url`, its
`project_id` and `subdomain`, and the release (`deployment_id`).

### Step.renameApp

```typescript
renameApp(subdomain: string): Promise<StepPublication>
```

Move this interface step's app to `subdomain`, publishing no edits; its old address stops answering.

Parameters:

- `subdomain` (`string`, required)

Returns: The `StepPublication`: `state` `renamed`, the new `url` and where it was
(`previous_url`).

### Step.unpublish

```typescript
unpublish(): Promise<StepPublication>
```

Take this interface step's app down, to the trash: its public URL stops answering and its page's key stops
working. For 30 days its address stays its own, and restoring it (or `publish()`) brings it back there with the
same key; the result's `trashId` restores it. One not published changes nothing.

Returns: The `StepPublication`: `state` `unpublished`, where it answered
(`previous_url`) and the `trash_id` that restores it until `restorable_until`.

## StepOption

```typescript
interface StepOption
```

One choice a step's setting takes, as the app's dropdown lists it: its `value` (what the setting takes), its
`label` and what the service says beside it (`metadata`: an icon, a count; `null` for none).

| Attribute | Type | Description |
| --- | --- | --- |
| `value` | `unknown` |  |
| `label` | `unknown` |  |
| `metadata` | `JsonObject | null` |  |

Types:

```typescript
type JsonObject = { [key: string]: unknown };
```

## StepOptions

```typescript
interface StepOptions
```

A page of the choices a step's `field` takes (`Step.options`). `nextPageToken` reads the next page; `withheld`
names, by path, a choice or a part of one left out because it held a secret.

| Attribute | Type | Description |
| --- | --- | --- |
| `field` | `string` |  |
| `options` | `StepOption[]` |  |
| `nextPageToken` | `string | null` |  |
| `withheld` | `string[]` |  |
| `raw` | `JsonObject` | The response JSON exactly as the API sent it. |

Types:

```typescript
type JsonObject = { [key: string]: unknown };
```

## StepPublication

```typescript
interface StepPublication
```

What `Step.publish`, `Step.renameApp` and `Step.unpublish` left of an interface step's app: its `state`
(`published`, `renamed` or `unpublished`) and `url`, as a build's `published` names them; the app itself
(`projectId`, a `Project`'s id, and its `subdomain`); the release a publish made (`deploymentId`); where it answered
before a rename or an unpublish (`previousUrl`); and, unpublished, the trash entry that restores it (`trashId`)
until `restorableUntil`.

| Attribute | Type | Description |
| --- | --- | --- |
| `workflowId` | `string` |  |
| `stepId` | `string` |  |
| `action` | `string` |  |
| `state` | `string` |  |
| `url` | `string | null` |  |
| `projectId` | `string | null` |  |
| `subdomain` | `string | null` |  |
| `deploymentId` | `string | null` |  |
| `previousUrl` | `string | null` |  |
| `trashId` | `string | null` |  |
| `restorableUntil` | `Date | null` |  |
| `raw` | `JsonObject` | The response JSON exactly as the API sent it. |

Types:

```typescript
type JsonObject = { [key: string]: unknown };
```

## StepValue

```typescript
interface StepValue
```

A widget's value on a step (`Step.value`): `value`, or `values` where it fills several of the step's settings at
once (a trigger's address, whether it's registered, why not). `withheld` names, by path, what was left out
because it held a secret (a webhook's signing secret, a signed upload link).

| Attribute | Type | Description |
| --- | --- | --- |
| `field` | `string` |  |
| `value` | `unknown` |  |
| `values` | `JsonObject | null` |  |
| `withheld` | `string[]` |  |
| `raw` | `JsonObject` | The response JSON exactly as the API sent it. |

Types:

```typescript
type JsonObject = { [key: string]: unknown };
```

## EditBatch

```typescript
class EditBatch
```

The edits `Workflow.edit()` collects: each method queues one, and they're sent as one batch once the function
you hand `edit()` resolves, applied in order as one version, or not at all (an op that can't apply throws
`InvalidRequest` naming it, and nothing of the batch lands). A function that throws sends nothing.

Steps are named by `Step` or by id; a step `addStep` queues has its id already, so later edits in the batch can
name it. Once sent, `result` is the `WorkflowEdit`.

| Attribute | Type | Description |
| --- | --- | --- |
| `ops` | `JsonObject[]` | The edits queued so far, as the API takes them (a connection given as an object is resolved when sent). |
| `result` | `WorkflowEdit | null` | What the batch did, once it was sent (`null` before, or when nothing was queued). |

Types:

```typescript
type JsonObject = { [key: string]: unknown };
```

### EditBatch.addStep

```typescript
addStep(type: string, options?: AddStepOptions): Step
```

Queue a new step of `type` (`automation-gmail`, `agent`, `trigger-cron`), doing `operation` with `settings`.
`id` names it (made from its type when left out); without `position` it's laid out beside the rest. Returns
the step, whose `id` later edits in the batch can name.

Parameters:

- `type` (`string`, required)
- `options.operation` (`string`): What it does, one of its type's operations.
- `options.settings` (`JsonObject`)
- `options.name` (`string`): Its name in the app.
- `options.id` (`string`): Its id; made from its type when left out.
- `options.position` (`Position`): Where it sits; left out, it's laid out beside the rest.
- `options.secrets` (`SecretRef[]`): An agent step's secrets, as `StepUpdate.secrets` takes them.
- `options.leftForUser` (`string[]`): Settings left for the step's person to fill in, as `StepUpdate.leftForUser` takes them.

Returns: The step, whose `id` later edits in the batch can name. Its fields load once the batch is sent.

Types:

```typescript
type JsonObject = { [key: string]: unknown };

/** A secret to pass: a `Secret`, its id, or its name (the user's own, else the account's). */
type SecretRef = string | Secret;

/** Where a step sits on the canvas. */
interface Position {
  x: number;
  y: number;
}
```

### EditBatch.updateStep

```typescript
updateStep(step: StepRef, update: StepUpdate): void
```

Queue a change to a step, as `Step.update` makes it.

Parameters:

- `step` (`StepRef`, required)
- `update` (`StepUpdate`, required)

Types:

```typescript
/** A step, or its id. */
type StepRef = Step | string;

/** What `Step.update` (and a batch's `updateStep`) changes; a field left out is never touched. */
interface StepUpdate {
  /**
   * Settings to change, merged into the step's (a nested object merges, any other value replaces, and `null` takes
   * that setting out, a secret included).
   */
  settings?: JsonObject;
  name?: string;
  operation?: string;
  /** `false` switches the step off; `true` back on. */
  enabled?: boolean;
  /**
   * An agent step's secrets: the account's own, in its shell's environment on every run, as `Secret` objects or
   * their names, replacing the ones it had (`[]` takes them all off). Only a key acting for the whole account of the
   * workflow's owner gives a step one, and an agent's own tools as your approval settings let them
   * (`attach_connection`, allowed by default); any other caller keeps or drops what it was given. Their values never
   * show in a read of the workflow, nor to the agent's model.
   */
  secrets?: SecretRef[];
  /**
   * Settings to leave for the step's person to fill in, by name: a value only they know (their own address, number
   * or URL). Each is cleared and noted on the step, so a required one reads `left_for_user` in the step's `verdict`
   * and the workflow's readiness, never an invalid setting, until it's given a value; giving it one takes it off the
   * note. It's how code or an agent that builds a workflow says "this one is yours" without making a value up. A
   * name that isn't one of the step's settings, or one given a value in the same call, is refused; so is a value
   * that only stands in for one (`YOUR_PHONE_NUMBER`, `<your website url>`), naming this instead.
   */
  leftForUser?: string[];
}

type JsonObject = { [key: string]: unknown };

/** A secret to pass: a `Secret`, its id, or its name (the user's own, else the account's). */
type SecretRef = string | Secret;
```

### EditBatch.patchStep

```typescript
patchStep(step: StepRef, field: string, patch: string): void
```

Queue a patch to one long text setting of a step, as `Step.patch` makes it.

Parameters:

- `step` (`StepRef`, required)
- `field` (`string`, required)
- `patch` (`string`, required)

Types:

```typescript
/** A step, or its id. */
type StepRef = Step | string;
```

### EditBatch.removeStep

```typescript
removeStep(step: StepRef): void
```

Queue taking a step (or a note) out, with its edges.

Parameters:

- `step` (`StepRef`, required)

Types:

```typescript
/** A step, or its id. */
type StepRef = Step | string;
```

### EditBatch.connect

```typescript
connect(
  source: StepRef,
  target: StepRef,
  options?: {
    kind?: "data" | "tools";
    handle?: string;
    targetHandle?: string;
    id?: string;
  },
): void
```

Queue an edge from `source` into `target`, as `Step.connect` makes it; `id` names the edge (made for it when left
out), as a canvas names its own.

Parameters:

- `source` (`StepRef`, required)
- `target` (`StepRef`, required)
- `options.kind` (`"data" | "tools"`, default `"data"`)
- `options.handle` (`string`)
- `options.targetHandle` (`string`)
- `options.id` (`string`)

Types:

```typescript
/** A step, or its id. */
type StepRef = Step | string;
```

### EditBatch.disconnect

```typescript
disconnect(
  source: StepRef,
  target: StepRef,
  options?: { handle?: string; id?: string },
): void
```

Queue removing the edge from `source` into `target` (`id`: the one edge of that id, when two join them).

Parameters:

- `source` (`StepRef`, required)
- `target` (`StepRef`, required)
- `options.handle` (`string`)
- `options.id` (`string`)

Types:

```typescript
/** A step, or its id. */
type StepRef = Step | string;
```

### EditBatch.setConnection

```typescript
setConnection(
  step: StepRef,
  connection: Connection | string | null,
  options?: { slot?: string },
): void
```

Queue connecting an account to a step, as `Step.setConnection` does (`null` with `slot` takes one off).

Parameters:

- `step` (`StepRef`, required)
- `connection` (`Connection | string | null`, required)
- `options.slot` (`string`)

Types:

```typescript
/** A step, or its id. */
type StepRef = Step | string;
```

### EditBatch.mockStep

```typescript
mockStep(step: StepRef, output: unknown): void
```

Queue giving a step `output` on test runs instead of running it.

Parameters:

- `step` (`StepRef`, required)
- `output` (`unknown`, required)

Types:

```typescript
/** A step, or its id. */
type StepRef = Step | string;
```

### EditBatch.unmockStep

```typescript
unmockStep(step: StepRef): void
```

Queue having a step run for real on test runs again.

Parameters:

- `step` (`StepRef`, required)

Types:

```typescript
/** A step, or its id. */
type StepRef = Step | string;
```

### EditBatch.updateWorkflow

```typescript
updateWorkflow(update: WorkflowUpdate): void
```

Queue a change to the workflow's own fields, as `Workflow.update` makes it.

Parameters:

- `update` (`WorkflowUpdate`, required)

Types:

```typescript
/** What `Workflow.update` changes; a field left out is never touched. */
interface WorkflowUpdate {
  name?: string;
  description?: string;
  /** Its settings to change, by top-level key; only its owner changes them. */
  settings?: JsonObject;
  /**
   * What the app shows of it (its canvas's viewport, the step open in its panel; 16 KB at most), replacing what's
   * kept: never a version, nor a change anyone is told of.
   */
  displayMetadata?: JsonObject;
  /**
   * Its Interface tab's layout as the app draws it (each block's place on the grid, the tabs' order; 256 KB at most),
   * replacing what's kept: part of its graph, so it moves the version.
   */
  interface?: JsonObject;
}

type JsonObject = { [key: string]: unknown };
```

### EditBatch.move

```typescript
move(
  step: StepRef,
  position: Position,
  size?: { width?: number; height?: number },
): void
```

Queue moving a step (or a note) on the canvas, and for one drawn at a size (a note) giving it `width` and
`height`. Moving things is never a version of its own.

Parameters:

- `step` (`StepRef`, required)
- `position` (`Position`, required)
- `size` (`{ width?: number; height?: number }`)

Types:

```typescript
/** A step, or its id. */
type StepRef = Step | string;

/** Where a step sits on the canvas. */
interface Position {
  x: number;
  y: number;
}
```

### EditBatch.layout

```typescript
layout(): void
```

Queue laying every step out again, as the app's Tidy up does.

### EditBatch.addNote

```typescript
addNote(content: string, options?: AddNoteOptions): Step
```

Queue a note on the canvas, as `Workflow.addNote` makes it; returns the note, whose `id` later edits can name.

Parameters:

- `content` (`string`, required)
- `options.id` (`string`)
- `options.color` (`number`): The app's colours, 0 to 20.
- `options.near` (`StepRef[]`): Steps it sits beside.
- `options.direction` (`"above" | "below" | "left" | "right"`): Which side of `near`: `above` (the default), `below`, `left` or `right`.
- `options.after` (`StepRef`): With `before`: the first step of the stretch it covers.
- `options.before` (`StepRef`): With `after`: the last step of the stretch it covers.
- `options.width` (`number`)
- `options.height` (`number`)
- `options.position` (`Position`): Where it sits, instead of beside steps (`near`, or `after` and `before`).

Returns: The note, a step of type `stickyNote` whose `id` later edits can name.

Types:

```typescript
/** A step, or its id. */
type StepRef = Step | string;

/** Where a step sits on the canvas. */
interface Position {
  x: number;
  y: number;
}
```

### EditBatch.defineVariable

```typescript
defineVariable(
  name: string,
  options?: { value?: string; description?: string; perUser?: boolean },
): void
```

Queue defining a workflow variable: a value its steps read as `{{vars.name}}`, changed in one place. `perUser`
asks each person who copies the workflow for their own. Only the workflow's owner defines one.

Parameters:

- `name` (`string`, required)
- `options.value` (`string`, default `""`)
- `options.description` (`string`)
- `options.perUser` (`boolean`)

### EditBatch.addTestRun

```typescript
addTestRun(
  trigger: StepRef,
  name: string,
  body: string,
  options?: { title?: string; author?: string; handle?: string },
): void
```

Queue a Test Run: a message staged on `trigger` (a trigger step wired into an agent, or its type) that the
app's Test Run plays to the agent. Only the workflow's owner adds one.

Parameters:

- `trigger` (`StepRef`, required)
- `name` (`string`, required)
- `body` (`string`, required)
- `options.title` (`string`)
- `options.author` (`string`)
- `options.handle` (`string`)

Types:

```typescript
/** A step, or its id. */
type StepRef = Step | string;
```

## WorkflowEdit

```typescript
interface WorkflowEdit
```

What an edit did: the workflow's `version` once it and what it set in motion were written (a trigger's
registration writes too), to edit on from; whether its definition `changed`; the version of its history it
landed in (`historyVersion`, what `versionAt` and `restore` name: a version of its own, which this key's next
edits join for five minutes from its first; a layout-only edit is none); a `summary`; each op's `results` in
order (an added step's `id`, and what the
edit did on its own: `resolutions`, `harness_switch`, `coerced_values`, `stripped_trigger_refs`,
`http_auth_credential_hint`); and, for each step an op touched, whether it's ready to run (`steps`:
`config_valid`, `validation_error`, `missing_required`, `left_for_user`, `agent_credential_hint`, and `references`:
each read of another step's output that won't resolve, as `Step.references` reads them). `graph` is the workflow as
written, read as `Workflow.graph()` reads it, when the edit asked for it; `restoredFrom` names the version of its
history a restore put back. `warnings` say what an edit did that won't work as it may look: a read in a touched
step's settings that gets no value (each of its `references`, in a sentence), and a workspace member's own
connection given to a team workflow's step, which its owner's automatic runs can't use. An edit sent with
`settle` also says whether what it set going finished in time (`settled`) and, by step, why each trigger it left
unregistered can't be registered yet (`unregistered`).

| Attribute | Type | Description |
| --- | --- | --- |
| `workflowId` | `string` |  |
| `version` | `number` |  |
| `historyVersion` | `number | null` |  |
| `changed` | `boolean` |  |
| `summary` | `string | null` |  |
| `results` | `JsonObject[]` |  |
| `steps` | `Record<string, JsonObject>` |  |
| `graph` | `WorkflowGraph | null` |  |
| `restoredFrom` | `number | null` |  |
| `warnings` | `string[]` |  |
| `settled` | `boolean | null` |  |
| `unregistered` | `Record<string, string>` |  |
| `raw` | `JsonObject` | The response JSON exactly as the API sent it. |

Types:

```typescript
type JsonObject = { [key: string]: unknown };
```

## WorkflowVersion

```typescript
interface WorkflowVersion
```

One version of a workflow's history: its own number (`historyVersion`, what `versionAt` and `restore` take,
fixed once given), the workflow's `version` its latest write left, where the change came from (`source`: `api`,
`canvas`, `builder`, `mcp`, `coordinator`, `deploy`, `restore`, `noclick`, NoClick's own change such as a schedule
it switched off after it kept failing the same way, `link`, the person's own word through a link NoClick emailed
them, `baseline`, the workflow before its history
began, or `checkpoint`, one saved in the app before its history was kept, numbered below 1), who began it
(`author`: `{ user_id, key_id }`, `null` for the baseline) and everyone who wrote into it (`authors`, its author
first), a `summary` and its `changes`, and for a restore the version of the history it put back (`restoredFrom`).
A named version (a checkpoint: `Workflow.nameVersion`) has its `label` and `note`, who named it (`labeledBy`) and
when (`labeledAt`), and is kept for good while it has a name.

Saves in the app's canvas within five minutes of a session's first are one version, whoever made them. Any other
change (from your code, the builder, an MCP client, NoClick's assistant, a restore) is a version of its own, which
only the same key's next changes from the same place join, within five minutes of its first; so `updatedAt` is its
latest write. `graph` is the whole definition it holds, its name, description and settings with its steps, read
with `Workflow.versionAt` (`null` in a list): a restore puts all of it back. Its steps are as they were, and
changing one changes the workflow's step of that id as it is now.

| Attribute | Type | Description |
| --- | --- | --- |
| `workflowId` | `string` |  |
| `historyVersion` | `number` |  |
| `version` | `number` |  |
| `source` | `string` |  |
| `author` | `{ user_id: string; key_id: string | null } | null` |  |
| `authors` | `{ user_id: string; key_id: string | null }[]` |  |
| `summary` | `string | null` |  |
| `changes` | `string[]` |  |
| `restoredFrom` | `number | null` |  |
| `createdAt` | `Date | null` |  |
| `updatedAt` | `Date | null` |  |
| `graph` | `WorkflowGraph | null` |  |
| `label` | `string | null` |  |
| `note` | `string | null` |  |
| `labeledBy` | `{ user_id: string } | null` |  |
| `labeledAt` | `Date | null` |  |
| `raw` | `JsonObject` | The response JSON exactly as the API sent it. |

Types:

```typescript
type JsonObject = { [key: string]: unknown };
```

## WorkflowVariables

```typescript
interface WorkflowVariables
```

A workflow's variables with their values (`Workflow.variables`), which no other read of it carries, as they were at
`version`: `definitions` are its variables as its settings hold them, in their order, and `variables` the graph's
own by name, as its Set variable steps last wrote them. `values` is what `{{vars.name}}` reads: the two together,
the graph's own winning.

| Attribute | Type | Description |
| --- | --- | --- |
| `workflowId` | `string` |  |
| `version` | `number | null` |  |
| `definitions` | `WorkflowVariableDefinition[]` |  |
| `variables` | `JsonObject` |  |
| `raw` | `JsonObject` | The response JSON exactly as the API sent it. |
| `values` | `JsonObject` | Each variable's value by name: a definition's when it has one, the graph's own over it. |

Types:

```typescript
/** One of a workflow's variables as its settings hold it (`WorkflowVariables.definitions`). */
interface WorkflowVariableDefinition {
  name: string;
  value?: unknown;
  description?: string;
  /** Asked of each new owner when the workflow is copied: a copy starts without its value. Read here like any other. */
  per_user?: boolean;
  [key: string]: unknown;
}

type JsonObject = { [key: string]: unknown };
```

## WorkflowSetup

```typescript
interface WorkflowSetup
```

What a workflow needs from its person before it can run (`Workflow.setup`), derived from it as it stands: `items`,
each with a `kind`: `connect` (an app to connect, once for every step that needs it: `app`, `label`, `steps`,
`reconnect`), `setting` (a value only the person knows: its `step`, the `setting`'s name, `label`, `type`,
`options`) or `secret` (the `keys` an agent step's shell asked for, kept as the secret `name`). `ready` when there's
nothing; `request` the setup request still waiting on the person; `sent` the request `requestSetup` just sent.

| Attribute | Type | Description |
| --- | --- | --- |
| `workflowId` | `string` |  |
| `ready` | `boolean` |  |
| `items` | `JsonObject[]` |  |
| `request` | `JsonObject | null` |  |
| `sent` | `JsonObject | null` |  |
| `raw` | `JsonObject` | The response JSON exactly as the API sent it. |

Types:

```typescript
type JsonObject = { [key: string]: unknown };
```

## WorkflowFile

```typescript
class WorkflowFile
```

A file one of your workflows keeps: what a step or an interface uploaded or produced. `url` reads it until
`urlExpiresAt`; list again for a fresh one. Tables are apart (`WorkflowTable`).

You read the files of each workflow `Workflow.get` reads: your account's own, those shared with it, and the ones
its agents run on. They're the account's: acting for one of your users, it's refused. An app's own code reads
only those of a workflow its code made, named with `workflow`.

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `string` |  |
| `name` | `string` |  |
| `workflow` | `KeptBy` | The workflow that keeps it, and what it's made of. |
| `access` | `string` | Your account's access to that workflow: `owner`, `editor` or `viewer`. Deleting takes owner or editor. |
| `stepId` | `string | null` | The step that keeps it, when one does. |
| `type` | `string` | What it holds: `image`, `video`, `audio`, `document` or `file`. |
| `mimeType` | `string | null` |  |
| `sizeBytes` | `number` |  |
| `url` | `string | null` | A link that reads the file until `urlExpiresAt` (an hour after it's listed), naming nothing of where it's stored: a picture, PDF, sound or video opens in place, anything else downloads. Null for a file with nothing stored yet. |
| `urlExpiresAt` | `Date | null` |  |
| `createdAt` | `Date | null` |  |
| `updatedAt` | `Date | null` |  |

Types:

```typescript
/** The workflow a list's item belongs to. */
interface KeptBy {
  id: string;
  name: string;
  /**
   * What it's made of, at a glance: at most four of its step types, its triggers first, then its agents, then the
   * rest in the order it holds them (`["trigger-cron", "agent:codex", "automation-hubspot"]`). An agent on a coding
   * harness is `agent:<harness>`. Only step types and harness names, never a step's settings.
   */
  stepTypes: string[];
}
```

### WorkflowFile.list

```typescript
static list(
  options?: WorkflowResourceListOptions & { limit?: number },
): Promise<WorkflowFile[]>
```

The files your workflows keep, most recently changed first: every workflow `Workflow.get` reads, or one.

Parameters:

- `options.workflow` (`Workflow | string`): One workflow's (a `Workflow` or its id); an app's own code names one its code made.
- `options.organizationId` (`string`): The workflows in this team workspace of the NoClick app (its id; your account must belong to it), or `"none"`.
- `options.limit` (`number`): Return at most this many.
- `options.client` (`NoClick`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: Every file, fetched page by page (or the first `limit`), each with a link good for an hour.

### WorkflowFile.listPage

```typescript
static listPage(
  options?: WorkflowResourceListOptions & PageOptions,
): Promise<Page<WorkflowFile>>
```

One page of the files your workflows keep; pass `nextCursor` back as `cursor`.

Parameters:

- `options.workflow` (`Workflow | string`): One workflow's (a `Workflow` or its id); an app's own code names one its code made.
- `options.organizationId` (`string`): The workflows in this team workspace of the NoClick app (its id; your account must belong to it), or `"none"`.
- `options.cursor` (`string | null`): The `next_cursor` of the page before; omit it for the first page.
- `options.limit` (`number`): Return at most this many.
- `options.client` (`NoClick`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: A page whose `data` holds the files and whose `next_cursor` is `None` on the last page.

### WorkflowFile.delete

```typescript
delete(): Promise<void>
```

Delete the file for good: its record and what it stored, with no trash to restore it from. A step that reads
it by its id finds nothing there. Takes edit access to its workflow, never one of your agents runs on
(`PermissionDenied` otherwise: change that through the agent).

## WorkflowTable

```typescript
class WorkflowTable
```

A table one of your workflows keeps rows in (a Table step's, an interface's). Read its rows with `rows()`,
never by querying the database it names (`databaseId`): how a workflow lays its tables out there may change. You
read the tables of the workflows you read their files of (`WorkflowFile`).

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `string` |  |
| `name` | `string` |  |
| `workflow` | `KeptBy` | The workflow that keeps it, and what it's made of. |
| `access` | `string` | Your account's access to that workflow: `owner`, `editor` or `viewer`. Deleting takes owner or editor. |
| `stepId` | `string | null` | The step that keeps it, when one does. |
| `rowCount` | `number | null` | How many rows it holds. |
| `databaseId` | `string | null` | The database of your account's its rows are kept in (`Database.fromId`); null until they move there. |
| `createdAt` | `Date | null` |  |
| `updatedAt` | `Date | null` |  |

Types:

```typescript
/** The workflow a list's item belongs to. */
interface KeptBy {
  id: string;
  name: string;
  /**
   * What it's made of, at a glance: at most four of its step types, its triggers first, then its agents, then the
   * rest in the order it holds them (`["trigger-cron", "agent:codex", "automation-hubspot"]`). An agent on a coding
   * harness is `agent:<harness>`. Only step types and harness names, never a step's settings.
   */
  stepTypes: string[];
}
```

### WorkflowTable.list

```typescript
static list(
  options?: WorkflowResourceListOptions & { limit?: number },
): Promise<WorkflowTable[]>
```

The tables your workflows keep, most recently changed first: every workflow `Workflow.get` reads, or one.

Parameters:

- `options.workflow` (`Workflow | string`): One workflow's (a `Workflow` or its id); an app's own code names one its code made.
- `options.organizationId` (`string`): The workflows in this team workspace of the NoClick app (its id; your account must belong to it), or `"none"`.
- `options.limit` (`number`): Return at most this many.
- `options.client` (`NoClick`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: Every table, fetched page by page (or the first `limit`).

### WorkflowTable.listPage

```typescript
static listPage(
  options?: WorkflowResourceListOptions & PageOptions,
): Promise<Page<WorkflowTable>>
```

One page of the tables your workflows keep; pass `nextCursor` back as `cursor`.

Parameters:

- `options.workflow` (`Workflow | string`): One workflow's (a `Workflow` or its id); an app's own code names one its code made.
- `options.organizationId` (`string`): The workflows in this team workspace of the NoClick app (its id; your account must belong to it), or `"none"`.
- `options.cursor` (`string | null`): The `next_cursor` of the page before; omit it for the first page.
- `options.limit` (`number`): Return at most this many.
- `options.client` (`NoClick`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: A page whose `data` holds the tables and whose `next_cursor` is `None` on the last page.

### WorkflowTable.rowsPage

```typescript
rowsPage(options?: PageOptions): Promise<RowsPage>
```

One page of its rows in the order they were added (`limit`, 1 to 10,000; 100 when left out), with how many rows
the table holds (`totalCount`).

Parameters:

- `options.cursor` (`string | null`): The `next_cursor` of the page before; omit it for the first page.
- `options.limit` (`number`): Return at most this many.

Returns: A page whose `data` holds each `TableRow`, whose `next_cursor` is `None` on the last page and
whose `total_count` is how many rows the table holds.

### WorkflowTable.rows

```typescript
rows(options?: { limit?: number }): Promise<TableRow[]>
```

Its rows in the order they were added: every one, read 10,000 at a time, or the first `limit`.

Parameters:

- `options.limit` (`number`): Return at most this many.

Returns: Every row, read 10,000 at a time (or the first `limit`).

### WorkflowTable.delete

```typescript
delete(): Promise<void>
```

Delete the table and every row in it for good, with no trash to restore it from. A step or an interface that
reads or adds to it fails on its next run. Takes edit access to its workflow, never one of your agents runs
on (`PermissionDenied` otherwise).

## TableRow

```typescript
interface TableRow
```

One row of a table: its position (`index`, from 0 in the order rows were added) and `data`, as it was written.

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `string` |  |
| `index` | `number` |  |
| `data` | `JsonObject` |  |
| `createdAt` | `Date | null` |  |
| `raw` | `JsonObject` | The response JSON exactly as the API sent it. |

Types:

```typescript
type JsonObject = { [key: string]: unknown };
```

## RowsPage

```typescript
interface RowsPage extends Page
```

One page of a table's rows, with how many rows the table holds.

| Attribute | Type | Description |
| --- | --- | --- |
| `totalCount` | `number` |  |

## stepTypes

```typescript
function stepTypes(
  query?: string,
  options?: { kind?: StepTypeKind; limit?: number; client?: NoClick },
): Promise<StepType[]>
```

Every kind of step a workflow can hold, NoClick's own first, then the integrations most used first; with
`query`, those it finds by name or by what they do, the best first, as the app's builder searches. `kind: "trigger"`
keeps the types a run starts from (a trigger step, or one with a trigger operation), `kind: "tool"` those an agent
uses as its tools. A listing leaves out each operation's description and the settings schema: `stepType()` reads
them. Fetched page by page, or the first `limit`. Needs the `workflows` scope.

    const [send] = await stepTypes("send an email", { limit: 1 });
    await Workflow.fromName("Morning brief").addStep(send.type, { operation: send.operations[0].name });

    for (const kind of await stepTypes(undefined, { kind: "trigger" })) {
      console.log(kind.type, kind.operations.filter((op) => op.trigger).map((op) => op.name));
    }

Parameters:

- `query` (`string`)
- `options.kind` (`StepTypeKind`)
- `options.limit` (`number`): Return at most this many.
- `options.client` (`NoClick`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: Each type's `type` (what `workflow.add_step` takes), `label`, `kinds`, `operations` (each
with whether it's a `trigger` and `needs_account`) and `connection`, fetched page by page
(or the first `limit`).

Types:

```typescript
/** What a step of a type can be in a workflow: a run starts from it, or an agent uses it as its tools. */
type StepTypeKind = "trigger" | "tool";
```

## stepType

```typescript
function stepType(
  name: string,
  options?: {
    kind?: StepTypeOperationKind;
    query?: string;
    operation?: string | string[];
    client?: NoClick;
  },
): Promise<StepType>
```

One step type, each operation with its `description` (its triggers first), and its `schema`: what a step's
`settings` take, as the app's canvas draws its form from it (null for a type that takes no settings). `name` is the
type as a workflow's graph names it (`automation-gmail`, `agent`); an unknown one throws `NotFound` naming the
nearest. A type can be large (Stripe holds 491 operations): `kind`, `query` (the operations its words fit, the best
first) and `operation` (one name, or several) keep only some, and the `schema` only their settings;
`operationsTotal` still counts them all. An operation the type doesn't have throws `InvalidRequest`. Needs the
`workflows` scope.

    const gmail = await stepType("automation-gmail");
    const send = gmail.operations.find((op) => op.name === "send_email_message");
    console.log(send?.description, gmail.connection?.credentialTypes);

    const stripe = await stepType("automation-stripe", { kind: "trigger", query: "payment failed" });
    const failed = await stepType("automation-stripe", { operation: stripe.operations[0].name });

Parameters:

- `name` (`string`, required)
- `options.kind` (`StepTypeOperationKind`)
- `options.query` (`string`)
- `options.operation` (`string | string[]`)
- `options.client` (`NoClick`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: The type, with its `schema` (`None` for a type that takes no settings).

Types:

```typescript
/** What one of a type's operations is: one that starts a workflow, or one a run does. */
type StepTypeOperationKind = "trigger" | "action";
```

## StepType

```typescript
interface StepType
```

A kind of step a workflow can hold: one of `stepTypes()`.

| Attribute | Type | Description |
| --- | --- | --- |
| `type` | `string` | What `workflow.addStep` takes, as a workflow's graph names it: `automation-slack`, `agent`, `trigger-cron`. |
| `label` | `string | null` | Its name in the app (`Slack`, `AI Agent`, `Schedule`). |
| `description` | `string | null` |  |
| `category` | `string | null` | The section the app lists an integration under (`communication`, `crm-sales`); null for NoClick's own. |
| `kinds` | `StepTypeKind[]` | What a step of it can be in a workflow: `trigger` (a run starts from it) and `tool` (an agent's tools). |
| `trigger` | `boolean` | Whether a step of it starts runs whatever its operation (a trigger step: a schedule, a webhook, a form). |
| `operations` | `StepTypeOperation[]` | Each operation once, its triggers first, in the order the app lists them; empty for a type that has none (`trigger-run`). A read narrowed by `kind`, `query` or `operation` holds only those it kept. |
| `connection` | `StepTypeConnection | null` | The accounts it connects to; null for a type whose settings take none. |
| `retired` | `JsonObject | null` | Why its service is gone and since when (`reason`, `since`), or null while it works. A listing leaves retired types out; `stepType()` still reads one, since a step saved on it still loads and runs. |
| `schema` | `JsonObject | null` | The JSON Schema of a step's settings, as the app's canvas draws its form from it (`properties.config`, a member per operation where it has several, with the canvas's `x-` and `ui:` extensions). Null in a listing, and for a type that takes no settings. |
| `raw` | `JsonObject` | The response JSON exactly as the API sent it. |
| `operationsTotal` | `number | null` | How many operations the type has in all, whatever a read kept; null in a listing. |

Types:

```typescript
/** What a step of a type can be in a workflow: a run starts from it, or an agent uses it as its tools. */
type StepTypeKind = "trigger" | "tool";

type JsonObject = { [key: string]: unknown };
```

## StepTypeOperation

```typescript
interface StepTypeOperation
```

One operation a step of the type runs: what `operation` takes.

| Attribute | Type | Description |
| --- | --- | --- |
| `name` | `string` |  |
| `label` | `string | null` |  |
| `description` | `string | null` | What it does; null in a listing (`stepType()` reads it). |
| `trigger` | `boolean` | Whether it starts runs (a trigger operation, `x-is-trigger`) rather than acting when a run reaches it. |
| `needsAccount` | `boolean` | Whether running it needs an account connected to the step: false when it runs on NoClick's key with no account (web search, public data) or the type takes none; true otherwise, also when the need depends on its settings. |
| `raw` | `JsonObject` | The response JSON exactly as the API sent it. |

Types:

```typescript
type JsonObject = { [key: string]: unknown };
```

## StepTypeConnection

```typescript
interface StepTypeConnection
```

The accounts a step of the type connects to (`step.setConnection`).

| Attribute | Type | Description |
| --- | --- | --- |
| `needed` | `boolean` | Whether every operation needs one, so a step of it can't run without. |
| `integration` | `string | null` | Its name in `Connection.integrations()` (`integration` when you make a connection for it), or null for a step whose account isn't connected there (an agent's model key). |
| `credentialTypes` | `string[]` | The credential types its settings take, as a step's `connections` names them. |
| `raw` | `JsonObject` | The response JSON exactly as the API sent it. |

Types:

```typescript
type JsonObject = { [key: string]: unknown };
```

## WorkflowFolder

```typescript
interface WorkflowFolder
```

One of your account's workflow folders, as the app's Automations page shows it: `Workflow.folders()` lists them,
`Workflow.createFolder()` makes one and `workflow.moveTo()` files a workflow in one.

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `string` |  |
| `name` | `string` |  |
| `description` | `string | null` |  |
| `parentId` | `string | null` | The folder it's in; null at the top. |
| `depth` | `number` | How deep it sits: 0 at the top, 10 at most. |
| `workflowCount` | `number` | How many workflows are in it (not counting its folders'). |
| `createdAt` | `Date | null` |  |
| `updatedAt` | `Date | null` |  |
| `raw` | `JsonObject` | The response JSON exactly as the API sent it. |

Types:

```typescript
type JsonObject = { [key: string]: unknown };
```

## workflowExamples

```typescript
function workflowExamples(
  query?: string,
  options?: { limit?: number; client?: NoClick },
): Promise<WorkflowExample[]>
```

NoClick's own example workflows, the ones its builder studies before it builds, most recently changed first; with
`query`, the ones it finds by name, what they're for and their text, the best first. A listing leaves each one's
text and workflow out: `workflowExample()` reads them. Fetched page by page, or the first `limit`. Needs the
`workflows` scope.

    const [best] = await workflowExamples("post new form answers to Slack", { limit: 1 });
    const example = await workflowExample(best.id);
    console.log(example.text);

Parameters:

- `query` (`string`)
- `options.limit` (`number`): Return at most this many.
- `options.client` (`NoClick`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: Each example's `name`, `description`, whether it has guidance `text` and a workflow, and what that's
made of (`step_types`), fetched page by page (or the first `limit`).

## workflowExample

```typescript
function workflowExample(
  exampleId: string,
  options?: { client?: NoClick },
): Promise<WorkflowExample>
```

One of NoClick's example workflows whole: its guidance `text` and its workflow's `graph` (each null where it has
none). An id that names none throws `NotFound`. Needs the `workflows` scope.

    const example = await workflowExample("6f1c2e9a-3b7d-4f0e-9a51-2d8c4b7e1a03");
    console.log(example.description, example.stepTypes);

Parameters:

- `exampleId` (`string`, required)
- `options.client` (`NoClick`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: The example, with its `text` and `graph` (each `None` where it has none).

## WorkflowExample

```typescript
interface WorkflowExample
```

One of NoClick's example workflows: one of `workflowExamples()`.

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `string` |  |
| `name` | `string` |  |
| `description` | `string | null` | What it's for, and when it applies. |
| `hasText` | `boolean` | Whether it holds guidance text. |
| `hasWorkflow` | `boolean` | Whether it holds a workflow. |
| `stepTypes` | `string[]` | What its workflow is made of, at a glance, as `Workflow.stepTypes` says it: its triggers first, then its agents, then the rest. |
| `updatedAt` | `Date | null` |  |
| `text` | `string | null` | Its guidance, in Markdown; null in a listing (`workflowExample()` reads it). |
| `graph` | `JsonObject | null` | Its workflow as `workflow.graph()` reads a workflow's (`nodes`, each with its `type` and `config`, and `edges`), without the connections or test outputs of the account it was made in, never a secret; null in a listing and for one that's guidance only. |
| `raw` | `JsonObject` | The response JSON exactly as the API sent it. |

Types:

```typescript
type JsonObject = { [key: string]: unknown };
```

## stepOutputShape

```typescript
function stepOutputShape(
  name: string,
  options?: { operation?: string; client?: NoClick },
): Promise<StepOutputShape>
```

What a step of type `name` outputs (its `operation`'s, for a type with several), learned from your account's own runs:
the fields a later step's settings can reference, as the app's canvas offers them. Needs the `workflows` scope.

    const { shape } = await stepOutputShape("automation-hubspot", { operation: "get_contact" });
    console.log(Object.keys(shape?.properties ?? {}));

Parameters:

- `name` (`string`, required)
- `options.operation` (`string`)
- `options.client` (`NoClick`): The client to send with; defaults to the module client built from `NOCLICK_API_KEY`.

Returns: The `StepOutputShape`; an unknown type raises `noclick.NotFound` naming the nearest.

## StepOutputShape

```typescript
interface StepOutputShape
```

What a step of a type outputs, as your account's own runs and events of it showed it (and those of people in a
workspace with you), never another account's: `shape`, its fields' names and types, with `suggestedRefs`, the few
references worth offering first (null until they're made). `shape` is null until your first run or event of it.

| Attribute | Type | Description |
| --- | --- | --- |
| `type` | `string` |  |
| `operation` | `string` |  |
| `shape` | `JsonObject | null` |  |
| `suggestedRefs` | `unknown[] | null` |  |
| `raw` | `JsonObject` | The response JSON exactly as the API sent it. |

Types:

```typescript
type JsonObject = { [key: string]: unknown };
```

## WorkflowRunCounts

```typescript
interface WorkflowRunCounts
```

How many runs `Workflow.runs` lists (`Workflow.runCounts`): the `total`, `byStatus` (`running`, `succeeded`,
`failed`, each there even at 0), `waiting` (how many of the running ones wait on an approval, a delay or an agent's
turn), `bySource` (`api`, `endpoint`, `schedule`, `trigger`, `app`: only those with runs) and `byTrigger` (the kinds
of event that started the runs a trigger did: `webhook`, `email`, …, only those with runs). A run from code counts
once, however many executions it spans.

| Attribute | Type | Description |
| --- | --- | --- |
| `workflowId` | `string` |  |
| `total` | `number` |  |
| `byStatus` | `Record<WorkflowRunStatus, number>` |  |
| `bySource` | `Record<string, number>` |  |
| `raw` | `JsonObject` | The response JSON exactly as the API sent it. |
| `waiting` | `number` |  |
| `byTrigger` | `Record<string, number>` |  |

Types:

```typescript
type WorkflowRunStatus = "running" | "succeeded" | "failed";

type JsonObject = { [key: string]: unknown };
```

## LatestOutputs

```typescript
interface LatestOutputs
```

Each step's latest output, whatever run it's from (`Workflow.latestOutputs`): `outputs` by step id, each cut short
as a run's steps are unless read `full` (`truncated` names the steps cut), never a secret (`withheld`: each step's
paths left out). A step that never stored one isn't in `outputs`. `lastRuns`: how each step's latest run ended, as
the app's canvas marks it beside the step; a step never run isn't in it.

| Attribute | Type | Description |
| --- | --- | --- |
| `workflowId` | `string` |  |
| `outputs` | `JsonObject` |  |
| `withheld` | `Record<string, string[]>` |  |
| `full` | `boolean` |  |
| `truncated` | `string[]` |  |
| `raw` | `JsonObject` | The response JSON exactly as the API sent it. |
| `lastRuns` | `Record<string, StepLastRun>` |  |

Types:

```typescript
type JsonObject = { [key: string]: unknown };
```

## StepLastRun

```typescript
interface StepLastRun
```

How a step's latest run ended (`LatestOutputs.lastRuns`): its `status` (`succeeded`, `failed`, `skipped`), when.

| Attribute | Type | Description |
| --- | --- | --- |
| `status` | `string` |  |
| `finishedAt` | `Date | null` |  |
| `error` | `string | null` |  |

## ExpressionPreview

```typescript
interface ExpressionPreview
```

What an expression gives (`Step.previewExpression`): `ok`, with the value's `kind` (`object`, `array`, `string`,
`number`, `boolean`, `null`), an object's `keys` and a short `preview`; or `ok` false with the `error`.

| Attribute | Type | Description |
| --- | --- | --- |
| `ok` | `boolean` |  |
| `kind` | `string | null` |  |
| `keys` | `string[] | null` |  |
| `preview` | `string | null` |  |
| `error` | `string | null` |  |
| `raw` | `JsonObject` | The response JSON exactly as the API sent it. |

Types:

```typescript
type JsonObject = { [key: string]: unknown };
```

## ClearedStepState

```typescript
interface ClearedStepState
```

What `Step.clearState` forgot: how many of its state records and of its conversations were deleted.

| Attribute | Type | Description |
| --- | --- | --- |
| `stepId` | `string` |  |
| `stateRowsDeleted` | `number` |  |
| `conversationsDeleted` | `number` |  |
| `raw` | `JsonObject` | The response JSON exactly as the API sent it. |

Types:

```typescript
type JsonObject = { [key: string]: unknown };
```

## BuildQuestion

```typescript
interface BuildQuestion
```

What a build waits on. Each of `inputs` is `{ id, label, type, description, options?, request_id? }`:
`request_id` is the human request that asks it, which NoClick sent the person whose build it is
(`sentTo`) and any client answers (its page, a chat's card, their texts,
`POST /v1/humans/requests/{id}/answer`); the build goes on once each is answered. Or answer them all
at once with `build.answer({ [id]: value })`, which goes on now: an input of type `credential` takes
a connection's ref or name, one of type `env` its values in `secretValues` (both with a key acting
for the whole account). `answerUrl` is a page anyone holding it answers on.

| Attribute | Type | Description |
| --- | --- | --- |
| `id` | `string | null` |  |
| `title` | `string | null` |  |
| `inputs` | `JsonObject[]` |  |
| `answerUrl` | `string | null` |  |
| `answerableFromCode` | `boolean` |  |
| `raw` | `JsonObject` | The response JSON exactly as the API sent it. |
| `sentTo` | `string[]` | Where NoClick sent its requests (`web`, `email`, `whatsapp`, `imessage`). |

Types:

```typescript
type JsonObject = { [key: string]: unknown };
```
