Automate creation of mock server out of collection

I have a collection with almost 500 requests I want to create mock server out of them I don’t want to save each request manually as an example. Can I do it using some API or run complete collection and save all requests as an example?

How I found the problem:

I’ve already tried:

Hi @supply-technologist2

I’m fairly new to mock servers but I don’t know of any automated way of creating examples.

The only suggestion I could offer is that you export the collection as JSON and write a script to add the examples in that way.

I’m very new to Postman and was also looking for a way to programmatically adding examples to a collection and then create a mock server from the collection. In your answer you advise to write a script to create the examples but therefore we would need an API endpoint from Postman that allows the creation of examples, I suppose? Unfortunately I have not been able to find such an endpoint.

To clarify my comment, I meant to write a script outside of Postman that altered the JSON file.

If you export your collection you would see the structure of the examples within the JSON;

These are stored in the response array. And I would think that new examples could be programmatically created and pushed to the array.