> ## Documentation Index
> Fetch the complete documentation index at: https://bruno-a6972042-mintlify-response-docs-1775161843.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Response object

> Access response data including body, headers, status, and more in your scripts

The `res` object is available inside the [vars](../vars), [assertions](../../tests/assertions), [scripting](../getting-started), and [testing](../../tests/introduction) 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](./response-query).

## Properties

| Property           | Description                                       |
| ------------------ | ------------------------------------------------- |
| `res.status`       | HTTP status code (e.g., `200`, `404`)             |
| `res.statusText`   | HTTP status text (e.g., `"OK"`, `"Not Found"`)    |
| `res.headers`      | Key-value pairs of HTTP response headers          |
| `res.body`         | The parsed response body (string, object, etc.)   |
| `res.responseTime` | Time in milliseconds the request took to complete |
| `res.url`          | The full URL of the request                       |

## Methods

| Method                  | Description                                                     |
| ----------------------- | --------------------------------------------------------------- |
| `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

```javascript theme={null}
// 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" });
```
