Inputs allow you to make your flows more dynamic and reusable.
Instead of hardcoding values in your flow, you can use inputs to make your workflows more adaptable to change.
Defining inputs
Similar to tasks
, inputs
is a list of key-value pairs. Each input must have a name
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, this bracket notation, {{ }}
, is used to wrap an expression. For an input, follow this general {{ inputs.input_name }}
syntax. We gave our input the id
value of user
, so in the example below we express it 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 of defaults
is used rather than 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 way, we can easily change the URL when executing the flow without having to modify 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?