Variable

Store, retrieve, update, and delete workflow variables.

Get Variable

AI-generated

Summary

Retrieves a stored variable value based on the selected scope and namespace.

Inputs

  • scope (required) — Where to store the variable: Local (this execution), Workflow Global, Node Local, Custom Namespace, Cross-Workflow (Shared), or Cross-Workflow (Data Tables).
  • namespace (required) — Namespace to organize variables (required for Workflow Global, Node Local, Custom Namespace, Cross-Workflow, and Cross-Workflow Data Tables).
  • key (required) — The variable key to retrieve. Supports expressions.
  • useDefaultValue — Whether to return a default value when the variable does not exist.
  • defaultValue — Value to return when the variable does not exist and useDefaultValue is enabled.
  • getOutputFieldName — The field name to put the retrieved value in on the output item.
  • outputMode — How to construct the output item: Preserve Input + Add Result, Result Only, or Add / Update Field.

Output shape

A result object containing the retrieved value and metadata (operation, scope, namespace, key, exists).

For the 'Result Only' or 'Add / Update Field' output modes, the value is placed in the specified field name on the output item. For the 'Preserve Input + Add Result' mode, a result object is added with the configured field name. If useDefaultValue is enabled and the variable does not exist, the default value is returned. Variables in the Data Tables scope require valid n8n API credentials.

Examples

Example 1: Retrieve a Workflow Global variable named 'user_balance' in the 'default' namespace.

Scope: Workflow Global, Namespace: default, Key: user_balance, Output Mode: Preserve Input + Add Result

Example 2: Get a Cross-Workflow Data Table variable and return a default message if missing.

Scope: Cross-Workflow (Data Tables), Namespace: shared, Key: session_data, Use Default Value: true, Default Value: 'No session found'

Example 3: Retrieve a Local Execution variable and output only the result in a custom field.

Scope: Local (This Execution), Namespace: default, Key: temp_value, Output Mode: Result Only, Result Field Name: temp

Links

Discussion