Skip to main content
Skip table of contents

Context Variables

Context Variables provide storage of temporary data inside a flow so as to be able to use it in the subsequent parts of the flow.

For example, a third party service can be called using the Service Call Out policy and the response is parsed using the Assign Variables policy to define the context variables which can then be used inside a Build Message policy to populate the request payload sent to the target service or as a response to the client. 

Context variables are also populated by policies like Lookup Cache or within custom policies such as Java Call Out.

The context variables that are handled by the API gateway server are described below.

Context VariableVariable ReferenceDescription

API Product/Developer variables
API PRODUCT NAMEapi.product.nameThe name of the product subscribed to by the client making a request. This variable will be populated only if the project is secured using the API keys or OAuth 2.0 access tokens.
API CONSUMER KEYapi.consumer.keyThe Key corresponding to the client making a request. This variable will be populated only if the project is secured using the API keys or OAuth 2.0 access tokens.
API PRODUCT QUOTA ALLOWEDapi.product.quota.allowedThe quota for the product subscribed to by the client making a request. This variable will be populated only if the project is secured using the API keys or OAuth 2.0 access tokens. It is used in Quota policy when Enforce Quota is applied while creating a project.
API QUOTA WEIGHTapi.quota.weightThe weight of the request can be assigned using this Context Variable and then it can be used in Quota policy when Enforce Quota is applied while creating a project.
API DEVELOPER IDapi.developer.idThe ID of the consumer making a request. This variable will be populated only if the project is secured using the API keys  or OAuth 2.0  access tokens.
Proxy Path variables
PROXY RESOURCE PATHproxy.resource.pathThe path of the resource invoked. For example, if a resource base path is items/{itemId} and a request has path items/myItem/price, then this variable will have the value items/myItem/price.
PROXY RESOURCE BASE PATHproxy.resource.base.pathThe base path of the resource. For example, if a resource base path is items/{itemId} and a request has path items/myItem/price, then this variable will have the value items/myItem.
PROXY RESOURCE FORWARD PATHproxy.resource.forward.pathThe path in a request after the resource base path. This path will be forwarded in the target request as well. For example, if a resource base path is items/{itemId} and a request has path items/myItem/response.json, then this variable will have the value /response.json which will be appended to the path specified in the target for this resource.
Proxy Request variables
PROXY REQUEST SIZEproxy.request.sizeThe size of the request received from the client.
PROXY REQUEST HEADER PROPERTY PREFIXproxy.request.header.The request header sent by the client can be retrieved inside a flow to define conditions or to evaluate them using this variable.
PROXY REQUEST QUERY PROPERTY PREFIXproxy.request.query.The request parameter sent by the client can be retrieved inside a flow to define conditions or to evaluate them using this variable.
PROXY REQUEST FORM PROPERTY PREFIXproxy.request.form.The form parameter sent by the client can be retrieved inside a flow to define conditions or to evaluate them using this variable.
PROXY REQUEST PATH PROPERTY PREFIXproxy.request.template.The template parameter sent by the client can be retrieved inside a flow to define conditions or to evaluate them using this variable. For example, for a resource with resource path as items/{itemId}, the itemId sent in the request can be retrieved using the variable proxy.request.template.itemId
PROXY REQUEST HTTP SCHEMEproxy.request.http.schemeThe scheme used by the client such as HTTP and HTTPS.
PROXY REQUEST PATH INFOproxy.project.path.infoThe path through which the request has been received by the proxy. This includes the base path of the project.
PROXY REQUEST HTTP VERSIONproxy.request.http.versionThe HTTP version of the request received from the client. Example: 1.0, 1.1.
PROXY REQUEST METHODproxy.request.methodThe method that is invoked on a resource by a client such as GET, POST, PUT, and DELETE.
PROXY REQUEST IN TIMEproxy.request.in.timeThe time when the request is received. This is the number of milliseconds, between the current time and midnight, January 1, 1970 UTC.
Target Request variables
TARGET REQUEST IN TIMEtarget.request.in.timeThe time at which the request is sent to the target server.
TARGET REQUEST HEADER PROPERTY PREFIXtarget.request.header.Headers sent as part of the request to the target server can be populated using this prefix. The variables can be defined using the Assign Variable policy. For example, to define a header for the client such as Accept, a variable target.request.header.Accept can be defined.
TARGET REQUEST QUERY PROPERTY PREFIXtarget.request.query.Query Parameters sent as part of a request to the target server can be populated using this prefix. The variables can be defined using the Assign Variable policy. For example, to define a Query Parameter to the client such as address, a variable target.request.query.address can be defined.
TARGET REQUEST FORM PROPERTY PREFIXtarget.request.form.Form Parameters sent as part of the request to the target server can be populated using this prefix. The variables can be defined using the Assign Variable policy. For example, to define a Form Parameter to be sent to the target server from the client such as address, a variable target.request.form.address can be defined.
TARGET REQUEST PATHtarget.request.pathThe path at which the request has to be sent to the target server can be modified based on the condition of the flow using this Context Variable.
TARGET REQUEST METHODtarget.request.methodThe path which needs to be invoked on the target server can be modified based on the condition of the flow using this Context Variable.
TARGET REQUEST PROTOCOL VERSIONtarget.request.versionThe HTTP version with which the request sent to the target server can be modified based on the condition of the flow using this Context Variable.
TARGET REQUEST PROTOCOLtarget.request.protocolThe HTTP protocol with which the request sent to the target server can be modified based on the condition of the flow using this Context Variable.
Target Response variables
TARGET RESPONSE HEADER PROPERTY PREFIXtarget.response.header.The response header sent by the target server can be retrieved inside a flow to define conditions or to evaluate them using this variable.
TARGET RESPONSE FORM PROPERTY PREFIXtarget.response.form.The form parameter sent by the target server in its response can be retrieved inside a flow to define conditions or to evaluate them using this variable.
TARGET RESPONSE REASON PHRASEtarget.response.reason.phraseThe reason phrase received from the target server when errors are detected.
TARGET RESPONSE STATUS CODEtarget.response.status.codeThe status code received from the target server.
TARGET RESPONSE OUT TIMEtarget.response.out.timeThe time at which the response is received from the target server.
Proxy Response variables
PROXY RESPONSE FORM PROPERTY PREFIXproxy.response.form.Form Parameters sent as a response to the client can be populated using this prefix. The variables can be defined using the Assign Variable policy.
PROXY RESPONSE HEADER PROPERTY PREFIXproxy.response.header.Headers sent as a response to the client can be populated using this prefix. The variables can be defined using the Assign Variables policy. For example, to define a response header to the client such as Content-Type, a variable proxy.response.header.Content-Type can be defined.
PROXY RESPONSE OUT TIMEproxy.response.out.timeThe time when the response is sent back to the client in milliseconds.
PROXY RESPONSE SIZEproxy.response.sizeThe size of the response sent back to the client.
API Project variables
API PROJECT IDapi.project.nameThe name of the project. This variable is used for analytics.
API PROJECT VERSIONapi.project.versionThe version of the project.
API PROJECT CONTEXT PATHapi.project.context.pathThe base path of the API project. This variable is used for analytics.
Client Variables
CLIENT IPclient.ipThe IP Address of the client making the request.
CLIENT HOST NAMEclient.hostnameThe host name of the client making the request.
CLIENT REQUEST PORTclient.portThe port where the client is sending the request.
Streaming variables
REQUEST STREAMING ENABLEDrequest.streaming.enabledThe variable provides information if streaming is enabled while sending a request to the target server.
RESPONSE STREAMING ENABLEDresponse.streaming.enabledThe variable provides information if streaming is enabled while sending a response from the target server to the client.
Cache variables
RESPONSE CACHE NAMEresponse.cache.nameThe cache into which the response is cached when Response Cache policy is being used.
CACHE HITcache.hitThe variable which determines if the cache has been hit.
Target Fail over variables
TARGET FAILOVER OCCURREDtarget.failover.occurredThe variable which identifies if a target fail over has occurred.
TARGET FAILOVER FROMtarget.failover.fromThe ID of the target configuration from which the fail over occurred.
TARGET FAILOVER TOtarget.failover.toThe ID of the target configuration to which the fail over has occurred.
Environment variables
ENVIRONMENT NAMEenvironment.nameThe name of the environment through which this request is passing.
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.