For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Postman
PricingEnterprise
Contact SalesSign InSign Up for Free
HomeDocs
HomeDocs
      • Overview
        • Overview
        • Write pre-request scripts
        • Write tests
        • Script examples
        • Dynamic variables
          • Overview
          • pm variables methods
          • pm.vault
          • pm.cookies
          • pm.request
          • pm.response
          • pm.sendrequest
          • pm.visualizer
          • pm.test and pm.expect
          • pm.require
          • pm.execution
          • pm.message
          • pm.info
          • pm.mock
          • pm.datasets
          • pm.state
        • Troubleshoot test errors
Postman API Platform

Product

  • Postman Overview
  • Enterprise
  • Spec Hub
  • Flows
  • Agent Mode
  • API Catalog
  • Fern
  • Postman CLI
  • Integrations
  • Workspaces
  • Plans and pricing

API Network

  • App Security
  • Artificial Intelligence
  • Communication
  • Data Analytics
  • Database
  • Developer Productivity
  • DevOps
  • Ecommerce
  • eSignature
  • Financial Services
  • Payments
  • Travel

Resources

  • Postman Docs
  • Academy
  • Community
  • Templates
  • Intergalactic
  • Videos
  • MCP Servers

Legal and Security

  • Legal Terms Hub
  • Terms of Service
  • Postman Product Terms
  • Security
  • Website Terms of Use

Company

  • About
  • Careers and culture
  • Contact us
  • Partner program
  • Customer stories
  • Student programs
  • Press and media
Twitter iconLinkedIn iconGithub iconYouTube iconInstagram iconDiscord icon
Download Postman
Privacy Policy

© 2026 Postman, Inc.

On this page
  • pm.require
  • Use global objects
  • Use external libraries
Tests and scriptsWrite scriptsPostman sandbox reference

Import packages into your scripts

||View as Markdown|
Was this page helpful?
Previous

Writing tests and assertions in scripts

Next

Use scripts in collection runs

Built with

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:

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

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

1// package imported from npm
2const npmVariableName = pm.require('npm:package-name@version-number');
3
4npmVariableName.functionName()
5
6// package imported from jsr
7const jsrVariableName = pm.require('jsr:package-name@version-number');
8
9jsrVariableName.functionName()

Use global objects

Postman supports the following JavaScript objects globally in your scripts:

  • Standard objects
    • AggregateError
    • Array
    • ArrayBuffer
    • Atomics
    • BigInt
    • BigInt64Array
    • BigUint64Array
    • Boolean
    • DataView
    • Date
    • Error
    • EvalError
    • Float32Array
    • Float64Array
    • Function
    • Infinity property
    • Int8Array
    • Int16Array
    • Int32Array
    • Intl
    • JSON
    • Map
    • Math
    • NaN property
    • Number
    • Object
    • Promise
    • Proxy
    • RangeError
    • ReferenceError
    • Reflect
    • RegExp
    • Set
    • SharedArrayBuffer
    • String
    • Symbol
    • SyntaxError
    • TypeError
    • Uint8Array
    • Uint8ClampedArray
    • Uint16Array
    • Uint32Array
    • URIError
    • WeakMap
    • WeakSet
  • Document Object Model (DOM) objects
    • AbortController
    • AbortSignal
    • DOMException
    • Event
    • EventTarget
  • Encoding objects
    • atob method
    • btoa method
    • TextEncoder
    • TextEncoderStream
    • TextDecoder
    • TextDecoderStream
  • File objects
    • Blob
    • File
  • JavaScript objects
    • decodeURI
    • decodeURIComponent
    • encodeURI
    • encodeURIComponent
    • escape
    • isFinite
    • isNaN
    • parseFloat
    • parseInt
    • undefined
    • unescape
  • HTML DOM objects
    • structuredClone method
    • queueMicrotask method
  • Streams objects
    • ByteLengthQueuingStrategy
    • CountQueuingStrategy
    • CompressionStream
    • DecompressionStream
    • ReadableByteStreamController
    • ReadableStream
    • ReadableStreamBYOBReader
    • ReadableStreamBYOBRequest
    • ReadableStreamDefaultController
    • ReadableStreamDefaultReader
    • TransformStream
    • TransformStreamDefaultController
    • WritableStream
    • WritableStreamDefaultController
    • WritableStreamDefaultWriter
  • URL objects
    • URL
    • URLSearchParams
  • Web Crypto objects
    • Crypto
    • CryptoKey
    • SubtleCrypto
    • crypto property

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:

  • ajv
  • chai
  • cheerio
  • csv-parse/lib/sync
  • lodash
  • moment
  • postman-collection
  • uuid
  • xml2js

The following libraries are deprecated and no longer supported:

  • atob (use the atob method)
  • btoa (use the btoa method)
  • crypto-js (use the Web Crypto objects)
  • tv4 (use the ajv library)

The following NodeJS modules are also available:

  • path
  • assert
  • buffer
  • util
  • url
  • punycode
  • querystring
  • string-decoder
  • stream
  • timers
  • events

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