Overview
Variable is a structure used to extract data from API traffic messages for policy needs. It is used to extract data from different parts of HTTP requests (header, parameter, body, etc.). Variables are used in policies, conditions, and other API configurations to dynamically access request/response data.Basic Properties
Note
namemust be unique within a project
Variable Types
Variables support the following types:HEADER- Extract data from HTTP headersPARAMETER- Extract data from URL parameters (query, path, form)BODY- Extract data from request/response body (XML, JSON, or raw body)CONTEXT_VALUES- Extract data from system context valuesCUSTOM- Custom variable defined with script
Variable Types and Required Fields
HEADER Type
Extract data from HTTP headers.Example
PARAMETER Type
Extract data from URL parameters (query, path, or form).Note
- For
paramType=QUERY: UseparamNameonly - For
paramType=PATH: UseparamNameandparamPath(required) - For
paramType=FORM: UseparamName(required),formNameis optional and typically same asparamNameunless you need a different field name
EnumVariableParameterType (paramType)
QUERY- Query parameter (e.g.,?userId=123)PATH- Path parameter (e.g.,/users/{userId})FORM- Form parameter (form data)
BODY Type
Extract data from request/response body (XML, JSON, or raw body).EnumMessageContentType (messageContentType)
XML- XML content typeJSON- JSON content typeALL_BODY- Raw body content (all body)
CONTEXT_VALUES Type
Extract data from system context values.Example
CUSTOM Type
Custom variable defined with script.Note
- If
initWithScriptistrue, bothscriptLanguageandscriptBodymust be provided - If
initWithScriptisfalse(default), script fields are optional
Example
EnumVariableContextValue
Context values available forCONTEXT_VALUES type variables.
Request-Related Values
Request Status Information
Response-Related Values
Message-Related Values
Environment-Related Values
API Proxy Group/Proxy/Method Values
Date/Time-Related Values
Note: Date/time context values require
zoneId field to be specified.
Credential Values
Complete Variable Examples
Example 1: Header Variable
Example 2: Query Parameter Variable
Example 3: Path Parameter Variable
Example 4: XML Body Variable
Example 5: JSON Body Variable
Example 6: Context Variable (Client IP)
Example 7: Context Variable (Date/Time)
Example 8: Custom Variable
Usage in Policies
Variables are used in various policies:- API Based Throttling -
targetVariableForIdentityto identify clients - RLCL -
targetVariablefor rate limiting - Conditions -
firstVariableandsecondVariablefor condition rules - Content Filter - Variables to filter content
- Redaction - Variables to identify data to redact
- Encryption/Decryption - Variables for source and target data
Notes and Warnings
-
Variable Names:
- Variable names must be unique within a project
- Use descriptive names for better understanding
-
Required Fields:
- Each variable type has specific required fields
- Missing required fields will cause validation errors
-
Context Values:
- Date/time context values require
zoneIdfield - Use IANA time zone identifiers (e.g., “Europe/Istanbul”, “America/New_York”)
- Date/time context values require
-
XPath/JsonPath:
- XPath expressions are used for XML content
- JsonPath expressions are used for JSON content
- Ensure expressions are valid for the content type
-
Custom Scripts:
- Custom variables use scripts to extract data
- Script language must be specified
- Scripts have access to request/response objects
Related Documentation
- Enum Reference - Enumeration values used in variables (EnumVariableType, EnumVariableParameterType, etc.)
- Glossary - Terms and definitions
- API Based Throttling Policy - Uses variables for client identification
- RLCL API - Uses variables for rate limit control
- Script Policy - Script language types

