Skip to main content

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.
string
The HTTP method of the request.
string
The complete URI of the request, including scheme, host, path, and query string. Supports .query(), .addQuery(), and .setQuery() methods.
string
The hostname of the request.
string
The scheme of the request (http or https).
string
The path component of the request URI, without query string.
string
The path and query string of the request URI. Supports .query(), .addQuery(), and .setQuery() methods.
string
The HTTP version of the request.
object
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.
string
The body of the request as a string.
Accessing request.body causes the body to be buffered in memory. Only reference this field when necessary, as it has performance implications for large payloads.
string
The timestamp when the request started, as an RFC3339 string. Use timestamp() to parse for time arithmetic.
string
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.
integer
The HTTP status code of the response.
object
The headers of the response. Supports the same chainable methods as request.headers.
string
The body of the response as a string.
Accessing response.body causes the body to be buffered in memory. Only reference this field when necessary, as it has performance implications for large responses.

source

The source object contains attributes about the downstream connection — the client that sent the request.
string
The IP address of the downstream connection.
integer
The port of the downstream connection.
object
The Istio SPIFFE identity of the downstream connection. Only present when mTLS is enabled and the downstream presents a valid certificate.
string[]
The Subject Alternative Names from the downstream client certificate, if available.
string
The issuer from the downstream client certificate, if available.
string
The subject from the downstream client certificate, if available.
string
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.
string
The name of the pod, when running on Kubernetes.
string
The Kubernetes namespace of the pod.
string
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.
string
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.
string
The username from the Basic authentication credentials.

backend

The backend object contains information about the backend selected to handle the request.
string
The name of the backend being used.
string
The type of the backend. One of: ai, mcp, static, dynamic, service, unknown.
string
The protocol of the backend. One of: http, tcp, a2a, mcp, llm.

extauthz, extproc, and metadata

object
Dynamic metadata set by external authorization (ext_authz) filters. Fields depend on what the external authorization service returns.
object
Dynamic metadata set by external processing (ext_proc) filters. Fields depend on what the external processor returns.
object
Values set by transformation metadata expressions in the Agentgateway configuration. Use this to pass computed values between transformation stages.

Practical examples