Transformation policies allow you to modify requests and responses as they pass through Agentgateway. Transformations are applied at the route level under binds[].listeners[].routes[].policies.
Agentgateway supports the following transformation types:
requestHeaderModifier — add, set, or remove request headers
responseHeaderModifier — add, set, or remove response headers
requestRedirect — respond directly with an HTTP redirect
urlRewrite — modify the URL path or authority before forwarding
requestMirror — mirror requests to a secondary backend
directResponse — respond directly with a static body without forwarding
transformations — modify request and response bodies and headers
Modify headers on the inbound request before it is forwarded to the backend.
policies :
requestHeaderModifier :
add :
x-request-source : agentgateway
set :
x-forwarded-host : gateway.example.com
remove :
- x-internal-debug
Headers to be modified on the inbound request. Show requestHeaderModifier fields
Key-value pairs of headers to add to the request. If the header already exists, a new header with the same name is appended. requestHeaderModifier :
add :
x-custom-header : my-value
Key-value pairs of headers to set on the request. If the header already exists, its value is overwritten. requestHeaderModifier :
set :
x-forwarded-for : 10.0.0.1
List of header names to remove from the request. requestHeaderModifier :
remove :
- x-debug-token
- x-internal-id
Modify headers on the response from the backend before it is returned to the client.
policies :
responseHeaderModifier :
add :
x-served-by : agentgateway
remove :
- server
- x-powered-by
Headers to be modified on the outbound response. Show responseHeaderModifier fields
Key-value pairs of headers to add to the response.
Key-value pairs of headers to set on the response, overwriting existing values.
List of header names to remove from the response. responseHeaderModifier :
remove :
- server
- x-powered-by
requestRedirect
Respond directly to the client with an HTTP redirect without forwarding the request to a backend.
policies :
requestRedirect :
scheme : https
authority :
host : api.example.com
status : 301
Directly respond to the request with a redirect. Show requestRedirect fields
The redirect scheme. Typically http or https. requestRedirect :
scheme : https
requestRedirect.authority
The redirect authority (host and/or port). One of full, host, or port. requestRedirect.authority.full
Full authority string including host and port (e.g. api.example.com:443).
requestRedirect.authority.host
Host portion only.
requestRedirect.authority.port
Port portion only.
The redirect path. One of full or prefix. requestRedirect.path.full
Replace the entire path with this value.
requestRedirect.path.prefix
Replace the matched path prefix with this value.
HTTP redirect status code. Common values: 301 (permanent), 302 (temporary), 307, 308. requestRedirect :
status : 301
urlRewrite
Modify the URL path or authority before forwarding the request to the backend. Unlike requestRedirect, the client does not see the rewrite — it receives the backend’s response as if the original URL was used.
policies :
urlRewrite :
authority :
host : internal-backend.example.com
path :
prefix : /v2
Modify the URL path or authority before forwarding. Override the request authority. One of full, host, or port. urlRewrite.authority.full
Full authority string.
urlRewrite.authority.host
Host portion only.
urlRewrite.authority.port
Port portion only.
Override the request path. One of full or prefix. Replace the matched path prefix.
requestMirror
Mirror (shadow) incoming requests to a secondary backend in addition to the primary backend. The client only receives the response from the primary backend. The mirror backend’s response is discarded.
policies :
requestMirror :
backend : shadow-backend
percentage : 10
Mirror incoming requests to another destination. Show requestMirror fields
The mirror destination. One of service, host, or backend. requestMirror.backend.service
Reference to a named service. Namespace of the service.
requestMirror.backend.host
Hostname or IP address of the mirror backend.
requestMirror.backend.backend
Name of a backend defined in the top-level backends list.
Percentage of requests to mirror (0–100). When omitted, all matching requests are mirrored. requestMirror :
percentage : 10
directResponse
Respond directly to the client with a static response body and status code, without forwarding to any backend.
policies :
directResponse :
status : 200
body : '{"status": "ok"}'
Directly respond to the request with a static response. Show directResponse fields
HTTP status code for the response. directResponse :
status : 200
Response body string. directResponse :
status : 200
body : '{"message": "Service unavailable"}'
Modify request and response bodies, headers, and metadata using structured transformation rules.
policies :
transformations :
request :
add :
x-request-id : some-value
set :
content-type : application/json
remove :
- x-debug
response :
add :
x-proxy : agentgateway
remove :
- server
Modify requests and responses sent to and from the backend. Show transformations fields
Transformations applied to the inbound request. Show request transformation fields
transformations.request.add
Headers to add to the request.
transformations.request.set
Headers to set on the request (overwriting existing values).
transformations.request.remove
Headers to remove from the request.
transformations.request.body
Modifications to apply to the request body.
transformations.request.metadata
Metadata to attach to the request.
Transformations applied to the response from the backend. Show response transformation fields
transformations.response.add
Headers to add to the response.
transformations.response.set
Headers to set on the response.
transformations.response.remove
Headers to remove from the response.
transformations.response.body
Modifications to apply to the response body.
transformations.response.metadata
Metadata to attach to the response.
Combined example
binds :
- port : 3000
listeners :
- routes :
- matches :
- path :
pathPrefix : /api/
policies :
requestHeaderModifier :
add :
x-request-source : agentgateway
remove :
- x-internal-token
responseHeaderModifier :
remove :
- server
- x-powered-by
urlRewrite :
path :
prefix : /v2
transformations :
request :
set :
content-type : application/json
response :
add :
x-proxy : agentgateway
backends :
- host : http://api-backend:8080
requestHeaderModifier and responseHeaderModifier operate on individual HTTP headers, while transformations provides a broader object with support for request/response body modifications. Both can be used together on the same route.