Workflow

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

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 it owns and pays for. 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=...).

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); changing, building and running 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.

Attributes
idstring
namestring
descriptionstring | null
inputsJsonObject

A JSON schema of what run takes: a form's fields, any object for a webhook, empty if nothing.

appUrlstring | null

Where to open it in the NoClick app.

accessstring

Your account's access: owner, editor or viewer.

createdAtDate | null
updatedAtDate | null
stepsWorkflowStep[]

Its steps in order, each with its settings, connection and trigger state (read with one workflow, not in a list).

edgesWorkflowEdge[]

How its steps are wired.

pausedboolean

Whether a pause switched its triggers off.

readinessWorkflowReadiness

Whether it's set up to run, what its status means, and the issues in the way.

urlsWorkflowUrl[]

The URLs it answers at.

latestBuildWorkflowBuild | null

The build create(..., { instructions }) or build() started here (null otherwise).

versionnumber | 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.

lastEditWorkflowEdit | null

What this handle's last edit did (null until one): its version, summary, each op's results and verdicts.

Types
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. */
  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;
}

createstatic

static create(
  name: string,
  options?: { instructions?: string; description?: string; 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).

Parameters
namestringrequired
options.instructionsstring
options.descriptionstring
options.clientNoClick

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.

fromNamestatic

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
namestringrequired
options.descriptionstring
options.clientNoClick

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.

fromIdstatic

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

A lazy reference to a workflow by id.

Parameters
workflowIdstringrequired
options.clientNoClick

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.

getstatic

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

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

Parameters
workflowIdstringrequired
options.clientNoClick

The client to send with; defaults to the module client built from NOCLICK_API_KEY.

Returns

The workflow, loaded.

liststatic

static list(
  options?: { q?: 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.

Parameters
options.qstring
options.limitnumber

Return at most this many.

options.clientNoClick

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).

listPagestatic

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

One page of workflows; pass nextCursor back as cursor.

Parameters
options.cursorstring | null

The next_cursor of the page before; omit it for the first page.

options.limitnumber

Return at most this many.

options.qstring
options.clientNoClick

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.

graph

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.

step

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
idstringrequired
Returns

The Step.

addStep

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
typestringrequired
options.operationstring

What it does, one of its type's operations.

options.settingsJsonObject
options.namestring

Its name in the app.

options.idstring

Its id; made from its type when left out.

options.positionPosition

Where it sits; left out, it's laid out beside the rest.

Returns

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

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

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

update

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
updateWorkflowUpdaterequired
Returns

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

Types
/** 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;
}

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

addNote

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
contentstringrequired
options.idstring
options.colornumber

The app's colours, 0 to 20.

options.nearStepRef[]

Steps it sits beside.

options.direction"above" | "below" | "left" | "right"

Which side of near: above (the default), below, left or right.

options.afterStepRef

With before: the first step of the stretch it covers.

options.beforeStepRef

With after: the last step of the stretch it covers.

options.widthnumber
options.heightnumber
Returns

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

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

move

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
stepStepRefrequired
positionPositionrequired
Returns

The step, at its new position.

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

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

edit

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 changes through the agent: an edit of it throws PermissionDenied naming it (details.agent_id).

Parameters
build(batch: EditBatch) => unknownrequired
options.ifVersionnumber

The version the edits were made against (a read's version): refused with Conflict when it moved on since.

options.includeGraphboolean

true: the answer carries the graph as written.

Returns

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

versions

versions(options?: { limit?: number | null }): Promise<WorkflowVersion[]>

Its versions, newest first, kept 90 days: the first limit (20 by default; null for all), fetched page by page.

Parameters
options.limitnumber | null

Return at most this many.

Returns

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

versionsPage

versionsPage(options?: PageOptions): Promise<Page<WorkflowVersion>>

One page of its versions, newest first; pass nextCursor back as cursor.

Parameters
options.cursorstring | null

The next_cursor of the page before; omit it for the first page.

options.limitnumber

Return at most this many.

Returns

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

versionAt

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
historyVersionnumberrequired
Returns

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

build

build(
  instructions?: string,
  options?: { publish?: boolean | JsonObject },
): 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.

Parameters
instructionsstring
options.publishboolean | JsonObject
Returns

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

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

publish

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.subdomainstring
options.titlestring
Returns

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

unpublish

unpublish(): Promise<WorkflowBuild>

Take the workflow's app down: its public URL stops answering.

Returns

A WorkflowBuild; its result's published says unpublished.

pause

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
reasonstring
Returns

This workflow, read again (paused is True).

resume

resume(): Promise<this>

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

Returns

This workflow, read again.

restore

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.historyVersionnumber
options.ifVersionnumber
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.

delete

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.

run

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.

Parameters
inputsJsonObject
options.userUserOption

undefined = the ambient user (asUser), null = the account itself.

(defaults to the current user)
options.idempotencyKeystring

Makes a retried create safe: the same key returns the first result. Generated when omitted.

options.clientNoClick
Returns

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

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

/** `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>;
}

runs

runs(
  options?: ReadOptions & {
    status?: WorkflowRunStatus | readonly WorkflowRunStatus[];
    limit?: number;
  },
): 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).

Parameters
options.statusWorkflowRunStatus | readonly WorkflowRunStatus[]
options.limitnumber

Return at most this many.

options.userFilterUserFilter

Which users the read covers (user_id query), instead of acting as one (user).

options.userUserOption

undefined = the ambient user (asUser), null = the account itself.

(defaults to the current user)
options.clientNoClick
Returns

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

Types
/**
 * 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;

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

getRun

getRun(runId: string): Promise<WorkflowRun>

One run, with what each step did (steps: status, error and output, in order); an unknown id throws NotFound.

Parameters
runIdstringrequired
Returns

The WorkflowRun; an unknown id raises noclick.NotFound.

endpoint

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.publicboolean
Returns

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

WorkflowRun

interface WorkflowRun

One run of a workflow. status is running (a run waiting on an approval or a delay too), 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, like a webhook or an 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.

Attributes
idstring
workflowIdstring | null
statusWorkflowRunStatus
inputsJsonObject
outputsJsonObject
errorstring | null
sourcestring | null
userIdstring | null
operationIdstring | null
startedAtDate | null
finishedAtDate | null
stepsRunStep[]
rawJsonObject

The response JSON exactly as the API sent it.

Types
type WorkflowRunStatus = "running" | "succeeded" | "failed";

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

RunStep

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.

Attributes
idstring
namestring
statusstring
errorstring | null
outputunknown

WorkflowEndpoint

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.

Attributes
urlstring
publicboolean
methodstring
rawJsonObject

The response JSON exactly as the API sent it.

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

WorkflowBuild

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: answer it with answer(), or send a person to its answerUrl. 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.

Attributes
workflowIdstring | null
questionBuildQuestion | null

What the build waits on (null unless it's asking).

nextQuestion

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

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

Parameters
options.timeoutSnumber
Returns

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

answer

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

Answer the question the build waits on, by input id; message tells the builder anything else, skip: true goes on without answering. An input only a person can answer (an account to connect, secret values) throws InvalidRequest naming answerUrl. Resolves to this build, running again.

Parameters
valuesJsonObject
options.messagestring
options.skipboolean
Returns

This build, running again.

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

WorkflowBuildResult

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).

Attributes
workflowIdstring | null
summarystring | null
stepsWorkflowStep[]
appUrlstring | null
published{ state: string; url: string | null } | null
rawJsonObject

The response JSON exactly as the API sent it.

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

WorkflowStep

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).

Attributes
idstring
namestring
typestring
operationstring | null
enabledboolean
settingsJsonObject
connectionStepConnection | null
triggerStepTrigger | null
Types
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;
}

WorkflowGraph

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), 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.

Attributes
workflowIdstring
versionnumber
namestring | null
descriptionstring | null
settingsJsonObject | null
settingsWithheldstring[] | null
stepsStep[]
notesStep[]
edgesGraphEdge[]
withheldRecord<string, string[]>
variablesWithheldstring[]
rawJsonObject

The response JSON exactly as the API sent it.

Types
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).
 */
interface GraphEdge {
  id: string | null;
  from: string;
  to: string;
  kind: "data" | "tools";
  handle: string | null;
}

step

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
refstringrequired
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

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().

Attributes
idstring

Its id in the workflow, which edits name it by.

workflowWorkflow

The workflow it's a step of.

typestring

What kind of step it is: automation-gmail, agent, trigger-cron, stickyNote for a note.

namestring | null

Its name in the app (null when it has none and the app shows its type).

operationstring | null

What it does, one of its type's operations (null for a step with one thing to do).

enabledboolean

Whether it runs: a step switched off (update({ enabled: false })) is passed over.

settingsJsonObject

Its settings, by field name, as stored (a secret is never read back: see withheld).

connectionsRecord<string, string>

The accounts connected to it: each slot (a connection type, like gmail_oauth) to the id of the account there.

positionPosition | null

Where it sits on the canvas.

mockOutputunknown

What it outputs on test runs instead of running (mock()), or null.

withheldstring[]

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.

verdictJsonObject | 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 and missing_required; an agent's agent_credential_hint. null until an edit judged it (a read doesn't).

notesJsonObject

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
type JsonObject = { [key: string]: unknown };

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

update

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); 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
updateStepUpdaterequired
Returns

This step as written, with notes and verdict.

Types
/** 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). */
  settings?: JsonObject;
  name?: string;
  operation?: string;
  /** `false` switches the step off; `true` back on. */
  enabled?: boolean;
}

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

patch

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
fieldstringrequired
patchstringrequired
Returns

This step as written.

remove

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).

connect

connect(
  other: StepRef,
  options?: { kind?: "data" | "tools"; handle?: 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. Connecting what's already connected changes nothing; notes holds the edge.

Parameters
otherStepRefrequired
options.kind"data" | "tools"default "data"
options.handlestring
Returns

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

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

disconnect

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

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

Parameters
otherStepRefrequired
options.handlestring
Returns

This step.

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

setConnection

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

Connect an account to the step: a Connection connected in the app (credential:<id>) or its id. Its slot is the account's own type unless slot names it; null with slot takes the account in that slot off. Only an account your account may use is taken, and only one of a type the step takes.

Parameters
connectionConnection | string | nullrequired
options.slotstring
Returns

This step, its connections as written.

mock

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
outputunknownrequired
Returns

This step, its mock_output set.

unmock

unmock(): Promise<this>

Have the step run for real on test runs again.

Returns

This step.

EditBatch

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.

Attributes
opsJsonObject[]

The edits queued so far, as the API takes them (a connection given as an object is resolved when sent).

resultWorkflowEdit | null

What the batch did, once it was sent (null before, or when nothing was queued).

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

addStep

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
typestringrequired
options.operationstring

What it does, one of its type's operations.

options.settingsJsonObject
options.namestring

Its name in the app.

options.idstring

Its id; made from its type when left out.

options.positionPosition

Where it sits; left out, it's laid out beside the rest.

Returns

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

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

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

updateStep

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

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

Parameters
stepStepRefrequired
updateStepUpdaterequired
Types
/** 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). */
  settings?: JsonObject;
  name?: string;
  operation?: string;
  /** `false` switches the step off; `true` back on. */
  enabled?: boolean;
}

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

patchStep

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
stepStepRefrequired
fieldstringrequired
patchstringrequired
Types
/** A step, or its id. */
type StepRef = Step | string;

removeStep

removeStep(step: StepRef): void

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

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

connect

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

Queue an edge from source into target, as Step.connect makes it.

Parameters
sourceStepRefrequired
targetStepRefrequired
options.kind"data" | "tools"default "data"
options.handlestring
Types
/** A step, or its id. */
type StepRef = Step | string;

disconnect

disconnect(
  source: StepRef,
  target: StepRef,
  options?: { handle?: string },
): void

Queue removing the edge from source into target.

Parameters
sourceStepRefrequired
targetStepRefrequired
options.handlestring
Types
/** A step, or its id. */
type StepRef = Step | string;

setConnection

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
stepStepRefrequired
connectionConnection | string | nullrequired
options.slotstring
Types
/** A step, or its id. */
type StepRef = Step | string;

mockStep

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

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

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

unmockStep

unmockStep(step: StepRef): void

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

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

updateWorkflow

updateWorkflow(update: WorkflowUpdate): void

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

Parameters
updateWorkflowUpdaterequired
Types
/** 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;
}

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

move

move(step: StepRef, position: Position): void

Queue moving a step (or a note) on the canvas. Moving things is never a version of its own.

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

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

layout

layout(): void

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

addNote

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
contentstringrequired
options.idstring
options.colornumber

The app's colours, 0 to 20.

options.nearStepRef[]

Steps it sits beside.

options.direction"above" | "below" | "left" | "right"

Which side of near: above (the default), below, left or right.

options.afterStepRef

With before: the first step of the stretch it covers.

options.beforeStepRef

With after: the last step of the stretch it covers.

options.widthnumber
options.heightnumber
Returns

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

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

defineVariable

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
namestringrequired
options.valuestringdefault ""
options.descriptionstring
options.perUserboolean

addTestRun

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
triggerStepRefrequired
namestringrequired
bodystringrequired
options.titlestring
options.authorstring
options.handlestring
Types
/** A step, or its id. */
type StepRef = Step | string;

WorkflowEdit

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, agent_credential_hint). 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.

Attributes
workflowIdstring
versionnumber
historyVersionnumber | null
changedboolean
summarystring | null
resultsJsonObject[]
stepsRecord<string, JsonObject>
graphWorkflowGraph | null
restoredFromnumber | null
rawJsonObject

The response JSON exactly as the API sent it.

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

WorkflowVersion

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, or baseline, the workflow before its history began), 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).

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.

Attributes
workflowIdstring
historyVersionnumber
versionnumber
sourcestring
author{ user_id: string; key_id: string | null } | null
authors{ user_id: string; key_id: string | null }[]
summarystring | null
changesstring[]
restoredFromnumber | null
createdAtDate | null
updatedAtDate | null
graphWorkflowGraph | null
rawJsonObject

The response JSON exactly as the API sent it.

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

BuildQuestion

interface BuildQuestion

What a build waits on. Each of inputs is { id, label, type, description, options? }; answer them with build.answer({ [id]: value }) where answerableFromCode. An input of type credential (an account to connect) or env (secret values) needs a person: send them to answerUrl, and the build goes on once they answer.

Attributes
idstring | null
titlestring | null
inputsJsonObject[]
answerUrlstring | null
answerableFromCodeboolean
rawJsonObject

The response JSON exactly as the API sent it.

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