FlowCallout policy Stay organized with collections Save and categorize content based on your preferences.
This pageapplies toApigee andApigee hybrid.
View Apigee Edge documentation.![]()
Use the FlowCallout policy to call out to a shared flow from either an API proxy or another shared flow.
In a shared flow, you create a sequence of steps that you can reuse at run time from multiple places. These steps are implemented as policies, as within an API proxy. TheFlowCallout policy gives you a way to invoke the shared flow from API proxies and other shared flows. It works like a function call in a traditional programming language.
- For example, imagine that you've built a shared flow with security features such as API key verification, OAuth token validation, and regular expression protection. This shared flow represents your convention for a way to check inbound requests. Using the
FlowCalloutpolicies, you can invoke that shared flow from multiple API proxies. - You can call one shared flow from another by implementing a
FlowCalloutpolicy from within a shared flow.
This policy is anExtensible policy and use of this policy might have cost or utilization implications, depending on your Apigee license. For information on policy types and usage implications, seePolicy types.
Note: For more on shared flows, seeReusable shared flows. You can also call a shared flow from outside API proxy code to enforce request pre-processing or response post-processing for all API Proxies deployed in an environment. For more, seeAttaching a shared flow using a flow hook.Samples
Verify API key in shared flow
In this example a shared flow is used to perform common security-related tasks. Here the shared flow validates an API key. API proxies and other shared flows can use theFlowCallout policy to make calls into this shared flow.
The following shared flow definition includes aVerify-API-Key policy that executes when the shared flow is called from aFlowCallout policy in an API proxy.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><SharedFlow name="default"> <Step> <Name>Verify-API-Key</Name> </Step></SharedFlow>
TheVerifyAPIKey policy within the preceding shared flow retrieves the key value and verifies it.
<VerifyAPIKey async="false" continueOnError="false" enabled="true" name="Verify-API-Key"> <DisplayName>Verify API Key</DisplayName> <APIKey ref="request.queryparam.apikey"/></VerifyAPIKey>
The followingFlowCallout policy, used in an API proxy, calls the preceding shared flow to verify the API key. Theverify-apikey-shared shared flow bundle (not shown here) configures the shared flow in the way an APIProxy bundle configures a proxy.
<FlowCallout async="false" continueOnError="false" enabled="true" name="Auth-Flow-Callout"> <DisplayName>Auth Flow Callout</DisplayName> <SharedFlowBundle>verify-apikey-shared</SharedFlowBundle></FlowCallout>
Pass parameters to a shared flow
This example illustrates how to pass parameters from aFlowCallout policy to a shared flow. Here, aFlowCallout policy calls to a shared flow designed to perform common string handling functions. The shared flow includes JavaScript that concatenates its input, lower-cases its input, or both. TheFlowCallout policy defines parameters that specify the string input, output, and what to do with the input.
The
String-HandlerFlowCalloutpolicy calls the shared flow, passing parameters specifying the variable to store the shared flow's output, what shared flow operation to use, and what input to use (here, a string literal, but it could also be a flow variable). TheParameterelements specify the names and values of variables to create runtime. The shared flow can retrieve these variables for use in its own code.<?xml version="1.0" encoding="UTF-8" standalone="yes"?><FlowCallout async="false" continueOnError="false" enabled="true" name="String-Handler"> <DisplayName>String Handler</DisplayName> <Parameters> <Parameter name="input">Gladys Kravitz</Parameter> <Parameter name="operations">concatenate tolowercase</Parameter> <Parameter name="outputVariable">string.handler.output</Parameter> </Parameters> <SharedFlowBundle>StringHandler</SharedFlowBundle></FlowCallout>
The following
defaultshared flow includes aSharedStringFunctionsJavaScript policy that executes when the shared flow is called from aFlowCalloutpolicy.<?xml version="1.0" encoding="UTF-8" standalone="yes"?><SharedFlow name="default"> <Step> <Name>SharedStringFunctions</Name> </Step></SharedFlow>
In the shared flow, the following
SharedStringFunctionsJavaScript policy specifies theSharedStringFunctions.jsJavaScript file with the code to execute.<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Javascript async="false" continueOnError="false" enabled="true" timeLimit="200" name="SharedStringFunctions"> <DisplayName>SharedStringFunctions</DisplayName> <Properties/> <ResourceURL>jsc://SharedStringFunctions.js</ResourceURL></Javascript>
The following JavaScript,
SharedStringFunctions.js, executes from theSharedStringFunctionsJavaScript policy. This script retrieves values from variables created fromFlowCalloutpolicyParameterelements.//InputvaluefromthecallingAPIproxy.varhandledString=context.getVariable("input");//Variabletouseforoutputfromthisscript.varoutputVariable=context.getVariable("outputVariable");//Aspace-separatedlistofthingstodototheinputstring.//Converttolowercasetohandleunintentionalcapitalsinconfiguration.varoperation=context.getVariable("operations").toLowerCase();//If"lowercase"wasgivenasanoperation,converttheinputtolowercase.if(operation.includes("tolowercase")){handledString=handledString.toLowerCase();}//If"concatenate"wasgivenasanoperation,concatenatetheinput.if(operation.includes("concatenate")){handledString=handledString.replace(/\s+/g,'');}//Assigntheresultingstringtotheoutputvariablespecifiedby//thecallingAPIproxy.context.setVariable(outputVariable,handledString);
- Execution flows back from the JavaScript policy, to the shared flow, then to the
FlowCalloutpolicy in the originating API proxy.
Element reference
Following are elements and attributes you can configure on this policy:
<FlowCallout async="false" continueOnError="false" enabled="true" name="Flow-Callout-1"> <DisplayName>Custom label used in UI</DisplayName> <SharedFlowBundle>thereferencedsharedflowbundle</SharedFlowBundle></FlowCallout>
<FlowCallout> attributes
<FlowCallout async="false" continueOnError="false" enabled="true" name="Flow-Callout-1">
The following table describes attributes that are common to all policy parent elements:
| Attribute | Description | Default | Presence |
|---|---|---|---|
name | The internal name of the policy. The value of the Optionally, use the | N/A | Required |
continueOnError | Set to Set to | false | Optional |
enabled | Set to Set to | true | Optional |
async | This attribute is deprecated. | false | Deprecated |
<DisplayName> element
Use in addition to thename attribute to label the policy in the management UI proxy editor with a different, natural-language name.
<DisplayName>Policy Display Name</DisplayName>
| Default | N/A If you omit this element, the value of the policy's |
|---|---|
| Presence | Optional |
| Type | String |
<SharedFlowBundle> element
Specifies the name of the shared flow to call. This element's value should be the same as the value of the target<SharedFlowBundle> element's name attribute.
<SharedFlowBundle/>
In the simplest example, you give the name of the shared flow being called as a value for this element. That is, this element's value must be the same as the shared flow'sname attribute value.
<SharedFlowBundle>Shared-Flow-Name</SharedFlowBundle>
| Default | N/A |
|---|---|
| Presence | Required |
| Type | N/A |
Attributes
None.
<Parameter> element
Specifies a parameter and value (or value source) to pass as a variable into the shared flow called by this policy.
By using a parameter, you can specify a value (or a variable containing a value) that should be passed to the shared flow called by the policy. This is conceptually similar to specifying a parameter in a function call. As with a function parameter, aFlowCallout parameter's value can vary based on the context of the shared flow call.
FlowCallout parameters are visible only during the shared flow's execution.
Syntax
You can use this element with any one of the following syntax forms. Note that where you use a literal value, the format of the value you specify will depend on the code that consumes it.
<!--Aliteralvalueinanattribute.--><Parametername="parameter-name"value='parameter-value'/><!--Areferencetoavariableinanattribute.--><Parametername="parameter-name"ref='source-variable-name'/><!--Aliteralvalueintheelementcontent.--><Parametername="parameter-name">parameter-value</Parameter><!--Areferencetoanattributeintheelementcontent.--><Parametername="parameter-name">{source-variable-name}</Parameter>
Example
ThisString-HandlerFlowCallout policy passing parameters that specify where to store the shared flow's output and what input to use. TheParameter elements specify the names and values of variables to create runtime. The shared flow can retrieve these variables for use in its own code.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><FlowCallout async="false" continueOnError="false" enabled="true" name="String-Handler"> <DisplayName>String Handler</DisplayName> <Parameters> <Parameter name="input">Gladys Kravitz</Parameter> <Parameter name="outputVariable">string.handler.output</Parameter> </Parameters> <SharedFlowBundle>StringHandler</SharedFlowBundle></FlowCallout>
| Default | N/A |
|---|---|
| Presence | Required |
| Type | N/A |
Attributes
| Attribute | Description | Default | Presence | Type |
|---|---|---|---|---|
name | The name of the runtime variable to create with this parameter. | None | Required | String |
ref | The variable that contains the value to use at runtime. Omit this attribute if you're specifying a literal value to use. | None | Optional | String |
value | The value to use in the runtime variable created with this parameter. Omit this attribute if you're specifying the name of a variable that should be the value source. | None | Optional | String |
<Parameters> element
Specifies the set of<Parameter> elements to pass as variables into the shared flow called by this policy.
Syntax
<Parameters> <Parameter name="parameter-name" value='parameter-value' /></Parameters>
| Default | N/A |
|---|---|
| Presence | Optional |
| Type | N/A |
Attributes
None.
Schemas
Sample: See ourGitHub repository samples for the most recent schemas.Flow variables
Flow variables enable dynamic behavior of policies and flows at runtime, based on HTTP headers, message content, or flow context. For more information about Flow variables, seeVariables reference.
| Variable | Description |
|---|---|
| Scope: During the shared flow execution The value of the shared flow's name attribute. |
| Scope: During execution of the shared flow attached to the flow hook. The name of the flow hook. |
Error reference
This section describes the fault codes and error messages that are returned and fault variables that are set by Apigee when this policy triggers an error. This information is important to know if you are developing fault rules to handle faults. To learn more, see What you need to know about policy errors andHandling faults.
Runtime errors
These errors can occur when the policy executes.
Tip: Need help resolving an error? Clickbuild in the Fix column for detailed troubleshooting information.UseAPI Monitoring to investigate fault codes and diagnose issues faster.
| Fault code | HTTP status | Cause | Fix |
|---|---|---|---|
flow.SharedFlowNotFound | 500 | Either the shared flow does not exist, or the shared flow exists but is not deployed. | build |
Deployment errors
N/A
Related topics
- Creating shared flows: Reusable shared flows
- Executing shared flows across multiple proxies: Attaching a shared flow using a flow hook
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-02-19 UTC.