# Create Temporary Variable



The **Create Temporary Variable** block is used to initialize variables that are only needed for the duration of a single flow execution. These variables are stored in memory and are discarded once the flow completes, making them ideal for intermediate calculations, loops, or storing temporary request data.

Configuration [#configuration]

| Field             | Required | Description                                                                                                                                            |
| :---------------- | :------: | :----------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Variable Name** |     ✅    | The unique identifier for the variable (e.g., `counter`, `results`). Names must follow the project's variable naming rules (letters and numbers only). |
| **Variable Type** |     ✅    | Select the data type for the variable: `String`, `Number`, `Array`, or `Object`.                                                                       |
| **Value**         |     ✅    | The initial value to assign to the variable. The input field will change based on the selected **Variable Type**.                                      |

<Callout type="info" title="Temporary vs. Persistent">
  Unlike [Set Variable](set-variable.mdx) (which saves to the database), variables created with this block only exist while the flow is running. If you need to access data in a different flow tomorrow, use the **Set Variable** block instead.
</Callout>

<Callout type="success" title="Initialization">
  It is best practice to use this block at the beginning of your flow to define all the temporary variables you'll need.
</Callout>

Error Handling [#error-handling]

* `FIELD_MISSING` — Triggered if the Variable Name or Type is not provided.
* `INVALID_TYPE` — Triggered if an unsupported variable type is selected.
* `STRING_TOO_LONG` — Triggered if the initial string value exceeds 2,000 characters.
* `NUMBER_OUT_OF_RANGE` — Triggered if the number is outside the allowed range.
* `ARRAY_TOO_LARGE` — Triggered if the initial array exceeds 2MB.
* `OBJECT_TOO_LARGE` — Triggered if the initial object exceeds 2MB.
* `RUNTIME_ERROR` — Triggered if an unexpected internal error occurs during variable creation.

Example: Initializing a Loop Counter [#example-initializing-a-loop-counter]

If you are building a flow that processes a list of items, you might need a counter to track your progress.

1. **Add a Create Temporary Variable Block**:
   * **Variable Name**: `loop_index`
   * **Variable Type**: `Number`
   * **Value**: `0`
2. **Usage**: You can now reference this counter in subsequent blocks using `{loop_index}`.
3. **Updating**: Use the [Set Temporary Variable](set-temporary-variable.mdx) block to increment this value within your loop.

Related Blocks [#related-blocks]

<Cards>
  <Card title="Set Temporary Variable" href="/docs/blocks/variable-blocks/set-temporary-variable" />

  <Card title="Set Variable (Persistent)" href="/docs/blocks/variable-blocks/set-variable" />
</Cards>
