Postman Mock Servers --> Modifying response before returning it to caller

Archived topic — some details may be out of date.
Mock servers built from saved collection examples are still supported. Postman now also has code-based mocks: JavaScript request handlers plus a config.yaml, stored as files in your Git repository, which you can run locally or deploy. Create one in the app, or use the Postman CLI to generate one from an OpenAPI spec, collection or dataset (postman mock generate) and run it (postman mock run). See About mocks and Create a mock.
Working with an AI coding agent? The Postman plugin can build and run mocks for you.
For current help, see the Postman docs, try the free Postman tools (no account needed), or join us on Discord.

Is it possible to configure a request in Postman so that we can modify the response and then return it back to the caller? I tried searching for results. The closest I got was using Test scripts, but this does not help because it only allows you to modify the “saved” response (which is already sent to the caller). The flow that I am looking for is:

Caller makes request → Postman endpoint hit → Match Response → modify response → Send response back to caller.

Example use case: I have a POST request set up for a mock server. The response body (example) saved for this request is “decrypted”. I am wondering if there is a way to configure this request such that when someone calls the mock endpoint, Postman grabs the saved (decrypted) response body, then runs some commands to encrypt the data and then send it back to the caller.

The above cannot be done using the Test Scripts feature.