Skip to main content

Exit Operator: Configure Output Schemas in Torq

Define output schemas in Torq to standardize workflow outputs for consistency in returned data and more predictable, robust workflows.

Updated today

Use the Exit operator to terminate a workflow at a specific point and, optionally, define the output schema for the data returned when the workflow completes. This enables information from the workflow to be easily integrated with other systems or workflows.

How to use

  1. Add the operator: Drag and drop the Exit operator to the place you want to stop the workflow.

  2. Add parameters: Open the Properties panel and click on + Add parameter to create your output schema. If you need a raw JSON output, click on the Convert to JSON arrow icon to switch the operator to JSON mode.

    • Parameters:

      • Type: Decide what data your parameter will hold (e.g., Text, Number, Boolean, etc.). The default type is Short text.

      • Name: Give your parameter a name. This is how you'll refer to it from a parent workflow or external system.

      • Description: Optionally, you can describe what the parameter is for.

  3. Consistency across all Exit operators: For consistency, ensure all Exit operators in your workflow are updated with the correct parameter values. Use the Event Preview tab to see how your data will look.

Parameters Default Values

  • Short/Long text: empty string

  • JSON: empty

  • Number: 0

  • Boolean: false

  • File: empty

JSON mode

If your workflow needs a custom data structure, you can convert an Exit operator to JSON mode. This allows for a flexible raw JSON output.

  1. Click on the Convert to JSON icon in the Exit operator's Properties panel.

The Properties panel now shows the output JSON, and the operator's icon is changed to indicate it's now in JSON mode.

In JSON mode, you might need to adjust the parent workflow for various data outputs, as not all Exit operators follow a single structure.

Using output schema with nested workflows

Define the structure and content of results returned by the nested workflow, ensuring consistent outputs are passed on to the parent workflow.

The output can either be passed as raw data in context or as a file (particularly useful when the output data is large).

You can reference the output schema of a nested workflow without running it. This allows you to design the parent workflow based on the output of the nested workflow.

Exit operator with large output

On occasion, the Exit output data might exceed data size limits. This can be solved by returning the output data as a file, instead of as raw data in context.

For example, in a nested workflow, convert the Exit operator to return a file as its output, instead of raw data:

  1. Return data output: Use the Print a message to stdout utility step before the Exit operator.

    • Input parameters: In the Properties panel, configure the input parameter with the raw data.

    • Execution options: Configure the Execution options.

      • Return response as a file: This is set to No by default, and the response is saved as context. Toggle to Yes to return a file link.

      • Create a shareable link: The default is No, and the file is returned as a tqfile accessible in Torq workflows only, and which you will use in the Exit step. If you need a URL that can be shared externally, toggle to Yes.

The output is then passed to the parent workflow as a URL:

  1. Use the output file: In the parent workflow, use a Run jq Command utility step.

    • Configure the Input parameter to the file URL.

    • Click on the 3-dot menu on the right of the Input parameter, and change the input type to File URL.

    • Set JSON query to be a dot . (which will return the same output JSON as input).

The output of the step will be the JSON data configured from the nested workflow's raw data output. The same approach can be used for other data types besides JSON, just with an HTTP POST step/ upload to S3, etc.

Did this answer your question?