Skip to main content

Author and deploy over the API

Create an Unstract Flow workflow, write its spec, connect it to your systems, prepare it and deploy it from your own code or an AI assistant, without opening the editor. Every request acts as the person who created the API key, with that person's permissions in your organization, and every path below starts with /api/v1/external/accounts/<organization-id>.

Permissions​

RequestsPermission needed
Read a workflow, its spec, versions, connectors, pipeline items and builds; list connectorsworkflow:read
Create or change a workflow, save or check a spec, add, link or remove a connector, reset, remove or expedite pipeline items, prepare, cancel or tag a buildworkflow:write
List credentialscredential:read
Read deployments and their runsdeployment:read
Create or change a deployment, regenerate a webhook keydeployment:write
Delete a deploymentdeployment:delete
Activate, pause or run a deploymentdeployment:schedule

The key's creator also needs access to the workflow's project: one they own, one shared with them (a Blueprint share to read, a Collaborate share to change), or any project of the organization when they are an organization admin. Projects explains them. A workflow of another organization, or an ID that names nothing, gets 404. A workflow the creator may not open or change gets 403.

Write IDs in the path in lower case with hyphens, as Flow shows them. Any other spelling gets 404.

Create a workflow​

POST /api/v1/external/accounts/<organization-id>/workflows
FieldWhat it holds
nameRequired, 1 to 255 characters. A name you already use gets a number added, as in the app.
descriptionOptional.
specOptional. The spec's text, saved as main.md of version 1.
curl -X POST "$FLOW_URL/api/v1/external/accounts/$FLOW_ORG/workflows" \
-H "X-API-Key: $FLOW_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: create-invoice-intake" \
-d '{"name": "Invoice intake", "spec": "Read each invoice from @extfs_s3."}'

Flow puts the new workflow in a new project of its own, named after it and owned by the key's creator, so it opens from their Projects list in the app. The answer is 201 with the workflow, plus warnings about the spec's connector mentions (see Write the spec). Send the same Idempotency-Key again with the same body and Flow returns the workflow the first request made, with the header Idempotent-Replayed: true. An Idempotency-Key belongs to the API key that sent it: another key sending the same value gets its own result. A replay checks your access again first, so a workflow or deployment you can no longer see gets the refusal a new request would.

FieldWhat it holds
workflow_idThe workflow's ID.
name, descriptionAs saved.
statusdraft, prepared or archived.
latest_versionThe number of the newest saved version of the spec, or null when there is none.
toolsEach connector instance: tool, instance and ready (true once it has what it needs to run).
latest_buildThe newest build's build_id, status and tag, or null.
active_deploymentsHow many of its deployments are active.
created_at, updated_atISO 8601 times.

GET /workflows/<workflow-id> returns the same fields without warnings.

Change or archive a workflow​

PATCH /api/v1/external/accounts/<organization-id>/workflows/<workflow-id>

Send any of name, description and archived. A name you already use for another workflow gets 409 NAME_TAKEN. "archived": true archives the workflow and pauses its active deployments. "archived": false sets an archived workflow back to draft and leaves its deployments paused; activate them one by one.

Write the spec​

GET /api/v1/external/accounts/<organization-id>/workflows/<workflow-id>/spec
PUT /api/v1/external/accounts/<organization-id>/workflows/<workflow-id>/spec

GET returns {"version": 3, "pages": [{"name": "main.md", "content": "…"}]}, the newest version with its pages in order. A workflow with no saved spec returns version 0 and no pages.

PUT saves a new version from either text (one page, main.md) or pages (a list of name and content; the first page is the entry page). Page names end in .md and differ from each other. Add base_version to refuse the save when someone saved a newer version since you read it, and notes to label the version.

curl -X PUT "$FLOW_URL/api/v1/external/accounts/$FLOW_ORG/workflows/$WORKFLOW_ID/spec" \
-H "X-API-Key: $FLOW_API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "Split each invoice with @pdf_tools and post the total to @slack.", "base_version": 1}'

The answer is 201:

FieldWhat it holds
versionThe new version's number.
tools_addedConnector instances this save added, as tool and instance.
tools_removedConnector instances this save removed.
tools_needing_credentialInstances that need a credential and have none. Link one under Connectors and credentials.
warningsMentions that added nothing, or added an instance with another number. An @file: or @table: name gets no warning: it names a file or a reference table of the project.

A mention adds a connector only when it is the connector's exact name, in any case: @slack, @SLACK, or @slack:2 for instance 2. When the workflow has no instance of that connector, Flow adds one, numbered after the highest it has had, and links the project's credential for that connector when the project holds exactly one. A display name or category, such as @gmail, adds nothing and warns; use the name that GET /tools gives (email_gmail). @slack:3 on a workflow that has Slack instances 1 and 2 adds nothing and warns. A connector the spec no longer mentions is removed, unless the workflow has an active deployment or the instance has a changed setting, a call limit, default inputs, or a linked credential that isn't the project's only one for that connector.

Saving sets the workflow back to draft, so it needs preparing again. An archived workflow stays archived.

StatusCodeWhen
409SPEC_CHANGEDbase_version isn't the newest version, or another save took the version number first. details.current_version holds the newest one; read the spec again and save on top of it.
413SPEC_TOO_LARGEThe spec is over the size limit, 250 KB by default.
422VALIDATION_ERRORBoth or neither of text and pages, empty text, no pages, a page name that doesn't end in .md, or two pages with one name.

Versions​

GET /api/v1/external/accounts/<organization-id>/workflows/<workflow-id>/versions
GET /api/v1/external/accounts/<organization-id>/workflows/<workflow-id>/versions/<version>

The list holds version, notes, created_by and created_at for each version, newest first. limit and offset page through it. One version adds its pages; a number the workflow doesn't have gets 404 VERSION_NOT_FOUND.

Check a spec​

POST /api/v1/external/accounts/<organization-id>/workflows/<workflow-id>/check-spec

Flow reads the spec for problems that make a workflow run badly, such as a review step inside a loop over many items. Send {"text": "…"} to check text you haven't saved, or {} to check the newest version. Nothing is saved.

The answer has ok, skipped (true when the check didn't run, with the cause in reason) and warnings, each an issue and a suggestion.

StatusCodeWhen
400NO_SPECThere is no text to check.
413SPEC_TOO_LARGEThe text is over the size limit.
429TOKEN_LIMIT_REACHEDYour organization reached its limit for preparing and checking specs.
503CHECK_UNAVAILABLEThis Flow deployment doesn't have the check set up.

Connectors and credentials​

RequestWhat it does
GET /toolsLists connectors under tools, each a tool, label, category and needs_credential. Filter with category or search.
GET /workflows/<workflow-id>/toolsLists the workflow's connector instances under tools.
POST /workflows/<workflow-id>/toolsAdds an instance: {"tool": "slack"}, optionally with credential_id. Without one, the instance gets the project's credential for that connector when the project holds exactly one. 201.
PATCH /workflows/<workflow-id>/tools/<tool>/<instance>Links a credential: {"credential_id": "…"}. null unlinks it.
DELETE /workflows/<workflow-id>/tools/<tool>/<instance>Removes the instance. 204.
GET /credentialsLists the credentials the key's creator owns or was shared under credentials, each a credential_id, name, tool, type and valid, sorted by tool then name. Filter with tool. Pages with limit (1 to 200, default 50) and offset (default 0): a page shorter than limit is the last.

An instance is tool, instance, label, credential (credential_id and name, or null) and ready. Credentials are created and connected in the app, on the Credentials tab beside Projects, and a project's page adds existing ones to the project; the API lists and links them and never returns a secret.

The key's creator can link any credential in the workflow's project, whoever owns it, and any credential they own or that is shared with them. Linking one the project doesn't hold yet adds it to the project: every workflow in the project can then use it, and anyone who can edit the project can link it. GET /credentials leaves out a colleague's credential that is in the project but not shared with the key's creator; GET /workflows/<workflow-id>/tools shows its credential_id and name on the instances that use it. Projects covers a project's credentials.

StatusCodeWhen
404CREDENTIAL_NOT_FOUNDNo credential of your organization has that ID, or the credential is outside the workflow's project and is neither the key creator's nor shared with them.
404TOOL_INSTANCE_NOT_FOUNDThe workflow has no such instance.
409TOOL_IN_USEThe workflow has an active deployment. Removing an instance changes the numbers that deployment's build uses; pause it first.
409WORKFLOW_MOVEDThe workflow moved to another project while the request ran. Send it again; the key creator's access is then checked against the new project.
422UNKNOWN_TOOLThe name isn't a connector's exact name.
422CREDENTIAL_TOOL_MISMATCHThe credential is for another connector.

Pipeline items​

An email, file or Database connector instance keeps a pipeline: the threads, files or table rows the workflow works through. These requests read and change an instance's pipeline, as its pipeline tab in the editor does. <tool> is matched in any case.

RequestWhat it does
GET /workflows/<workflow-id>/tools/<tool>/<instance>/itemsLists the instance's items. Filter with status. Pages with limit (1 to 200, default 50) and offset (default 0).
POST /workflows/<workflow-id>/tools/<tool>/<instance>/items/reset with "action": "reset_status"Puts up to 100 items back to AVAILABLE, and the next run processes them again: {"item_ids": ["…"], "action": "reset_status"}.
POST /workflows/<workflow-id>/tools/<tool>/<instance>/items/reset with "action": "delete"Removes up to 100 items. The next run that finds one in its source adds it back as AVAILABLE.
POST /workflows/<workflow-id>/tools/<tool>/<instance>/items/reset-allPuts the instance's items back to AVAILABLE, as Reset All does, and leaves every other instance's pipeline as it is. {"mode": "all"} is the default.
POST /workflows/<workflow-id>/tools/<tool>/<instance>/items/expediteFiles only. Moves up to 100 files to the front of the queue, so the next run claims them before the rest: {"item_ids": ["…"]}. Send "expedite": false to put them back in their place.

A list is tool, instance, kind (file, record or thread), items, total (items matching the filter) and status_counts (all the instance's items by status, whatever the filter).

An item is item_id, status, source (a file's path, a record's table, or a thread's mailbox), run_id (the run that last claimed it), held_by_run_id, retry_count, last_error, expedite (files), update_pending (threads), created_at and updated_at. A field that doesn't apply to the kind is null. held_by_run_id names a run that holds the item and is still going, at the moment of the list; a reset checks again, so it can refuse an item the list showed with null.

A status is the value the pipeline stores: AVAILABLE, CLAIMED, STAGED, IN_PROGRESS, PROCESS_SUCCESS (Success), PROCESS_FAILED (Failed), SOURCE_UNAVAILABLE, UNREADABLE, or UNKNOWN for a file whose record names no status. Records are sorted by updated_at, newest first. Files and threads are too, after the UNREADABLE ones.

A reset answers with action, succeeded, failed and errors. An ID sent twice counts once. Resetting an item that is already AVAILABLE counts as a success; on a file, it also clears expedite. Each sentence in errors names what wasn't changed:

SentenceWhat to do
<id>: skipped (busy: being processed, retry shortly)A run was claiming or marking the item. Send it again.
<id>: could not be changed. Send it again.Send it again.
Stopped after <n> item(s): storage could not be reached. …Covers every item after the first <n>. Send those again.
Record <id> not found, File <id> not found in pipeline, Thread <id> not found in pipelineThe pipeline has no such item.
File <id> could not be read, so it was not reset. Remove it instead., and the same for a ThreadIts record is UNREADABLE. Send it with "action": "delete".
StatusCodeWhen
400INVALID_ITEM_IDA file or thread ID is empty, or holds .. or a control character; a thread ID can't hold / either. Nothing was changed.
404TOOL_INSTANCE_NOT_FOUNDThe workflow has no such instance.
404NO_PIPELINEThe connector keeps no pipeline.
409ITEM_HELD_BY_RUNA run that is still going holds one of the items; details.held lists each item_id and run_id. Nothing was changed. Wait for the run to end, or cancel it.
409WORKFLOW_MOVEDThe workflow moved to another project while the request ran. Nothing was changed. Send it again; the key creator's access is then checked against the new project.
422VALIDATION_ERRORitem_ids is empty or holds more than 100 IDs, action is neither reset_status nor delete, limit is outside 1 to 200, or <instance> isn't a number.

Reset a whole pipeline​

reset-all takes a mode:

modeWhat it resetsFilesThreadsRecords
allEvery item that isn't AVAILABLEYesYesYes
last_nThe count items updated most recently, of those that aren't AVAILABLE: {"mode": "last_n", "count": 20}YesYesNo
before_dateThe items that aren't AVAILABLE and were last updated before before_date, an ISO 8601 time, read as UTC when it has no offset: {"mode": "before_date", "before_date": "2026-10-01T00:00:00Z"}. An item with no update time is left out.YesYesNo

A thread that is AVAILABLE but waiting after a failed read is reset too, which ends the wait. An AVAILABLE file is left as it is, expedite included.

An item held by a run that is still going is left as it is, and so is a file or thread a run is claiming or marking at that moment. The rest are reset. On a Database instance, a run that starts while the reset runs isn't seen as holding anything. The answer is mode, reset_count, skipped_count (the items left as they were), failed_count and message, which names the runs holding skipped items and adds a sentence such as Skipped 2 files that were busy. Try again. for busy ones:

{
"mode": "all",
"reset_count": 12,
"skipped_count": 1,
"failed_count": 0,
"message": "Reset 12 pipeline files (all files). Skipped 1 file that run run-4f2a9c81d3e0 is still working on."
}

failed_count counts the files or threads storage failed to read or reset, and a listing that failed counts once. They were left as they were, and message ends Send the request again. When storage failed and nothing was reset, the answer is 503.

StatusCodeWhen
400MODE_NOT_SUPPORTEDmode is last_n or before_date on a Database instance.
404TOOL_INSTANCE_NOT_FOUNDThe workflow has no such instance, or it was removed while the request ran.
404NO_PIPELINEThe connector keeps no pipeline.
409WORKFLOW_MOVEDAs for a reset of items.
422VALIDATION_ERRORmode is none of the three, last_n has no count (or one below 1), or before_date has no before_date.
503PIPELINE_UNAVAILABLEA file or thread pipeline's storage couldn't be reached, and nothing was reset. Send it again.

Expedite files​

Only an AVAILABLE file can be expedited, because a run claims only AVAILABLE files. To move a failed file to the front, reset it first with "action": "reset_status", then expedite it. Reset first, because a reset clears expedite.

The answer is expedite (the value sent), succeeded, failed and errors. A file that already has the value sent counts as a success. Each sentence in errors names a file that wasn't changed:

SentenceWhat to do
<id>: its status is <status>, and only AVAILABLE files can be expedited.Wait until it is AVAILABLE. For PROCESS_FAILED, DOWNLOAD_FAILED and PROCESS_SUCCESS the sentence goes on: Reset it first ("action": "reset_status"), then expedite it.
<id>: skipped (busy: being processed, retry shortly)A run was claiming the file. Send it again.
File <id> not found in pipelineThe pipeline has no such file.
<id>: could not be changed. Send it again., Stopped after <n> item(s): …As for a reset of items.
StatusCodeWhen
400NOT_EXPEDITABLEThe instance keeps database records or email threads. Only files can be expedited.
400INVALID_ITEM_IDA file ID is empty, or holds .. or a control character. Nothing was changed.
404TOOL_INSTANCE_NOT_FOUND, NO_PIPELINEAs for a list.
409WORKFLOW_MOVEDAs for a reset of items.
422VALIDATION_ERRORitem_ids is empty or holds more than 100 IDs, or expedite isn't true or false.

Prepare and follow a build​

Preparing turns the newest version of the spec into a build that can run. It takes minutes; follow it until status is completed or failed.

RequestWhat it does
POST /workflows/<workflow-id>/buildsPrepares the newest version. 202 with build_id and status queued. Takes Idempotency-Key.
GET /workflows/<workflow-id>/buildsRecent builds, newest first. limit sets how many.
GET /workflows/<workflow-id>/builds/<build-id>One build.
POST /workflows/<workflow-id>/builds/<build-id>/cancelCancels a queued or running build.
PUT /workflows/<workflow-id>/builds/<build-id>/tagTags a completed build: {"tag": "release-1"}.

A build is build_id, status (queued, running, completed, failed or cancelled), version (the spec version it was prepared from), tag, error (why it failed, in a sentence, or null), warnings (places where the spec contradicts itself), created_at and completed_at.

A tag is up to 100 letters, digits, dots, dashes and underscores. The same tag on the same build again changes nothing.

StatusCodeWhen
400NO_SPECThe newest version has no text.
404BUILD_NOT_FOUNDThe workflow has no build with that ID.
409BUILD_IN_PROGRESSA build is queued or running; details.build_id names it.
409WORKFLOW_ARCHIVEDThe workflow is archived.
409COMPILER_UNAVAILABLEThe workflow is set to a build method this Flow deployment has turned off.
409BUILD_FINISHEDThe build you asked to cancel already finished.
409BUILD_NOT_READYOnly a completed build can be tagged.
409TAG_TAKENAnother build of the workflow has that tag.
429TOKEN_LIMIT_REACHEDYour organization reached its limit for preparing and checking specs.

Deploy​

RequestWhat it does
POST /deploymentsCreates a deployment. 201. Takes Idempotency-Key.
GET /deploymentsLists deployments under deployments. Filter with workflow_id and status (active, inactive or error); limit 1 to 100 (default 50), offset.
GET /deployments/<deployment-id>One deployment.
PATCH /deployments/<deployment-id>Changes name, the build (tag or build_id), cron, timezone, parallelism or auto_retry. Only the deployment's creator can.
POST /deployments/<deployment-id>/activateMakes it active. Activating an active deployment changes nothing.
POST /deployments/<deployment-id>/pausePauses it. Pausing a paused deployment changes nothing.
POST /deployments/<deployment-id>/regenerate-keyGives a webhook deployment a new key and returns the deployment with webhook_url and webhook_key. The old key stops working at once. Takes Idempotency-Key.
DELETE /deployments/<deployment-id>Deletes it. 204 with no body. Its schedule and webhook stop; runs already started go on, and the run history keeps them.
POST /deployments/<deployment-id>/runsStarts a run: {"initial_variables": {…}}. 202 with the same run fields as Start a run.
GET /deployments/<deployment-id>/runsIts runs under runs, newest first. limit 1 to 100 (default 50). Pass next_cursor back as cursor for the next page.

The create request:

FieldWhat it holds
workflow_id, name, typeRequired. Names are unique in the organization. type is on_demand, scheduled or webhook.
tag or build_idThe build to deploy, one of the two. With neither, the workflow's newest completed build.
cron, timezoneFor scheduled: a cron expression no more often than your organization's minimum interval, and a time zone such as Europe/London.
parallelismFor scheduled: runs started at each time. For webhook: runs in flight at once; left out, no limit. Up to your organization's cap. Default 1 for the others.
auto_retryRetry settings, as in the app: enabled, mode (from_failure or from_start, required when enabled) and max_retries (1 to 10).
activatetrue to make it active at once. Default false. Needs deployment:schedule as well as deployment:write; without it the request gets 403 and nothing is created.

When the build has no tag, Flow tags it v1, v2 and so on, one more than the workflow's tagged builds, and the answer's tag says which. The tag stays even if the request is then refused.

A webhook deployment's answer adds webhook_url and webhook_key. The key is shown once: store it at once. Repeating the request with the same Idempotency-Key returns the deployment with webhook_key null and a note. If you lost the key, regenerate it with POST /deployments/<deployment-id>/regenerate-key. A regenerated key is also shown once, and a repeat of that request with the same Idempotency-Key answers the same way, without making another key.

A deployment is deployment_id, name, workflow_id, type, status, tag, build_id, cron, timezone, parallelism, auto_retry, created_by, last_run_at, next_run_at and created_at. A webhook deployment's parallelism is null when it has no limit; on PATCH, an explicit "parallelism": null removes a webhook's limit, and leaving the field out keeps it. Another member's private deployment gets 404.

StatusCodeWhen
400INVALID_CURSORcursor isn't one a previous response returned.
400NOT_A_WEBHOOKRegenerating the key of a deployment that isn't a webhook.
403NOT_DEPLOYMENT_CREATOROnly the person who created a deployment can change it.
404WORKFLOW_NOT_FOUNDYour organization has no workflow with that ID.
404DEPLOYMENT_NOT_FOUNDThe deployment doesn't exist, or the key's creator can't see it.
404NO_BUILDThe workflow has no completed build.
404TAG_NOT_FOUNDThe workflow has no completed build with that tag.
409NAME_TAKENAnother deployment of your organization has that name.
409WORKFLOW_ARCHIVEDThe workflow is archived.
409BUILD_NOT_READYThe build isn't a completed build of this workflow.
409TAG_TAKENThe four tags Flow tried, v{n} to v{n+3}, were all taken. Tag the build yourself, then deploy it by tag.
409BUILD_STALEThe build uses connector instances removed or replaced since it was prepared. Prepare again and redeploy.
409DEPLOYMENT_NOT_ACTIVEStarting a run of a paused deployment.
422DEPLOYMENT_INVALIDThe schedule or parallelism breaks your organization's limits, or a scheduled deployment has no cron.
402QUOTA_EXCEEDEDStarting a run when your organization has used its allowance. See Rate limits and errors.
429HTTP_429Starting a run when your organization has as many runs in flight as it may.

When activate is true and the deployment can't go live, Flow still creates it, paused, with a note saying why.

Walkthrough​

H=(-H "X-API-Key: $FLOW_API_KEY" -H "Content-Type: application/json")
API="$FLOW_URL/api/v1/external/accounts/$FLOW_ORG"

# 1. Create the workflow.
WORKFLOW_ID=$(curl -s -X POST "$API/workflows" "${H[@]}" \
-d '{"name": "Invoice intake", "spec": "Read each invoice."}' | jq -r .workflow_id)

# 2. Save the spec; it names the connectors.
curl -s -X PUT "$API/workflows/$WORKFLOW_ID/spec" "${H[@]}" \
-d '{"text": "Split each invoice with @pdf_tools and post the total to @slack."}'

# 3. Link a credential to the Slack instance.
CRED=$(curl -s "$API/credentials?tool=slack" "${H[@]}" | jq -r '.credentials[0].credential_id')
curl -s -X PATCH "$API/workflows/$WORKFLOW_ID/tools/slack/1" "${H[@]}" \
-d "{\"credential_id\": \"$CRED\"}"

# 4. Prepare, then poll until the build is completed.
BUILD_ID=$(curl -s -X POST "$API/workflows/$WORKFLOW_ID/builds" "${H[@]}" | jq -r .build_id)
curl -s "$API/workflows/$WORKFLOW_ID/builds/$BUILD_ID" "${H[@]}" | jq -r .status

# 5. Tag it and deploy it, active.
curl -s -X PUT "$API/workflows/$WORKFLOW_ID/builds/$BUILD_ID/tag" "${H[@]}" -d '{"tag": "release-1"}'
DEPLOYMENT_ID=$(curl -s -X POST "$API/deployments" "${H[@]}" \
-d "{\"workflow_id\": \"$WORKFLOW_ID\", \"name\": \"Invoices\", \"type\": \"on_demand\", \"tag\": \"release-1\", \"activate\": true}" \
| jq -r .deployment_id)

# 6. Run it.
curl -s -X POST "$API/deployments/$DEPLOYMENT_ID/runs" "${H[@]}" -d '{"initial_variables": {}}'
Limitations
  • Workflows written in the app's collaborative mode can be read, renamed and archived over the API, and nothing else: reading or saving a spec, checking it, changing connectors and preparing answer 409 COLLABORATIVE_WORKFLOW.
  • Credentials, OAuth connections, secrets and input files are made in the app. The API lists the key creator's own and shared credentials and links them; it has no list of a project's credentials.
  • Workflows are archived, never deleted, over the API. A deleted deployment can't be brought back.
  • The Architect, and the settings of a single step of a build, stay in the app.