{"slug": "mock-any-api-response-in-postman-and-let-ai-build-the-collection", "title": "Mock any API response in Postman (and let AI build the collection)", "summary": "Postman now supports AI-generated mock servers that let frontend developers test any API response without touching the backend. By adding examples to a collection and using a mock server URL, developers can simulate status codes like 200, 404, and 500, and control which response is returned via a request header. Postman's integration with Claude through the MCP automates the creation of example responses, making it easier to build comprehensive test stands.", "body_md": "The hardest part of frontend testing isn't writing the test. It's getting the backend to return the exact response you need: a 500, an empty list, a malformed payload, right when you want it. On a live server that's painful, and sometimes impossible.\n\nHere's the workflow I use instead. I make the app receive **any** response I want, without touching the backend at all. Postman mock servers do the heavy lifting, and an AI fills them with data.\n\nYour frontend doesn't know where the JSON comes from. It calls a URL and trusts whatever comes back. So you point it at a **mock server**: a fake address that returns responses you defined in advance. Same endpoints, same shapes, zero real backend.\n\nFor a quick one-off, browser tools are fine:\n\nBut the override dies when you close the tab, it lives only on your machine, and you can't hand it to a teammate or a CI pipeline. For anything beyond a single check, you want a real, persistent stand.\n\nIn Postman you already (or soon will) have a collection: the same endpoints your real API exposes, with method, URL, body and headers.\n\nFor each request, hit the three dots and pick **Add example**. An example is a saved response: a status code plus a body. You write it by hand.\n\nHang several examples on the same endpoint to cover every case:\n\n`200`\n\nsuccess`404`\n\nnot found`[]`\n\nempty list`500`\n\nserver errorThree dots on the collection, then **Mock collection**. Postman gives you an address:\n\n```\nhttps://xxxx.mock.pstmn.io\n```\n\nSwap the base URL in your app config:\n\n``` js\n- const API = \"https://api.production.com\"\n+ const API = \"https://xxxx.mock.pstmn.io\"\n```\n\nThat's it. Your frontend now talks to the mock and never notices the difference.\n\nHere's where it gets good. You hung 200, 404 and 500 on the same endpoint. Which one does the mock return? It decides by a request header:\n\n```\nx-mock-response-name: order not found\n```\n\nSend that header from your automated test, and a **single endpoint** runs through every scenario without touching the server or the data:\n\n```\nawait fetch(`${API}/orders/42`, {\n  headers: { \"x-mock-response-name\": \"server error\" }\n})\n// the mock returns your 500 example\n```\n\nPostman supports dynamic variables right inside the example body:\n\n```\n{\n  \"id\": \"{{$randomInt}}\",\n  \"name\": \"{{$randomFullName}}\",\n  \"email\": \"{{$randomEmail}}\"\n}\n```\n\nEvery call comes back with different data instead of one hardcoded blob, so you catch the bugs that only surface on unexpected input.\n\nWriting dozens of example responses by hand is the boring tax on all of this. So I don't.\n\nI hand the whole collection to **Claude through the Postman MCP**, and it generates the example responses for every endpoint (success, edge cases, malformed payloads) and wires up the mock. I'm not asking it to write code. I'm asking it to assemble a working test stand while I drink my coffee.\n\nThat's the shift: AI stopped being \"write me this function\" and became \"build me the tool\".\n\nHow do you handle this on your team: Postman mocks, a standalone mock service, or still waiting on the backend?", "url": "https://wpnews.pro/news/mock-any-api-response-in-postman-and-let-ai-build-the-collection", "canonical_source": "https://dev.to/antonkirilchuk/mock-any-api-response-in-postman-and-let-ai-build-the-collection-2le1", "published_at": "2026-06-21 21:06:29+00:00", "updated_at": "2026-06-21 21:25:27.201191+00:00", "lang": "en", "topics": ["developer-tools", "artificial-intelligence"], "entities": ["Postman", "Claude", "MCP"], "alternates": {"html": "https://wpnews.pro/news/mock-any-api-response-in-postman-and-let-ai-build-the-collection", "markdown": "https://wpnews.pro/news/mock-any-api-response-in-postman-and-let-ai-build-the-collection.md", "text": "https://wpnews.pro/news/mock-any-api-response-in-postman-and-let-ai-build-the-collection.txt", "jsonld": "https://wpnews.pro/news/mock-any-api-response-in-postman-and-let-ai-build-the-collection.jsonld"}}