Import packages into your scripts

You can use the pm.require method to import packages from your team’s Package Library or external package registries inside scripts in HTTP, gRPC, and GraphQL requests.

pm.require

The pm.require method accepts the name of a package. Declare the method as a variable if the package has functions or objects you want to call. If the package only has code or instances of the pm object, you don’t need to declare the method as a variable.

Examples

Use the following format to import a package from the Package Library:

const variableName = pm.require('@team-domain/package-name');

variableName.functionName()

Use the following format to import an external package from a package registry:

// package imported from npm
const npmVariableName = pm.require('npm:package-name@version-number');

npmVariableName.functionName()

// package imported from jsr
const jsrVariableName = pm.require('jsr:package-name@version-number');

jsrVariableName.functionName()

Use global objects

Postman supports the following JavaScript objects globally in your scripts:

Use external libraries

The require method enables you to use the sandbox built-in library modules. To use a library, call the require method, pass the module name as a parameter, and assign the return object from the method to a variable:

require(moduleName:String):function

The supported libraries available for use in the sandbox include:

The following libraries are deprecated and no longer supported:

The following NodeJS modules are also available:

Postman doesn’t support the following in the buffer module: isAscii, isUtf8, resolveObjectURL, transcode, and copyBytesFrom.

Last modified: 2025/11/04