> For the complete documentation index, see [llms.txt](https://doc.duaer.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.duaer.com/code/variables.md).

# Define custom variables in Duaer

Custom variables let you store and reuse values across Duaer workflows.
## What a variable is

A Duaer variable is a key and value stored for the organization or a project—not a const you declare for one run. When an expression or a Code node runs, Duaer replaces $vars.key with the value at that time.

Every value is a string. A missing value reads as undefined, and the run does not fail because of that. A run cannot change a variable—edit it on Variables. To store data for one run, use custom execution data, not a variable.

## Scope: organization and project

- An organization variable is readable by every workflow in your Duaer organization. Other organizations cannot read or see it.
- A project variable is readable only in that project’s workflows.
- When both use the same key, the project variable overrides the organization one. Organization variable keys are unique within one organization; another organization can use the same key without conflict.
- Only the organization’s owner and admins can create, edit, or delete organization variables. Whether you can create a project variable depends on your role in that project. If the plan does not include variables, the screen tells you to upgrade.

For what an organization is, refer to [Duaer organizations](/organizations.md).

## Create a variable

1. On Variables, select Add variable.
2. Enter a Key and a Value. A key is at most 50 characters; a value is at most 1000. A new key may use letters, numbers, and underscores, and it cannot start with a number—a leading number breaks the $vars.key dot form.
3. When you create from the overview, choose Scope: Organization covers the whole organization, and picking a project limits it to that project. Creating from a project page sets the scope to that project.
4. Select Save.

## Edit or delete a variable

1. On Variables, hover the row you want to change.
2. Select Edit or Delete.

## Use a variable in a workflow

Expressions and the JavaScript Code node both read it:

```
{{ $vars.api_host }}
$vars.api_host
```

The first line is an expression in a node parameter. The second is a Code node. The key is the Key you saved.
## Questions

### How do you read a Duaer variable in an expression?

In Duaer, write $vars.key. Put it inside {{ }} in an expression. In a JavaScript Code node, write $vars.key directly. Every value is a string. A missing value is undefined, and the run does not fail for that.

### Which Duaer variable wins when an organization key and a project key match?

A Duaer organization variable is readable across the organization. A project variable is readable only in that project’s workflows. The project value overrides the organization one. A run cannot change a variable—edit it on Variables.

## Related

- [Transform data with expressions in Duaer](https://doc.duaer.com/code/expressions.md)
- [Use built-in methods and variables in Duaer](https://doc.duaer.com/code/builtin.md)
- [Use convenience methods in Duaer expressions](https://doc.duaer.com/code/builtin/convenience.md)

