Variable Types
5 different types of variables are created in Apinizer:Header
Used to get values from HTTP headers
Parameter
Used to get values from URL parameters
Body
Used to get values from message body
Context Value
Used to get values from system properties
Custom Variable
Used to transfer data between policies
The Apinizer Platform comes with ready-made variables with the initial installation. When a new project is created, all variables in the variables section under the Management menu are copied to the relevant project.Since variables created under the Management menu are used by copying them to projects, update or delete operations on these variables do not affect the definitions in the projects where they are used.All variables can be moved to the Admin page with the “Globalize” option to make them available for use in all projects and management is left to the Admin user.
Creating Header Type Variable
To create this type of variable, Header is selected as the type and the relevant input fields are filled. Variable name and header name can be defined differently. The name is a unique definition system-wide. Header name is the value expected from the client.| Field | Description |
|---|---|
| Name | Field where the name of the variable definition is entered. |
| Description | Description can be written to facilitate management related to the created variable. |
| Type | Field where which part of the message the variable is expected is entered. |
| Header Name | Field where the header name expected in the request from the client is entered. If this field contains multiple values, the first value is used. |
Header variables are used to extract data from HTTP headers. For example, values can be retrieved from headers such as
X-API-Key, Authorization, Content-Type.Creating Parameter Type Variable
To create this type of variable, Parameter is selected as the type and the relevant input fields are filled. Variable name and parameter name can be defined differently. The name is a unique definition system-wide. Parameter name is the value expected from the client.| Field | Description |
|---|---|
| Name | Field where the name of the variable definition is entered. |
| Description | Description can be written to facilitate management related to the created variable. |
| Type | Field where which part of the message the variable is expected is entered. |
| Parameter Type | Field where the request type of the parameter from the client is selected. Default value is QUERY. Values that can be read as form parameter values are x-www-form values and attached text data part values. In x-www-form values, addition, deletion, and editing can be done; the text data part is read-only, addition/editing cannot be done. Reading can be done from anywhere. Adding/deleting/editing values is only valid for the request (request) line. |
| Parameter Name | Field where the parameter name expected in the request from the client is entered. If the Parameter Type value is Query and it is a multiple value, the first value is used. |
Parameter variables are used to extract data from URL query parameters, path parameters, or form parameters. For example, values can be retrieved from query parameters like
?page=1&limit=10 or path parameters like /users/{id}.Creating Body Type Variable
To create this type of variable, Body is selected as the type and the relevant input fields are filled.| Field | Description |
|---|---|
| Name | Field where the name of the variable definition is entered. |
| Description | Description can be written to facilitate management related to the created variable. |
| Type | Field where which part of the message the variable is expected is entered. |
| Message Type | Field where the type of message content is selected. Default value is JSON. |
| JSON/XML Path | Field where JSON/XPath information necessary to get the value from the request from the client is entered. |
Body variables are used to extract data from message body. JSONPath is used for JSON format, XPath is used for XML format. For example, a username can be extracted from JSON content with a JSONPath expression like
$.user.name.Creating Context Values Type Variable
To create this type of variable, Context Values is selected as the type and the relevant input fields are filled.| Field | Description |
|---|---|
| Name | Field where the name of the variable definition is entered. |
| Description | Description can be written to facilitate management related to the created variable. |
| Type | Field where which part of the message the variable is expected is entered. |
| Value | Field where the predefined value expected in the request from the client is selected. Only Http Info and Backend Endpoint from these values can be edited; other values are read-only. |
| Zone ID | This field becomes active if any value from the Date/Time group is selected as the value. Example value: “+03:00” or “Europe/Istanbul”. For more information, you can refer to the Java ZoneId documentation. |
Request Information
Request Information
Request information selectable in the form:
- Client IP address
- HTTP method
- Content type
- Path information
- Query string
- Request URI
- Remote user information
- Server information (name, port, etc.)
Date/Time Values
Date/Time Values
Date/time values require time zone (zoneId):
- Epoch milliseconds
- Formatted date-time
- Formatted date
- Formatted time
- Year, month, day, hour, minute, second information
Environment and API Proxy Information
Environment and API Proxy Information
- Environment ID and name
- API Proxy Group ID and name
- API Proxy ID and name
- API Method information
Message Information
Message Information
- Message correlation ID
- Content length
- Response status code
- Compression information
Context values are used to extract data from system properties and request context. These values are selected from a dropdown menu in form-based configuration and displayed with user-friendly labels.
Creating Custom Variable Type Variable
To create this type of variable, Custom Variable is selected as the type and only the name field is filled. Afterwards, it becomes possible to assign values, read values, and change values from Script and Business Rule policies with the entered name of this variable. It is mostly used for transferring data from one policy to another.| Field | Description |
|---|---|
| Name | Field where the name of the variable definition is entered. |
| Description | Description can be written to facilitate management related to the created variable. |
| Type | Field where which part of the message the variable is expected is entered. |
| Initialized with Script | Field used to determine the initial value of the Custom Variable. This field only works if the variable has never been created or is null. To give an initial value, the variable name added to the customVariableMap object with the name used here must be exactly the same. For example, if the variable name is “test”, the expression should be written as customVariableMap.put("test",value) in the last line of the script. |
| Script Language | Field where Script Language is selected. |
| Script Body | Field where script content is entered. |
Custom Variable is especially used for transferring data between pipelines. Data can be added, read, and changed to Custom Variable during flow with Script and Business Rule policies. This enables data transfer from one policy to another.The first value is always taken on the variables screen, even if the header (header) and parameter (parameter) values come as multiple (multiple). Only in script policy, if there is a multiple (multiple) value, it can be used separated by #.When showing in log records, it is shown as key: val1#val2#val3.
Variable Management
Project-Based Usage
Variables are defined at the project level and can be used in all API Proxies in the relevant project.
Management Menu
Variables created under the Management menu are automatically copied to the project when a new project is created.
Globalization
All variables can be moved to the Admin page with the “Globalize” option to make them available for use in all projects.
Independent Management
Updating or deleting variables in the Management menu does not affect the definitions in the projects where they are copied.
Variable Usage Scenarios
Variables are used in the following situations:Policy Configuration
Used for dynamic values in policy settings. Client definition for policies such as Rate Limiting, Throttling, API Key.
Conditional Policy Execution
Used to make policy execution decisions based on variable values.
Routing and Routing
Used to route to different backends based on variable values.
Message Processing
Used for dynamic values in message transformation operations.
Script Policy
Variable usage in Groovy/JavaScript scripts and adding, reading, and changing data to Custom Variables.
Data Transfer Between Pipelines
Data transfer between pipelines with Custom Variable. Data transfer from Request Pipeline to Response Pipeline, from one policy to another.

