Skip to content

Postman compatibility

Restura runs scripts in a QuickJS WASM sandbox built around a native rs.* API. pm is a live alias of the same object, so existing Postman scripts run unchanged — and full Postman v12 sandbox parity means most of the surface is present. Here’s the mapping.

Looking for collection import/export (Postman v2.x and v3 files)? See Import & export. Export: Postman v3 (folder / zip) is the default; Postman v2.1 (single file) is for Newman. The Import & export guide has the details. This page covers script compatibility.

Postman APIRestura support
pm.requestRead access to method, URL and body. pm.request.headers also has add/upsert/remove/get/has/all/each/toObject; edits in a pre-request script are sent (HTTP and GraphQL; gRPC edits the metadata; MCP ignores them).
pm.response.code, .status, .text(), .json(), .responseTime, .headers (get/has/all/each/toObject), .cookies (get/has/all/toJSON/each/toObject), .to.have.status/header/body/jsonBody, .to.be.ok/json/html/withBody/info/success/redirection/clientError/serverError/error/accepted/badRequest/unauthorized/forbidden/notFound/rateLimited, and .to.not.* to negate. .to.be.* assert when read (pm.response.to.be.ok;) or called. The body is text on every platform; .json() and the JSON assertions parse it. .code is the number, .status the status text. With several Set-Cookie headers, .headers.get('Set-Cookie') returns them all joined with ", " (Postman returns the last one), and .to.have.header('Set-Cookie', v) matches any single cookie. See Set-Cookie in scripts.
pm.environment / pm.collectionVariables / pm.globals / pm.variablesFull get/set/unset/has. pm.environment writes from pre-request and test scripts are saved to the active environment (a collection run saves to the run’s environment; the CLI keeps them for the run only); a desktop secret-handle variable is never overwritten. A collection’s script writing to a shared (global) environment is held until you approve it once for that collection. pm.variables writes last for the request (and the run). pm.collectionVariables reads/writes the request’s actual owning collection and persists mutations back to it. Writes made before a script error are kept.
pm.test(name, fn)Test assertions with named scope. Sync or async: a returned promise is awaited, and a rejection (or a promise that never settles) fails the test.
pm.expect(value)chai-style assertions: .to.equal, .to.be.a, .to.include, .to.have.property, etc.
pm.iterationDataData-driven runs (CSV / JSON rows) — .get/.set/.has/.toObject() reflect the actual current row during a collection run (single-send: empty).
pm.info.requestName, .requestId, .iteration, .iterationCount, .eventName ('prerequest' / 'test') — populated from the real request during a send or collection run.
pm.execution.location.collectionName, .currentRequestName, .folderPath — always a real object (never undefined), populated during collection/folder runs.
pm.cookiesCookie jar lookup, plus an async .jar() for get/set/clear.
pm.sendRequest(input, cb?)Fire an ad-hoc request through the SSRF-guarded proxy. Returns a promise. Secret variables are never resolved: a token naming one refuses the sub-request. Parent headers are inherited on the parent’s origin only; on another origin none are, and headers the script sets stay. Works from the interactive Send button, gRPC, and in-app collection runs. Not wired in the CLI (rejects with a clear error).
pm.execution.setNextRequest / skipRequestRunner flow control. skipRequest() is honoured by the CLI runner and by the app’s Collection run (nothing is sent, the test script does not run, the row is recorded as skipped). With stop-on-failure / --bail, an unknown setNextRequest name or the jump cap stops the run.
pm.visualizer.set(template, data)Custom HTML response visualizations.
pm.vaultEncrypted secret vault (await pm.vault.get(...)). Restura-native. Desktop only.
require(name)Bundled library set: ajv, chai, cheerio, crypto-js, csv-parse/sync, lodash, moment, postman-collection, tv4, uuid, xml2js.
console.log/warn/errorOutput to the script panel.
postman.setEnvironmentVariable / getEnvironmentVariable / clearEnvironmentVariableLegacy pre-pm API — aliases for pm.environment.*.
postman.setGlobalVariable / getGlobalVariable / clearGlobalVariableLegacy aliases for pm.globals.*.
postman.setNextRequest(name)Legacy alias for pm.execution.setNextRequest(name).
tests["assertion label"] = true/falseLegacy object-literal test style — equivalent to pm.test(label, () => ...).
HelperWhat it returns
{{$randomUUID}}UUID v4 per request.
{{$guid}}Alias for $randomUUID.
{{$timestamp}}Epoch seconds.
{{$isoTimestamp}}ISO 8601 timestamp.

A :name path segment (/users/:id) takes its value from the request’s Path variables rows, shown under the query params in the Params tab and kept in step with the URL. Postman imports keep :id in the URL and bring url.variable / pathVariables in as those rows (v2.1 and v3 export write them back). An enabled row with a non-empty value replaces the whole segment at send time, after {{var}} resolution, percent-encoded as one segment; the host, port, query and fragment are never touched. A :name with no row (or a disabled or empty one) is sent as written, as in Postman. Web, desktop, the CLI and code snippets all apply the same rule.

  • Raw fetch / XMLHttpRequest — use pm.sendRequest(...) for network access.
  • Arbitrary require('...') beyond the bundled set above — no reaching into npm or Node core.
  • DOM globals and the filesystem — the sandbox has neither.

The sandbox is intentionally narrow:

  • Shared collections are everywhere. Scripts from a downloaded collection should never be able to exfiltrate data or escape the request context — hence no raw network and no arbitrary modules.
  • Predictable runtime. Memory and execution-time caps mean a malformed loop can’t take down the app.
  • Scripts — the script editor, the rs.* API, and examples.
  • Workflows — declarative chaining where you’d otherwise script.
  • Import & export — importing Postman v2.1 collections.