FUNCTION_NAME: the name of the function you are
calling
ARG_1,ARG_2 (optional): if the
function accepts parameters, the arguments you are passing and their values
(VALUE_1, VALUE_2)
OUTPUT_VARIABLE (optional): if the function returns
anything, the variable
to store the returned data in
Calls are often HTTP requests but can be made to any function including a
connector, a standard library function, or a subworkflow (user-defined function):
Connectors can be used to
connect to other Google Cloud APIs within a workflow, and to integrate
your workflows with those products, allowing you to perform operations from
other Google Cloud services.
Standard library functions
include modules and frequently used functions, such as for data type and format
conversions, as well as functions that make HTTP calls like
http.get
and http.post. To access HTTP
response data saved in a variable, see
Make an HTTP request.
Subworkflows let you
define a piece of logic that can be called from the main workflow, similar to a
routine or function in a programming language.
Samples
The following samples demonstrate the syntax. For more samples, see
Make an HTTP request.
Assign the response from an API call
This sample makes a call to a
sample API.
The returned day of the week is passed to the
Wikipedia API.
Relevant articles on Wikipedia about the current day of the week are returned.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[],[],null,["# Calls\n\nA common type of workflow step uses the `call` field to run a function and\nreturn a result: \n\n### YAML\n\n```yaml\n - STEP_NAME:\n call: FUNCTION_NAME\n args:\n ARG_1: VALUE_1\n ARG_2: VALUE_2\n ...\n result: OUTPUT_VARIABLE\n```\n\n### JSON\n\n```json\n [\n {\n \"\u003cvar translate=\"no\"\u003eSTEP_NAME\u003c/var\u003e\": {\n \"call\": \"\u003cvar translate=\"no\"\u003eFUNCTION_NAME\u003c/var\u003e\",\n \"args\": {\n \"\u003cvar translate=\"no\"\u003eARG_1\u003c/var\u003e\": \"\u003cvar translate=\"no\"\u003eVALUE_1\u003c/var\u003e\",\n \"\u003cvar translate=\"no\"\u003eARG_2\u003c/var\u003e\": \"\u003cvar translate=\"no\"\u003eVALUE_2\u003c/var\u003e\"\n },\n \"result\": \"\u003cvar translate=\"no\"\u003eOUTPUT_VARIABLE\u003c/var\u003e\"\n }\n }\n ]\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eFUNCTION_NAME\u003c/var\u003e: the name of the function you are calling\n- \u003cvar translate=\"no\"\u003eARG_1\u003c/var\u003e,\u003cvar translate=\"no\"\u003eARG_2\u003c/var\u003e (optional): if the function accepts parameters, the arguments you are passing and their values (\u003cvar translate=\"no\"\u003eVALUE_1\u003c/var\u003e, \u003cvar translate=\"no\"\u003eVALUE_2\u003c/var\u003e)\n- \u003cvar translate=\"no\"\u003eOUTPUT_VARIABLE\u003c/var\u003e (optional): if the function returns anything, the [variable](/workflows/docs/reference/syntax/variables#store-result) to store the returned data in\n\nCalls are often HTTP requests but can be made to any function including a\nconnector, a standard library function, or a subworkflow (user-defined function):\n\n- [Connectors](/workflows/docs/reference/googleapis) can be used to connect to other Google Cloud APIs within a workflow, and to integrate your workflows with those products, allowing you to perform operations from other Google Cloud services.\n- [Standard library functions](/workflows/docs/reference/stdlib/overview) include modules and frequently used functions, such as for data type and format conversions, as well as functions that make HTTP calls like [http.get](/workflows/docs/reference/stdlib/http/get) and [http.post](/workflows/docs/reference/stdlib/http/post). To access HTTP response data saved in a variable, see [Make an HTTP request](/workflows/docs/http-requests).\n- [Subworkflows](/workflows/docs/reference/syntax/subworkflows) let you define a piece of logic that can be called from the main workflow, similar to a routine or function in a programming language.\n\nSamples\n-------\n\nThe following samples demonstrate the syntax. For more samples, see\n[Make an HTTP request](/workflows/docs/http-requests).\n\n### Assign the response from an API call\n\nThis sample makes a call to a\n[sample API](https://github.com/GoogleCloudPlatform/workflows-samples/tree/main/functions/datetime).\nThe returned day of the week is passed to the\n[Wikipedia API](https://wikipedia.org/w/api.php).\nRelevant articles on Wikipedia about the current day of the week are returned.\n\n### YAML\n\n main:\n params: [input]\n steps:\n - checkSearchTermInInput:\n switch:\n - condition: '${\"searchTerm\" in input}'\n assign:\n - searchTerm: '${input.searchTerm}'\n next: readWikipedia\n - getLocation:\n call: sys.get_env\n args:\n name: GOOGLE_CLOUD_LOCATION\n result: location\n - setFromCallResult:\n assign:\n - searchTerm: '${text.split(location, \"-\")[0]}'\n - readWikipedia:\n call: http.get\n args:\n url: 'https://en.wikipedia.org/w/api.php'\n query:\n action: opensearch\n search: '${searchTerm}'\n result: wikiResult\n - returnOutput:\n return: '${wikiResult.body[1]}'\n\n### JSON\n\n {\n \"main\": {\n \"params\": [\n \"input\"\n ],\n \"steps\": [\n {\n \"checkSearchTermInInput\": {\n \"switch\": [\n {\n \"condition\": \"${\\\"searchTerm\\\" in input}\",\n \"assign\": [\n {\n \"searchTerm\": \"${input.searchTerm}\"\n }\n ],\n \"next\": \"readWikipedia\"\n }\n ]\n }\n },\n {\n \"getLocation\": {\n \"call\": \"sys.get_env\",\n \"args\": {\n \"name\": \"GOOGLE_CLOUD_LOCATION\"\n },\n \"result\": \"location\"\n }\n },\n {\n \"setFromCallResult\": {\n \"assign\": [\n {\n \"searchTerm\": \"${text.split(location, \\\"-\\\")[0]}\"\n }\n ]\n }\n },\n {\n \"readWikipedia\": {\n \"call\": \"http.get\",\n \"args\": {\n \"url\": \"https://en.wikipedia.org/w/api.php\",\n \"query\": {\n \"action\": \"opensearch\",\n \"search\": \"${searchTerm}\"\n }\n },\n \"result\": \"wikiResult\"\n }\n },\n {\n \"returnOutput\": {\n \"return\": \"${wikiResult.body[1]}\"\n }\n }\n ]\n }\n }\n\n### Make an external HTTP POST request\n\nThis sample makes a POST request to an external HTTP endpoint.\n\n### YAML\n\n - send_message:\n call: http.post\n args:\n url: https://www.example.com/endpoint\n body:\n some_val: \"Hello World\"\n another_val: 123\n result: the_message\n - return_value:\n return: ${the_message.body}\n\n### JSON\n\n [\n {\n \"send_message\": {\n \"call\": \"http.post\",\n \"args\": {\n \"url\": \"https://www.example.com/endpoint\",\n \"body\": {\n \"some_val\": \"Hello World\",\n \"another_val\": 123\n }\n },\n \"result\": \"the_message\"\n }\n },\n {\n \"return_value\": {\n \"return\": \"${the_message.body}\"\n }\n }\n ]"]]