Generate examples automatically

Hi there.

I love Postman examples, but I would love them even more if you could create them automatically.

I have some APIs that are usually down, so when they are up and I call them I would like to save the request/response pairing somehow inside Postman, and examples seemed to be the right idea for me.

However, while I know I can save them manually when I get a 200, I would like this to be automatic, I would like to do something like this:

//on Test tab
if(pm.response.status === 200) {
   //save example

Ideally I would do this on a collection level, but that might be too much to ask.

Is this behaviour posible? Any other (maybe better) ideas to save the results of my requests in Postman?

Thanks in advance

Hi @ddecasth - It’s possible to script a solution using the Postman API to run the API calls and create examples for various status codes. If you choose to do that, be careful that you don’t unintentionally reveal sensitive info, as many people choose to use sanitized or stubbed examples.

If you’d like to open a new feature request, feel free to do that here. I didn’t see one opened already, but if you find one that’s similar, you can always chime in with your use case and drop a link to this forum post.

Hey @joyce thanks for your answer.
Doing this via the Postman API could be interesting, however, I’m browsing the docs and can’t find any resource that creates examples. Would you be so kind to specify exactly how this could be done via the Postman API?
Thanks a lot :smiley:

You can try updating the collection that contains examples. Not ideal, but possible :man_shrugging: