Skip to main content
Every workflow is a JSON definition you can keep in version control and deploy with the Workflows API, without opening the Workflow Editor. To build workflows in the UI, see Building Workflows. To run a workflow on a list of records, see Batch Processing.

The workflow definition

A workflow definition is a directed graph of blocks and edges. This is the body for a new workflow. Existing workflow updates also require the revision saved with the document being edited, as shown below.
Each block:
block_name selects what the block does. Changing it while hand-editing JSON changes or breaks the workflow.

Get the JSON for an existing workflow

Build the workflow in the editor once, then export it:
  • In the editor, open the More options menu (⋮) next to Run and select View Workflow Definition. The dialog shows the Workflow ID and the JSON definition.
  • With the API, GET /workflows/{workflow_id} returns the graph under workflow_definition and its authoring revision under edit_revision.
For an update, export the graph and revision from the same response. Run this in a fresh directory; keep workflow-base.json unchanged and edit the content fields in workflow-update.json.
Keep expected_revision unchanged while editing. It belongs to this workflow’s exported base, even if another editor saves a newer version before CI runs.

Create a workflow from JSON

Save the new definition above as workflow.json, without expected_revision, and POST it to create_workflow. Creation needs no existing workflow. The response is the saved workflow; keep its id to run it.
Response (abridged)
With an API key, an invalid definition is rejected with 400 and a validation_errors list. See Validation errors.

Deploy from CI

Commit the unchanged workflow-base.json and your edited workflow-update.json together. CI submits the candidate with its stored expected_revision; it does not fetch a newer revision. Initial deployments use create_workflow. If the shared workflow changed after export, the update is refused and your files remain intact. Export the current shared document into a separate directory, compare it with the original base, and reapply your intended changes onto that new base before submitting again. Copying only a fresh revision into an older candidate overwrites intervening work. See workflow edit conflicts.
After deploying, start runs with POST /workflows/run — see Batch Processing. To deliver results to your own URL when a run completes, add an outgoing_webhook block; see Outgoing Webhooks.

Authentication

The Workflows API accepts an API key or an OAuth access token. The credential decides ownership: the definition has no organization field, so a workflow belongs to the organization of the credential that created it. An update file belongs to one workflow in that organization. To create a copy in another organization, use that organization’s credential and the creation definition without expected_revision. See Get API Key and OAuth Clients. For error responses, see Handling Errors.