rq.request object provides access to all details of the API request in your Requestly scripts. You can use these properties and methods in both pre-request and post-response scripts to read data.
Properties and Methods
rq.request.method
Use this property to get the Request’s method. The HTTP method of the request (e.g. GET, POST, PUT, OPTION, DELETE, PATCH, HEAD).
Example:
rq.request.headers
An object that holds the request headers. Read them with rq.request.headers.get(name), rq.request.headers.has(name), or rq.request.headers.all(), which returns a plain { name: value } object. JSON.stringify(rq.request.headers) returns {} because the object exposes only methods (which JSON.stringify omits), so use .all() when you want to serialize the headers.
Example:
rq.request.headers.add(header)
Adds a header. If a header with the same name already exists, this adds a second one (it does not replace the existing header).
Parameters:
header(object):{ key, value }- the header name and value.
rq.request.headers.upsert(header)
Adds a header, or replaces it if a header with the same name already exists. Header names are matched case-insensitively.
Parameters:
header(object):{ key, value }- the header name and value.
rq.request.headers.remove(name)
Removes every header with the given name (case-insensitive).
Parameters:
name(string): The header name to remove.
rq.request.headers.clear()
Removes all request headers.
Parameters: none. Any argument passed is ignored. clear() always removes every header, so to remove a single header use remove(name) instead.
Example:
The same operations are available directly on
rq.request as rq.request.addHeader({ key, value }), rq.request.upsertHeader({ key, value }), and rq.request.removeHeader(name).rq.request.body
The body of the request, accessible as a string. It is always a string, or undefined when the request has no body.
Example:
rq.request.url
The full URL of the API request.
Example:
rq.request.queryParams
A read-only object mapping each query parameter name to its value ({ name: value }). Iterate it with Object.entries().
Example:

