FlowCallout policy

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 theFlowCallout policies, you can invoke that shared flow from multiple API proxies.
  • You can call one shared flow from another by implementing aFlowCallout policy 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.

  1. TheString-HandlerFlowCallout policy 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). 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="operations">concatenate tolowercase</Parameter>    <Parameter name="outputVariable">string.handler.output</Parameter>  </Parameters>  <SharedFlowBundle>StringHandler</SharedFlowBundle></FlowCallout>
  2. The followingdefault shared flow includes aSharedStringFunctions JavaScript policy that executes when the shared flow is called from aFlowCallout policy.

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?><SharedFlow name="default">  <Step>    <Name>SharedStringFunctions</Name>  </Step></SharedFlow>
  3. In the shared flow, the followingSharedStringFunctions JavaScript policy specifies theSharedStringFunctions.js JavaScript 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>
  4. The following JavaScript,SharedStringFunctions.js, executes from theSharedStringFunctions JavaScript policy. This script retrieves values from variables created fromFlowCallout policyParameter elements.

    //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);
  5. Execution flows back from the JavaScript policy, to the shared flow, then to theFlowCallout policy 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:

AttributeDescriptionDefaultPresence
name

The internal name of the policy. The value of thename attribute can contain letters, numbers, spaces, hyphens, underscores, and periods. This value cannot exceed 255 characters.

Optionally, use the<DisplayName> element to label the policy in the management UI proxy editor with a different, natural-language name.

N/ARequired
continueOnError

Set tofalse to return an error when a policy fails. This is expected behavior for most policies.

Set totrue to have flow execution continue even after a policy fails. See also:

falseOptional
enabled

Set totrue to enforce the policy.

Set tofalse toturn off the policy. The policy will not be enforced even if it remains attached to a flow.

trueOptional
async

This attribute is deprecated.

falseDeprecated

<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'sname attribute is used.

PresenceOptional
TypeString

<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>
DefaultN/A
PresenceRequired
TypeN/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>
DefaultN/A
PresenceRequired
TypeN/A

Attributes

AttributeDescriptionDefaultPresenceType
nameThe name of the runtime variable to create with this parameter.NoneRequiredString
ref

The variable that contains the value to use at runtime. Omit this attribute if you're specifying a literal value to use.

NoneOptionalString
valueThe 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.NoneOptionalString

<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>
DefaultN/A
PresenceOptional
TypeN/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.

VariableDescription

apigee.edge.sharedflow.name

Scope: During the shared flow execution
Type: String
Permission: Read

The value of the shared flow's name attribute.

apigee.edge.flowhook.name

Scope: During execution of the shared flow attached to the flow hook.
Type: String
Permission: Read

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? Click in the Fix column for detailed troubleshooting information.

UseAPI Monitoring to investigate fault codes and diagnose issues faster.

Fault codeHTTP statusCauseFix
flow.SharedFlowNotFound500Either the shared flow does not exist, or the shared flow exists but is not deployed.

Deployment errors

N/A

Related topics

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.