Runtime arguments

You can access data passed at runtime by adding a params field to your workflow, which names the argument the workflow uses to store the data you pass in. If passing in a JSON object, you can then use dot notation to access the arguments. For example:

YAML

  main:
      params: [ARG_NAME]
      steps:
        - step1:
            return: ${ARG_NAME.PARAM_NAME}
  

JSON

  {
    "main": {
      "params": ["ARG_NAME",]
      "steps": [
        {
          "step1": {
            "return": "${ARG_NAME.PARAM_NAME}"
          }
        }
      ]
    }
  }
    

Note the following:

  • For a workflow to receive runtime arguments there must be a main block.

  • The main block accepts a single argument that is the name of any valid JSON data type: an array, an object, or a string.

  • As a best practice, passing in an object with multiple, named arguments makes it easier to understand their purpose, and to add arguments. You can also then use dot notation to access the arguments.

  • Other subworkflows can have multiple arguments.

The following workflow returns a "Hello" greeting to a person whose first and last name you pass as a string in JSON format to the workflow in an execution request. For example, if you pass in the argument {"firstName":"Workflows","lastName":"User"}, the results of the execution should include the output "Hello, Workflows User".

YAML

    main:
      params: [person]
      steps:
        - step1:
            assign:
              - outputVar: ${"Hello, " + person.firstName + " " + person.lastName}
        - step2:
            return: ${outputVar}
    

JSON

    {
      "main": {
        "params": [
          "person"
        ],
        "steps": [
          {
            "step1": {
              "assign": [
                {
                  "outputVar": "${"Hello " + person.firstName + " " + person.lastName}"
                }
              ]
            }
          },
          {
            "step2": {
              "return": "${outputVar}"
            }
          }
        ]
      }
    }
      

For more information about using runtime arguments, see Pass runtime arguments in an execution request.