Skip to main content
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

requestHeaderModifier

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
requestHeaderModifier
object
Headers to be modified on the inbound request.

responseHeaderModifier

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
responseHeaderModifier
object
Headers to be modified on the outbound response.

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
requestRedirect
object
Directly respond to the request with a redirect.

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
urlRewrite
object
Modify the URL path or authority before forwarding.

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
requestMirror
object
Mirror incoming requests to another destination.

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"}'
directResponse
object
Directly respond to the request with a static response.

transformations

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
transformations
object
Modify requests and responses sent to and from the backend.

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.