Skip to main content
The res object is available inside the vars, assertions, scripting, and testing contexts. Use it to extract values from the response body, headers, and status. The res object is only available in the context of a request. You can also query nested response data using response queries.

Properties

PropertyDescription
res.statusHTTP status code (e.g., 200, 404)
res.statusTextHTTP status text (e.g., "OK", "Not Found")
res.headersKey-value pairs of HTTP response headers
res.bodyThe parsed response body (string, object, etc.)
res.responseTimeTime in milliseconds the request took to complete
res.urlThe full URL of the request

Methods

MethodDescription
res.getStatus()Returns the HTTP status code
res.getStatusText()Returns the HTTP status text
res.getHeader(name)Returns the value of a specific response header
res.getHeaders()Returns all response headers
res.getBody()Returns the response body
res.getResponseTime()Returns the response time in milliseconds
res.getUrl()Returns the request URL
res.setBody(data)Replaces the response body with new data
res.getSize()Returns an object with header, body, and total byte sizes

Example usage

// Accessing response properties
let status = res.status;               // 200
let statusText = res.statusText;       // "OK"
let contentType = res.headers['content-type']; // "application/json"
let body = res.body;                   // { message: "Hello, world!" }
let time = res.responseTime;           // 120
let url = res.url;                     // "https://api.example.com/data"

// Using getter methods
let headerVal = res.getHeader('content-type');
let allHeaders = res.getHeaders();
let size = res.getSize(); // { header: 234, body: 1024, total: 1258 }

// Modifying the response body for downstream scripts
res.setBody({ message: "Modified response" });