Skip to main content

Terminate

The Terminate task is used to terminate the current workflow with a termination status and reason, and to modify the workflow output with a given value.

It can act as a return statement for cases where you want the workflow to be terminated without continuing the subsequent tasks. For example, you want to execute certain tasks only if a condition is met and otherwise terminate the workflow.

Task configuration

Configure these parameters for the Terminate task.

ParameterDescriptionRequired/ Optional
inputParameters. terminationStatusThe termination status for the current workflow. Accepted values:
  • COMPLETED
  • FAILED
  • TERMINATED
Required.
inputParameters. terminationReasonThe reason for terminating the current workflow, which will provide the context of the termination. It can be passed as a variable.Optional.
inputParameters. workflowOutputA map of the expected workflow output on termination. It can contain a string, number, boolean, null, or object/array.Optional.

Task definition

This is the JSON schema for a Terminate task definition.

{
"name": "terminate",
"taskReferenceName": "terminate_ref",
"inputParameters": {
"terminationStatus": "TERMINATED",
"terminationReason": "",
"workflowOutput": {
"key": "value"
}
},
"type": "TERMINATE"
}

Task output

The Terminate task will return the following parameters.

ParameterDescription
outputA map of the workflow output on termination, as defined in inputParameters.workflowOutput. If workflowOutput is not set in the Terminate task definition, the output will be an empty object.

Adding a Terminate task in UI

To add a Terminate task:

  1. In your workflow, select the (+) icon and add a Terminate task.
  2. Select the Termination status.
  3. Enter the Termination reason.
  4. (Optional) Add the workflow output.

Adding wait task

Examples

Here are some examples for using the Terminate task.

Using the Terminate task in a switch case

In a shipping workflow, a decision is made to ship with a specific shipping provider based on provided input while running the workflow. If the provided input does not match with the available shipping providers, then the workflow will fail and terminate. If the input provided matches, then it continues. Here is a snippet that shows the default switch case terminating the workflow:

{
"name": "switch_task",
"taskReferenceName": "switch_task",
"type": "SWITCH",
"defaultCase": [
{
"name": "terminate",
"taskReferenceName": "terminate",
"type": "TERMINATE",
"inputParameters": {
"terminationStatus": "FAILED",
"terminationReason": "{workflow.input.termination-reason}"
}
}
]
}

The full workflow with the Terminate task looks like this:

Terminate Example