Can you use values from the request body in the response body?

I want the Postman’s mock server respond to a POST request containing JSON values from the request body.

For example,


  "firstName": "John",
  "lastName": "Smith"


  "existing": true,
  "person":  {
    "firstName": {{firstName}},
    "lastName": {{lastName}}

Would be great if this exists, so we can push our API-first further

Hey @sjeefr ,

Perhaps there is a better approach than the one I’m suggesting however hopefully it may help you. I’m not entirely sure you’ll be able to accomplish your use case with the mock, but you could also make use of Postman Echo by using the post endpoint That endpoint should echo the contents of the request body and thus helping you test.

The following suggestion may be better suited for your needs. You could leverage the use of Dynamic Variables i.e to generate a random first name and random last name in your example response, e.g:

"firstName": "{{$randomFirstName}}",

You’d then create environment variables such as randomfirstName and randomlastName and set the request body to something like:

  "firstName": "{{randomFirstName}}",
  "lastName": "{{randomLastName}}"

And the final step would be to set up your test scripts to set the respective values of randomFirstName and randomLastName from the response body. Example:

var jsonData = pm.response.json();


Hopefully, you found this information helpful and useful.