Examples
Five examples demonstrating Stop Workflow at different exit points in real workflows.
Example 1 — Early Exit on Cancellation Condition
A subscription renewal workflow first checks whether the customer has already cancelled their account. If the account is already inactive, there is nothing to renew — terminate immediately with a cancelled status.
// Switch node checks var.accountStatus === 'inactive'
// If true, routes to this Stop Workflow node:
{
"node_type": "StopWorkflow",
"name": "AccountAlreadyInactive",
"config": {
"status": "cancelled",
"message_expression": "{@ 'Account ' + var.accountId + ' is already inactive. No renewal action taken.' }"
}
}
cancelled with a clear message. The monitoring dashboard does not alert on this as an error. The account team can filter for these in reporting to understand churn timing.Example 2 — Terminate After Maximum Retries
A retry loop attempts to call a payment API up to 3 times. After the third failure, a Loop Break node exits the loop and the workflow terminates with failed status, logging the last error.
{
"node_type": "StopWorkflow",
"name": "PaymentAPIMaxRetriesExceeded",
"config": {
"status": "failed",
"message_expression": "{@ 'Payment API call failed after ' + var.retryCount + ' attempts. Order ' + var.orderId + ' could not be processed. Last error: ' + var.lastApiError }"
}
}
Example 3 — Stop on Data Validation Failure
A contact import workflow validates each record before processing. If a required field is missing or malformed, stop the workflow immediately rather than processing invalid data into the CRM.
{
"node_type": "StopWorkflow",
"name": "ContactValidationFailed",
"config": {
"status": "failed",
"message_expression": "{@ 'Validation failed for contact record. Field: ' + var.failedField + '. Value received: \"' + var.failedValue + '\". Expected: ' + var.expectedFormat }"
}
}
Example 4 — Explicit Success Completion with Summary
An invoice generation workflow ends with a rich success message that summarises what was accomplished. This message appears in the execution history and can be surfaced in dashboards.
{
"node_type": "StopWorkflow",
"name": "InvoiceGenerationComplete",
"config": {
"status": "success",
"message_expression": "{@ 'Invoice ' + var.invoiceNumber + ' (total: $' + var.invoiceTotal + ') generated and emailed to ' + var.customerEmail + ' at ' + var.completedAt + '.' }"
}
}
Example 5 — Business Rule Short-Circuit
A duplicate detection check at the start of an order processing workflow identifies that this order was already processed (idempotency check). Stop immediately to avoid double-processing.
// IfCondition: var.isDuplicateOrder === true → routes here
{
"node_type": "StopWorkflow",
"name": "DuplicateOrderDetected",
"config": {
"status": "cancelled",
"message_expression": "{@ 'Duplicate order detected. Order ' + var.orderId + ' was already processed on ' + var.originalProcessedAt + ' (execution ID: ' + var.originalExecutionId + '). No further action taken.' }"
}
}
cancelled (not failed) because this is an expected, handled condition. The message provides a full audit trail pointing to the original execution. Monitoring does not alert, and the order is not double-charged or double-shipped.