You can use the policy-assign-attributes policy to set variables such as request attributes, message attributes, and other execution context attributes.
NOTE: When you use this policy on message request or message response phases, attributes are stored in the message attribute list instead of the context attribute list.
This policy is useful to keep initial request data after policies such as Transform headers or Transform query parameters, and reuse these values in downstream policies like Dynamic routing.
The policy-assign-attributes policy can be applied to the following API types and flow phases.
PROXYMESSAGENATIVE KAFKAMCP PROXYLLM PROXYA2A PROXY
- Request
- Response
- Publish
- Subscribe
- Interact
Strikethrough text indicates that a version is deprecated.
| Plugin version | APIM |
|---|---|
| 3.x | 4.8.x to latest |
| 2.x | 4.0.x to 4.7.x |
Name json name |
Type constraint |
Mandatory | Description |
|---|---|---|---|
Assign context attributesattributes |
array | See "Assign context attributes" section. |
Name json name |
Type constraint |
Mandatory | Description |
|---|---|---|---|
Namename |
string | ✅ | Name of the attribute. |
Valuevalue |
string | ✅ | Value of the attribute (Support EL). |
Proxy API on Request phase
{
"api": {
"definitionVersion": "V4",
"type": "PROXY",
"name": "Assign attributes example API",
"flows": [
{
"name": "Common Flow",
"enabled": true,
"selectors": [
{
"type": "HTTP",
"path": "/",
"pathOperator": "STARTS_WITH"
}
],
"request": [
{
"name": "Assign attributes",
"enabled": true,
"policy": "policy-assign-attributes",
"configuration":
{
"scope": "REQUEST_CONTENT",
"attributes": [
{
"name": "test-request-content",
"value": "{#jsonPath(#request.content, '$.registrationForm.firstName')}"
},
{
"name": "test-request-content1",
"value": "{#jsonPath(#request.content, '$.registrationForm.birthDate')}"
},
{
"name": "test-request-content2",
"value": "{#jsonPath(#request.content, '$.registrationForm.username')}"
}
]
}
}
]
}
]
}
}
Proxy API on Response phase
{
"api": {
"definitionVersion": "V4",
"type": "PROXY",
"name": "Assign attributes example API",
"flows": [
{
"name": "Common Flow",
"enabled": true,
"selectors": [
{
"type": "HTTP",
"path": "/",
"pathOperator": "STARTS_WITH"
}
],
"response": [
{
"name": "Assign attributes",
"enabled": true,
"policy": "policy-assign-attributes",
"configuration":
{
"scope": "RESPONSE_CONTENT",
"attributes": [
{
"name": "test-response-content",
"value": "{#jsonPath(#response.content, '$.responseForm.firstName')}"
},
{
"name": "test-response-content1",
"value": "{#jsonPath(#response.content, '$.responseForm.birthDate')}"
},
{
"name": "test-response-content2",
"value": "{#jsonPath(#response.content, '$.responseForm.username')}"
}
]
}
}
]
}
]
}
}
Message API CRD on Subscribe phase
apiVersion: "gravitee.io/v1alpha1"
kind: "ApiV4Definition"
metadata:
name: "policy-assign-attributes-message-api-crd"
spec:
name: "Assign attributes example"
type: "MESSAGE"
flows:
- name: "Common Flow"
enabled: true
selectors:
matchRequired: false
mode: "DEFAULT"
subscribe:
- name: "Assign attributes"
enabled: true
policy: "policy-assign-attributes"
configuration:
attributes:
- name: test-message-response-attr1
value: '{#message.content}'
3.2.0 (2026-02-18)
- enable for A2A proxy (ec4a9ab)
3.1.0 (2025-12-11)
- enable for LLM & MCP Proxy API (cc71b88)
3.1.0-alpha.1 (2025-11-12)
- enable for LLM & MCP Proxy API (731bf8f)
3.0.2 (2025-09-01)
- use this policy on request/response phases (c4e4e35)
3.0.1 (2025-07-02)
- changed flatMapMaybe to concatMapMaybe (31e7d81)
3.0.0 (2025-06-17)
- make policy compatible with apim 4.8.0 (424cf3e)
- enable assign attribute policy for native apis (619b191)
- require APIM 4.8.0+ to work
2.0.3 (2024-09-13)
- json-schema - remove json forced language (2eac825)
2.0.2 (2024-09-11)
- json-schema - add code editor for attribute values (9fa4a86)
2.0.1 (2023-07-20)
- update policy description (723e2ca)
2.0.0 (2023-07-18)
- add missing breaking change and update compatibility matrix in README (791eac8)
- bump gravitee-parent to fix release to nexus (e4d0957)
- use new execution engine (21ea3f7)
- deps: update gravitee-parent (bd51e10)
- deps: require Java17
- This implementation is using the dependencies introduced by Gravitee V4.0
2.0.0-alpha.4 (2023-06-29)
- use new execution engine (21ea3f7)
2.0.0-alpha.3 (2023-06-27)
- clean and validate json schema for v4 (f915aca)
2.0.0-alpha.2 (2023-06-23)
- bump gravitee-parent to fix release to nexus (e4d0957)
2.0.0-alpha.1 (2023-06-21)
- add missing breaking change and update compatibility matrix in README (791eac8)
- This implementation is using the dependencies introduced by Gravitee V4.0
1.6.0-alpha.1 (2023-06-20)
- add message level support to policy (676fc6f)
1.5.1 (2023-01-23)
- properly set
responseattribute in the execution context (f8d4de4)