Skip to main content

Variables



The Variables block allows you to create variables whose values can be updated at any point in an API. The Variables block is useful for updating a value over time in a Loop or Condition block, or for referencing a frequently used value across an API.

variable initialized

Access the variable value using .value property on the variable name (e.g., myVar.value).

Variable scoping

Variables follow lexical scoping like variables in code. As such, a variable is available to other API blocks at the same nesting level (or below), relative to where the Variables block is defined.

variable referenced within scope
variable referenced outside scope

Updating / setting variable values

Variables are not typed so they can be updated to any value. In the example below, a variable called nextPage is initialized to true at the start of a backend API that is used to iterate through a paginated REST API. When a condition is met inside a While Loop further down in the API, the variable is updated to false. This can be done with either another Variables block or by setting the variable in code.

Define a new Variables block in the same scope as the original Variables block, using the same variable name whose value you want to update.

variable updated