Scripted response in mock server

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.

Hello experts.

I’m new to mock servers in postman but couldn’t find the answer so please help me out here.

I have the following scenario;
An external API call will be done towards my mock server (this is already working)
The external API software expects that a provided header value (from the Reques) is sent back as raw text (in the response body).

Image from the mock server including what is expected:

Text from the external API Call software:

Is there a way to script something like this into the response created by t he mock server?
If so can you please point me to the right directen?

Thanks a lot for your help,
Regards Lukas

Postman mock servers are not that advanced (and they probably should not be).

The purpose of a mock is to provide some data, but not business functionality. For example, you can hardcode some verification value but you can’t read the request and dynamically change the response.