---
schema_version: "1"
id: 3b45800285efe203f582bc4b4c93183ec3f06b4de5bca2ecbc021303212d39ee
title: Variables in Mule Apps
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/mule-runtime/4.11/about-mule-variables.md
canonical_url: https://docs.mulesoft.com/mule-runtime/4.11/about-mule-variables
source_site: docs.mulesoft.com
content_type: documentation
content_hash: d09ba631e1280d449f128b033995ee34bf4719f7d9cb4c248bc89e1df541cd7d
description: MuleSoft Documentation Site
release: "4.11"
latest: false
---
---
product: Mule Runtime
version: 4.11
---

# Variables in Mule Apps

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

Variables are used to store per-event values for use within a flow of a Mule app. The stored data
can be any supported data type, such as an object, number, or string. It is also possible to store
the current message (using the `message` keyword), the current message payload (using the `payload`
keyword) or just the current message attributes (using the `attributes` keyword). You can even use a
DataWeave expression as the value. However, the keyword `vars` (for example, `vars.someOtherVar`) is
not allowed.

You can create, or update, variables in these ways:

- Using the Set Variable component.

- Using a Target Variable from within an operation, such as the Read operation to the File connector
  or the Store operation to the Database connector.

- Using the DataWeave Transform Component (EE-Only)

- Using Scripting Component (in scripting module)

You can also delete/remove:

- Using the Remove Variable component.

After creating a variable, you can access and use it within the scope of a Mule flow where you
created it, which includes any flows that are joined with it through a Flow Ref component.

- `vars`: Keyword for accessing a variable, for example, through a DataWeave expression in a Mule
  component, such as the Logger, or from an Input or Output parameter of an operation. If the name
  of your variable is `myVar`, you can access it like this: `vars.myVar`

Note that a variable in the Mule event is different from variables defined in a DataWeave script,
which are local to the script and not accessible outside of it.

## See Also

- [Mule Events](https://docs.mulesoft.com/mule-runtime/4.11/about-mule-event)

- [Set Variable Transformer](https://docs.mulesoft.com/mule-runtime/4.11/variable-transformer-reference)

- [Flow Reference Component](https://docs.mulesoft.com/mule-runtime/4.11/flowref-about)

- [Enrich Data with Target Variables](https://docs.mulesoft.com/mule-runtime/4.11/target-variables)

- [DataWeave Language](https://docs.mulesoft.com/mule-runtime/4.11/dataweave)
