Is it possible to setup a mock server which accepts requests by a given pattern?

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.

Hi guys,

Iโ€™ve searched for the answer for some time now and I failed to find anything.

Iโ€™m testing out the mock servers and I can not figure out how to make the mock server to work with variable URLs.

I have an API endpoint of โ€œ/order/initalize/[orderID]โ€. The โ€œ[orderID]โ€ part is variable and fits the ([A-Z0-9]{8}) regex;

It does not have to be such a specific pattern basically I would like the mock server to return the same example response for any call to โ€œ/order/initalize/[whatever_string]โ€ or โ€œ/order/initalize/*โ€ if you fancy.

Is it possible?

Thanks,
Jakub

Hey @jwwisniewski,

Welcome to the community :wave:

Are you able to provide an example of what you have tried so far, please?