Kong: request-transformer edits the request before it is proxied

Add, remove, replace or rename headers, query parameters and body fields - without touching the upstream service. Useful for injecting a fixed header or hiding a rename.

Code
curl -X POST http://localhost:8001/routes/api/plugins \
  --data name=request-transformer \
  --data 'config.add.headers[]=X-Gateway:kong' \
  --data 'config.remove.headers[]=X-Internal-Debug' \
  --data 'config.rename.querystring[]=q:search' \
  --data 'config.add.querystring[]=version:2'

# response-transformer is the mirror image, for what goes back:
curl -X POST http://localhost:8001/routes/api/plugins \
  --data name=response-transformer \
  --data 'config.remove.headers[]=Server' \
  --data 'config.remove.headers[]=X-Powered-By'
Output
Client sends:   GET /api?q=shoes        X-Internal-Debug: 1
Upstream sees:  GET /api?search=shoes&version=2
                X-Gateway: kong

# add only sets a header that is absent. To overwrite one that is present,
# use replace. Getting this backwards is why an injected header sometimes
# appears to do nothing.
Advertisement

Run this yourself in the Online Java Compiler, spin up a live REST API in the API Sandbox, or practise with Java interview questions.

Published 2026-08-25