TESTING
Scripting API
Complete reference for all objects and globals available inside pre-request and test scripts.
request Object
Available in pre-request scripts only. Read/write access — modifications affect the outgoing request.
| Property | Type | Description |
|---|---|---|
| request.url | string | Full request URL (after variable interpolation) |
| request.method | string | HTTP method (GET, POST, etc.) |
| request.headers | KeyValue[] | Push to add, filter to remove. Each: {key, value, enabled} |
| request.body | RequestBody | Request body object (type, raw, formData, graphql, etc.) |
Note: Modifying
request in test scripts has no effect — the request has already been sent.
response Object
Available in test scripts only. Read-only access to the full HTTP response.
| Property | Type | Description |
|---|---|---|
| response.status | number | HTTP status code |
| response.statusText | string | Status text ("OK", "Not Found") |
| response.headers | Record<string, string> | Response headers (lowercase keys) |
| response.body | string | Raw response body text |
| response.json() | any | Parsed JSON (throws if body is not valid JSON) |
| response.time | number | Response time in milliseconds |
| response.size | number | Response body size in bytes |
| response.cookies | CookieEntry[] | Parsed cookies from Set-Cookie headers |
environment Object
Available in both pre-request and test scripts. Read/write access to the active environment.
| Method | Returns | Description |
|---|---|---|
| environment.get(key) | string | undefined | Get variable value from active environment |
| environment.set(key, value) | void | Save variable to active environment |
| environment.has(key) | boolean | Check if variable exists |
| environment.unset(key) | void | Remove variable from environment |
console
Available in both scripts. Output appears in the Test Results tab under "Script Logs".
| Method | Behavior |
|---|---|
| console.log(...args) | Output shown in script logs |
| console.assert(condition, message) | Failed assertion = test failure |
| console.warn(...args) | Also captured in script logs |
| console.error(...args) | Also captured in script logs |
Built-in Globals
Standard JavaScript globals available in the sandbox:
JSON
Math
Date
parseInt
parseFloat
encodeURIComponent
decodeURIComponent
atob
btoa
Buffer
crypto
setTimeout
RegExp
Array
Object
String / Number
crypto.randomUUID() generates UUIDs. Buffer.from() / .toString() for encoding. setTimeout is limited to max 5 seconds.
Limitations
✗5-second execution timeout — scripts that exceed this are terminated
✗No require/import — cannot load external modules
✗No file system access —
fs is not available✗No network requests —
fetch, http are not available✗No process/os access — fully sandboxed from the host system
✗Cannot import external libraries — only built-in globals are available
Error handling: Errors thrown in scripts are caught and displayed as script failures in the Test Results tab. They do not prevent the request from sending (pre-request) or the response from displaying (test).