Skip to main content

HTTP Macros

ngrok provides additional CEL macros that you can use specifically in the on_http_request and on_http_response phases.

NameReturn TypeDescription
isQueryString(string)boolReturns true or false if the provided string is valid query string.
isUrl(string)boolReturns true or false if the provided string is a valid URL.
isJson(string)boolReturns true or false if the provided string is a valid JSON.
hasReqHeader(string)boolReturns true or false if the provided header key is present on the request.
getReqHeader(string)listReturns a list of header values for the provided key on the request.
hasQueryParam(string)boolReturns true or false if the specified query parameter key is part of the request URL.
getQueryParam(string)listReturns a list of the query parameter values from the request URL for the specified key.
hasReqCookie(string)boolReturns true or false if a cookie exists on the request with the specified name.
getReqCookie(string)cookieReturns the cookie struct for the specified cookie name, if it exists on the request. If there are multiple cookies of the same name, the first from the ordering specified in the Cookie header will be returned.
hasResHeader(string)boolReturns true or false if the provided header key is present on the response.
getResHeader(string)listReturns a list of header values for the provided key on the response.
hasResCookie(string)boolReturns true or false if a cookie exists on the response with the specified name.
getResCookie(string)cookieReturns the cookie struct for the specified cookie name, if it exists on the response. If there are multiple cookies of the same name, the cookie with the longest path will be returned.

on_http_*

The following macros can be used in both the on_http_request and on_http_response phases.

isQueryString(string) -> bool

Returns true or false if the provided string is valid query string.

Example

Loading…

Example (Expression)

Loading…

Show agent config example

isUrl(string) -> bool

Returns true or false if the provided string is a valid URL.

Example

Loading…

Example (Expression)

Loading…

Show agent config example

isJson(string) -> bool

Returns true or false if the provided string is a valid JSON.

Example

Loading…

Example (Expression)

Loading…

Show agent config example

hasReqHeader(string) -> bool

Returns true or false if the provided header key is present on the request. Header keys must be written in canonical format.

Example

Loading…

Example (Expression)

Loading…

Show agent config example

getReqHeader(string) -> list

Returns a list of header values for the provided key on the request. Header keys must be written in canonical format.

Example

Loading…

Example (Expression)

Loading…

Show agent config example

hasQueryParam(string) -> bool

Returns true or false if the specified query parameter key is part of the request URL.

Example

Loading…

Example (Expression)

Loading…

Show agent config example

getQueryParam(string) -> list

Returns a list of the query parameter values from the request URL for the specified key.

Example

Loading…

Example (Expression)

Loading…

Show agent config example

hasReqCookie(string) -> bool

Returns true or false if a cookie exists on the request with the specified name.

Example

Loading…

Example (Expression)

Loading…

Show agent config example

Returns the cookie struct for the specified cookie name, if it exists on the request. If there are multiple cookies of the same name, the first from the ordering specified in the Cookie header will be returned.

Example

Loading…

Example (Expression)

Loading…

Show agent config example

on_http_response

The following macros can only be used in the on_http_response phase.

hasResHeader(string) -> bool

Returns true or false if the provided header key is present on the response. Header keys must be written in canonical format.

Example

Loading…

Example (Expression)

Loading…

Show agent config example

getResHeader(string) -> list

Returns a list of header values for the provided key on the response. Header keys must be written in canonical format.

Example

Loading…

Example (Expression)

Loading…

Show agent config example

hasResCookie(string) -> bool

Returns true or false if a cookie exists on the response with the specified name.

Example

Loading…

Example (Expression)

Loading…

Show agent config example

Returns the cookie struct for the specified cookie name, if it exists on the response. If there are multiple cookies of the same name, the cookie with the longest path will be returned.

Example

Loading…

Example (Expression)

Loading…

Show agent config example