Inputs make your flows more dynamic and reusable.
Instead of hardcoding values in your flow, use inputs to make your workflows more adaptable to change.
Defining inputs
Similar to tasks
, inputs
is defined as a list of key–value pairs. Each input must have an id
and a type
. You can also set defaults
for each input. Setting default values for an input is always recommended, especially if you want to run your flow on a schedule.
To retrieve an input value, you need to identify the input in an expression. In Kestra, bracket notation {{ }}
is used to wrap an expression. For an input, follow this general {{ inputs.input_id }}
syntax. In the example below, the input id
is set to user
, and it's referenced in the task message as {{ inputs.user }}
:
id: inputs_demo
namespace: company.team
inputs:
- id: user
type: STRING
defaults: Rick Astley
tasks:
- id: hello
type: io.kestra.plugin.core.log.Log
message: Hey there, {{ inputs.user }}
Try running the above flow with different values for the user
input. You can do this by clicking on the Execute button in the UI and then typing the desired value in the menu. For any downstream task, inputs are accessible using expressions.
The plural form defaults
is used instead of default
for two reasons. First, default
is a reserved keyword in Java, so it couldn't be used. Second, this property allows you to set default values for a JSON object which can be an array that simultaneously defines multiple default values.
Here are the most common input types:
Type | Description |
---|---|
STRING | It can be any string value. Strings are not parsed, they are passed as-is to any task that uses them. |
INT | It can be any valid integer number (without decimals). |
BOOLEAN | It must be either true or false . |
Check the inputs documentation for a full list of supported input types.
Parametrize your flow
In our example below, we provide the URL of the API as an input. This allows you to change the URL at execution time without modifying the flow itself.
id: getting_started
namespace: company.team
inputs:
- id: api_url
type: STRING
defaults: https://dummyjson.com/products
tasks:
- id: api
type: io.kestra.plugin.core.http.Request
uri: "{{ inputs.api_url }}"
To learn more about inputs, check out the full inputs documentation.
Was this page helpful?