Request context
This page documents the CEL context objects available for HTTP request and response processing in Agentgateway. These objects are available across authorization rules, transformations, logging, and tracing expressions.request
The request object contains attributes about the incoming HTTP request.
The HTTP method of the request.
The complete URI of the request, including scheme, host, path, and query string. Supports
.query(), .addQuery(), and .setQuery() methods.The hostname of the request.
The scheme of the request (
http or https).The path component of the request URI, without query string.
The path and query string of the request URI. Supports
.query(), .addQuery(), and .setQuery() methods.The HTTP version of the request.
The headers of the request. Returns a string for single-value headers and a list for multi-value headers. Supports
.redacted(), .join(), .raw(), .split(), and .cookie(name) methods.The body of the request as a string.
The timestamp when the request started, as an RFC3339 string. Use
timestamp() to parse for time arithmetic.The timestamp when the request completed. Only available after the response has been received.
response
The response object contains attributes about the HTTP response. It is only available in response-phase expressions (for example, logging and response transformations) — not during request-phase authorization.
The HTTP status code of the response.
The headers of the response. Supports the same chainable methods as
request.headers.The body of the response as a string.
source
The source object contains attributes about the downstream connection — the client that sent the request.
The IP address of the downstream connection.
The port of the downstream connection.
The Istio SPIFFE identity of the downstream connection. Only present when mTLS is enabled and the downstream presents a valid certificate.
The Subject Alternative Names from the downstream client certificate, if available.
The issuer from the downstream client certificate, if available.
The subject from the downstream client certificate, if available.
The Common Name (CN) from the subject of the downstream client certificate, if available.
env
The env object exposes a curated subset of Kubernetes environment attributes. It does not expose raw environment variables.
The name of the pod, when running on Kubernetes.
The Kubernetes namespace of the pod.
The name of the Gateway resource the proxy is running as, when running on Kubernetes.
jwt
The jwt object contains the claims from a verified JWT token. All standard and custom claims from the token payload are accessible as fields.
jwt is only available when the JWT authentication policy is enabled for the route. The token is verified against the configured issuer and JWKS before the claims are made available.apiKey
The apiKey object contains information about a verified API key. Only present when the API key authentication policy is enabled.
The verified API key value.
basicAuth
The basicAuth object contains credentials from a verified HTTP Basic authentication header. Only present when the basic authentication policy is enabled.
The username from the Basic authentication credentials.
backend
The backend object contains information about the backend selected to handle the request.
The name of the backend being used.
The type of the backend. One of:
ai, mcp, static, dynamic, service, unknown.The protocol of the backend. One of:
http, tcp, a2a, mcp, llm.extauthz, extproc, and metadata
Dynamic metadata set by external authorization (
ext_authz) filters. Fields depend on what the external authorization service returns.Dynamic metadata set by external processing (
ext_proc) filters. Fields depend on what the external processor returns.Values set by transformation metadata expressions in the Agentgateway configuration. Use this to pass computed values between transformation stages.
Practical examples
Authorization: restrict by IP and JWT role
Authorization: restrict by IP and JWT role
Logging: capture user identity
Logging: capture user identity
Transformation: rewrite a header using a JWT claim
Transformation: rewrite a header using a JWT claim
Tracing: sample only slow or error responses
Tracing: sample only slow or error responses
Parse a JSON body field
Parse a JSON body field
Check a cookie value
Check a cookie value