Using variables in Apigee Integration

Stay organized with collections Save and categorize content based on your preferences.

You're viewing Apigee X documentation.
View Apigee Edge documentation.

A variable is an integration element that holds and transports data between the tasks, triggers, and edges of an integration.

  • Variables can be statically defined at design time or dynamically passed to the integration at runtime.
  • Variables can reference other variables in an integration.
  • Variables can be globally accessible to all tasks, or locally accessible to a specific task.

Two types of variables are available:

Integration variables

Integration variables are similar to variables used in a programming language. Data in the variables can be read and written throughout the execution of the integration.

Integration variables can be used in the following ways:

  • Taken in as inputs to the integration(input variables).
  • Returned as outputs of the integration(output variables).
  • Used to hold temporary state during the execution of an integration.

The value of a variables does not have to be statically defined in the integration. Variable values can be passed into an integration through the use of a trigger. However, if a variable is statically defined in the integration, and the same variable is supplied dynamically with trigger, the dynamic value assignment will overwrite the static assignment.

Format of an integration variable

An integration variable contains the following information:

  • Name: Specifies the name of the variable in the integration.
  • Data Type: Specifies the data type of the variable in the integration. You can identity the data type of a variable using the colored icon next to the variable name.
    String
    Integer
    Double
    Boolean
    JSON
    String array
    Integer array
    Double array
    Boolean array

    For information about the supported data types, see Supported data types.

  • Default Value:Specifies the default value for the variable in the integration. This is an optional field.
  • Schema: Specifies the JSON schema of the variable in the integration.
    • Infer from a sample JSON payload: Generate a JSON schema from a sample JSON payload. The sample payload is discarded after the schema is generated. Only the generated schema will be saved.
    • Enter a JSON schema: Manually enter an entire JSON schema.
    • Infer from the default value: Generate a JSON schema using the provided default value.
    • None: No JSON schema.
  • Settings relating to variable usage and searchability in execution logs.

Supported data types for integration variables

The following data types are supported for integration variables:

  • String and String array
  • Integer and Integer array
  • Double and Double array
  • Boolean and Boolean array
  • JSON

Task variables

Task variables are pre-defined variables of a task. If a task has an output, all such ouputs are available in a task variable. You cannot delete or edit a task variable. For example, in the Call REST Endpoint task, the response body is stored in the responseBody variable.

Defining variables in integration

The integration designer lets you to define and initialize variables. You can view all the variables of an integration by clicking the VAR (manage variables) button in the integration designer toolbar.

The following image shows the Create Variable pane:

create variable configuration pane

Using variable data in integrations

During the execution of an integration, run-time data is passed in as variables that are declared for the integration or task. Once execution begins, input data is converted into an in-memory object called an Event.

After the Event object is created, an in-memory graph of tasks is built using the integration definition. Incoming variable values are passed to tasks based on your configuration. As the integration executes, the tasks read and write data back into the Event object,to be used by subsequent tasks or to form the output data of the integration.

Persisting variable data

During the execution of the integration, the integration platform persists variable data periodically to enable retries in the event of failure and to serve the execution logs for debugging and monitoring purposes. You can control the persistence of this data, by setting the Searchable in Execution Logs option for a variable.