rq.response object provides access to all details of the API response in your Requestly scripts. You can use these properties and methods primarily in post-response scripts to process, validate, and extract data from API responses.
Properties and Methods
rq.response.body
The body of the response as a string.
Example:
rq.response.bodyEncoding
Tells you how rq.response.body encodes the original response bytes:
'utf8'- the body is the decoded text. This is the case for JSON, XML, HTML, and other text responses.'base64'- the body is Base64-encoded raw bytes, used for binary responses such as images, PDFs, and archives.
'utf8'.
Example:
rq.response.responseTime
The time taken by the request to complete, in milliseconds.
Example:
rq.response.headers
An object holding the response headers. Access a single header with rq.response.headers.get(name) or rq.response.headers.has(name) (both case-insensitive), or get them all as a plain { name: value } object with rq.response.headers.all().
Example:

