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 WorkflowA 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.
- Like every live object, it also has hydrate(), refresh() and raw.
| id | string | |
| name | string | |
| description | string | null | |
| inputs | JsonObject | A JSON schema of what |
| appUrl | string | null | Where to open it in the NoClick app. |
| access | string | Your account's access: |
| 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 |
| version | number | null | Its version as this handle last read or wrote it: what |
| lastEdit | WorkflowEdit | null | What this handle's last edit did ( |
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).
The client to send with; defaults to the module client built from NOCLICK_API_KEY.
The new workflow; latest_build is its build when instructions describe it.
fromNamestatic
static fromName(
name: string,
options?: { description?: string; client?: NoClick },
): WorkflowA 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.
The client to send with; defaults to the module client built from NOCLICK_API_KEY.
A workflow that loads the first time it's used. Nothing is sent yet.
fromIdstatic
static fromId(workflowId: string, options?: { client?: NoClick }): WorkflowA lazy reference to a workflow by id.
The client to send with; defaults to the module client built from NOCLICK_API_KEY.
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.
The client to send with; defaults to the module client built from NOCLICK_API_KEY.
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.
Return at most this many.
The client to send with; defaults to the module client built from NOCLICK_API_KEY.
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.
The next_cursor of the page before; omit it for the first page.
Return at most this many.
The client to send with; defaults to the module client built from NOCLICK_API_KEY.
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.
The WorkflowGraph; this handle's version is now its.
step
step(id: string): StepA 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).
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.
What it does, one of its type's operations.
Its name in the app.
Its id; made from its type when left out.
Where it sits; left out, it's laid out beside the rest.
The new Step, with its verdict and what the edit said about it (notes).
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.
This workflow; it loads again the next time you read a field.
/** 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.
The app's colours, 0 to 20.
Steps it sits beside.
Which side of near: above (the default), below, left or right.
With before: the first step of the stretch it covers.
With after: the last step of the stretch it covers.
The note: a Step of type stickyNote (its text is settings["content"]).
/** 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.
The step, at its new position.
/** 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).
The version the edits were made against (a read's version): refused with Conflict when it moved on since.
true: the answer carries the graph as written.
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.
Return at most this many.
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.
The next_cursor of the page before; omit it for the first page.
Return at most this many.
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.
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.
A WorkflowBuild: wait() gives the WorkflowBuildResult (its steps, and what was
published), and next_question() returns anything it asks first.
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.
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.
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.
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).
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.
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.
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.
An operation whose .wait() gives the finished WorkflowRun, or
raises the run's error if it failed.
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).
Return at most this many.
Which users the read covers (user_id query), instead of acting as one (user).
undefined = the ambient user (asUser), null = the account itself.
The first limit matching runs (20 by default; None for all of them).
/**
* 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.
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.
The endpoint: its url, whether it's public, and the method to call it with.
WorkflowRun
interface WorkflowRunOne 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.
| 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. |
type WorkflowRunStatus = "running" | "succeeded" | "failed";
type JsonObject = { [key: string]: unknown };RunStep
interface RunStepWhat 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.
| id | string | |
| name | string | |
| status | string | |
| error | string | null | |
| output | unknown |
WorkflowEndpoint
interface WorkflowEndpointThe 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.
| url | string | |
| public | boolean | |
| method | string | |
| raw | JsonObject | The response JSON exactly as the API sent it. |
type JsonObject = { [key: string]: unknown };WorkflowBuild
class WorkflowBuild extends OperationA 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.
- Inherits from Operation.
| workflowId | string | null | |
| question | BuildQuestion | null | What the build waits on ( |
nextQuestion
nextQuestion(options?: { timeoutS?: number }): Promise<BuildQuestion | null>Resolve once the build asks something (its question) or finishes (null: wait() gives the result).
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.
This build, running again.
type JsonObject = { [key: string]: unknown };WorkflowBuildResult
interface WorkflowBuildResultA 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).
| workflowId | string | null | |
| summary | string | null | |
| steps | WorkflowStep[] | |
| appUrl | string | null | |
| published | { state: string; url: string | null } | null | |
| raw | JsonObject | The response JSON exactly as the API sent it. |
type JsonObject = { [key: string]: unknown };WorkflowStep
interface WorkflowStepOne 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).
| id | string | |
| name | string | |
| type | string | |
| operation | string | null | |
| enabled | boolean | |
| settings | JsonObject | |
| connection | StepConnection | null | |
| trigger | StepTrigger | null |
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 WorkflowGraphA 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.
| 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. |
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): StepOne 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).
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 StepOne 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().
- Like every live object, it also has hydrate(), refresh() and raw.
| 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: |
| name | string | null | Its name in the app ( |
| operation | string | null | What it does, one of its type's operations ( |
| enabled | boolean | Whether it runs: a step switched off ( |
| settings | JsonObject | Its settings, by field name, as stored (a secret is never read back: see |
| connections | Record<string, string> | The accounts connected to it: each slot (a connection type, like |
| position | Position | null | Where it sits on the canvas. |
| mockOutput | unknown | What it outputs on test runs instead of running ( |
| withheld | string[] | The settings left out of |
| verdict | JsonObject | null | Whether it's ready to run, as the last edit through this handle that touched it judged: |
| notes | JsonObject | What the last edit through this handle answered for its change, beyond the step's id: |
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.
This step as written, with notes and verdict.
/** 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.
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.
"data"This step; notes holds the edge (edge_id, kind).
/** 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.
This step.
/** 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.
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.
This step, its mock_output set.
unmock
unmock(): Promise<this>Have the step run for real on test runs again.
This step.
EditBatch
class EditBatchThe 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.
| 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 ( |
type JsonObject = { [key: string]: unknown };addStep
addStep(type: string, options?: AddStepOptions): StepQueue 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.
What it does, one of its type's operations.
Its name in the app.
Its id; made from its type when left out.
Where it sits; left out, it's laid out beside the rest.
The step, whose id later edits in the batch can name. Its fields load once the batch is sent.
type JsonObject = { [key: string]: unknown };
/** Where a step sits on the canvas. */
interface Position {
x: number;
y: number;
}updateStep
updateStep(step: StepRef, update: StepUpdate): voidQueue a change to a step, as Step.update makes it.
/** 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): voidQueue a patch to one long text setting of a step, as Step.patch makes it.
/** A step, or its id. */
type StepRef = Step | string;removeStep
removeStep(step: StepRef): voidQueue taking a step (or a note) out, with its edges.
/** A step, or its id. */
type StepRef = Step | string;connect
connect(
source: StepRef,
target: StepRef,
options?: { kind?: "data" | "tools"; handle?: string },
): voidQueue an edge from source into target, as Step.connect makes it.
"data"/** A step, or its id. */
type StepRef = Step | string;disconnect
disconnect(
source: StepRef,
target: StepRef,
options?: { handle?: string },
): voidQueue removing the edge from source into target.
/** A step, or its id. */
type StepRef = Step | string;setConnection
setConnection(
step: StepRef,
connection: Connection | string | null,
options?: { slot?: string },
): voidQueue connecting an account to a step, as Step.setConnection does (null with slot takes one off).
/** A step, or its id. */
type StepRef = Step | string;mockStep
mockStep(step: StepRef, output: unknown): voidQueue giving a step output on test runs instead of running it.
/** A step, or its id. */
type StepRef = Step | string;unmockStep
unmockStep(step: StepRef): voidQueue having a step run for real on test runs again.
/** A step, or its id. */
type StepRef = Step | string;updateWorkflow
updateWorkflow(update: WorkflowUpdate): voidQueue a change to the workflow's own fields, as Workflow.update makes it.
/** 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): voidQueue moving a step (or a note) on the canvas. Moving things is never a version of its own.
/** A step, or its id. */
type StepRef = Step | string;
/** Where a step sits on the canvas. */
interface Position {
x: number;
y: number;
}layout
layout(): voidQueue laying every step out again, as the app's Tidy up does.
addNote
addNote(content: string, options?: AddNoteOptions): StepQueue a note on the canvas, as Workflow.addNote makes it; returns the note, whose id later edits can name.
The app's colours, 0 to 20.
Steps it sits beside.
Which side of near: above (the default), below, left or right.
With before: the first step of the stretch it covers.
With after: the last step of the stretch it covers.
The note, a step of type stickyNote whose id later edits can name.
/** A step, or its id. */
type StepRef = Step | string;defineVariable
defineVariable(
name: string,
options?: { value?: string; description?: string; perUser?: boolean },
): voidQueue 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.
""addTestRun
addTestRun(
trigger: StepRef,
name: string,
body: string,
options?: { title?: string; author?: string; handle?: string },
): voidQueue 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.
/** A step, or its id. */
type StepRef = Step | string;WorkflowEdit
interface WorkflowEditWhat 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.
| workflowId | string | |
| version | number | |
| historyVersion | number | null | |
| changed | boolean | |
| summary | string | null | |
| results | JsonObject[] | |
| steps | Record<string, JsonObject> | |
| graph | WorkflowGraph | null | |
| restoredFrom | number | null | |
| raw | JsonObject | The response JSON exactly as the API sent it. |
type JsonObject = { [key: string]: unknown };WorkflowVersion
interface WorkflowVersionOne 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.
| 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 | |
| raw | JsonObject | The response JSON exactly as the API sent it. |
type JsonObject = { [key: string]: unknown };BuildQuestion
interface BuildQuestionWhat 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.
| id | string | null | |
| title | string | null | |
| inputs | JsonObject[] | |
| answerUrl | string | null | |
| answerableFromCode | boolean | |
| raw | JsonObject | The response JSON exactly as the API sent it. |
type JsonObject = { [key: string]: unknown };