Skip to main content
All CollectionsBuild AutomationsVariables
Global Variables in Torq: Sharing Data Across Workflow Executions
Global Variables in Torq: Sharing Data Across Workflow Executions

Learn how to use global variables in Torq to store and access data across multiple workflow executions efficiently.

Updated over a week ago

Global variables enable you to collect data from one workflow execution, store it, and call/use it in other workflow executions. Data stored within global variables should be considered "temporary" compared to Workspace Variables. Unless the optional Time Limit parameter is adjusted, global variables will be deleted after a year of creation.

Examples of When to Use Global Variables

  1. Passing Event Data: Use Global Variables to communicate the status of tasks between workflows.

  2. Maintaining a Cache List: Keep a running list of recently checked IPs or other temporary data for quick access.

  3. Updating Task Flags: Monitor and update ongoing tasks' status, periodically checking for changes.

Example Use Case: IOC Enrichment Caching

Before processing a new Indicator of Compromise (IOC), check if it has been recently enriched by retrieving the existing results from a global variable.

If no prior data is found, enrich the IOC and store the results in a Global Variable following a specified naming convention.

Managing Global Variables: Steps

The global variable steps are designed to work with arrays of values for easy accessibility and manipulation.

These are optional parameters you may find helpful:

  • Add the DO_NOT_RETURN_VALUE optional parameter for the Set a variable and Append to a variable steps to speed up the execution by avoiding getting the variable's value in the step response.

  • Use the EXPIRES_IN optional parameter to set an expiration period when creating or modifying a variable. An expiration period can be set for a variable when updating or appending to it, even if it was not set when the variable was created.

Set a Variable

Create or update a Global Variable to store data such as text, numbers, arrays, or JSON objects.

Append to a Variable

Add new data to an existing variable without removing old data.

Adjust the expiration period to extend or reduce the variable's lifespan if necessary.

Flatten an Array

To streamline data management, use the 'Concat Arrays' utility step to merge array data seamlessly. Each appended item is added as a new object in the array.

Get a Variable

Retrieve the content of a Global Variable, with options to access entire arrays or single data points for backward compatibility.

The value_array output field can contain an array of values, whereas the value output field can only contain a single value (available for backward compatibility). For array variables, the value output will only get the first member of the array.

List Variables

Obtain a comprehensive list of all Global Variables currently active in your workspace.

Delete a Variable

Remove a Global Variable permanently. This action is irreversible and should be handled with caution to avoid disrupting published workflows.

Did this answer your question?