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:
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 underworkflow_definitionand its authoring revision underedit_revision.
workflow-base.json unchanged and edit the content fields in workflow-update.json.
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 asworkflow.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)
400 and a validation_errors list. See Validation errors.
Deploy from CI
Commit the unchangedworkflow-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.
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 withoutexpected_revision.
See Get API Key and OAuth Clients.
For error responses, see Handling Errors.