Build and Parameterize Requests
Implementation starts with the requests your tests and mocks will reuse. The collection-schema-v3 skill covers how a collection is stored as per-request YAML files, and the variables skill keeps target configuration out of those files so one collection can run against any environment.
-
Ask Claude Code:
Add a "Get animated movie by ID" request to my Movies API collection for `GET /movies/animation/{{id}}` with an `id` collection variable defaulting to 1. Then create a "Local" environment with a `base_url` variable of `https://api.sampleapis.com`, switch every request in the collection to use `{{base_url}}`, and lint the collection and the environment.
-
Review the diff. Confirm the new request is its own
*.request.yamlfile, no request still hard-codes the host, theidvariable lives in.resources/definition.yaml, andpostman/environments/containsLocal.environment.yaml. -
The new request needs its own test and examples — the mock and the tests in later steps are built from them. Ask Claude Code:
Give the "Get animated movie by ID" request a status-code test and two saved examples, a 200 for id 1 and a 404 for an unknown id, using real responses from the live API. Lint the collection when you are done.
-
Confirm the request now has an
afterResponsescript and two example files. The live API returns404with an empty{}body for an unknown id.
Mock the API
A mock lets you build and test against the API without depending on the live service. The api-mocking skill generates a local mock from your collection, and postman mock run serves it with no sign-in required.
-
Ask Claude Code:
Generate a mock of the Movies API from my collection, run it locally, and call `GET /movies/animation` and `GET /movies/animation/1` against it. Also trigger the 404 example and show me what comes back.
-
Confirm Claude runs
postman mock generateandpostman mock run, prints the local URL it bound, and gets back the movie list, the movie with id 1, and the documented 404 ({}). -
Check that a
postman/mocks/<name>/folder with aconfig.yamlanddefault.jshandler now exists in your project. -
Read Claude's list of differences from the real API — a generated mock replays your saved examples, so expect these:
- The 404 only comes back when a request sends the header
x-mock-response-code: 404. A bad id with no header still returns the saved 200. - The list holds only the movies in your saved example, even though
X-Total-Countsays 96. - Nothing is stateful. Regenerating with
--updateoverwrites hand edits todefault.js.
- The 404 only comes back when a request sends the header
Simulate a Dependency
Real services call other services. The api-simulation skill runs your actual code against mocks of the HTTP APIs it depends on, so you can prove a change works end to end — and see what happens when a dependency fails — without touching the real thing. It needs Postman CLI 1.70.0 or later, so check postman --version.
-
Ask Claude Code:
Create a tiny Node service in a `catalog-service/` folder with one route, `GET /top-animated`, that calls the Movies API and returns the first three titles. Build a simulation that uses my Movies API mock as the service's dependency, run the service against it, confirm `GET /top-animated` returns a 200 with three titles, and show me from the simulation log that the mock was called.
-
Confirm Claude creates a
.sim.yamlunderpostman/simulations/, runspostman simulation run, and points the service's base URL at the simulation instead of the live API (the simulation serves each mock under its route key, for examplehttp://localhost:4900/movies-api). -
Check the happy path first:
GET /top-animatedmust return 200 with three movie titles, and the simulation log must show exactly onerequestevent forGET /movies/animationserved by the Movies API mock. A run that returns anything other than 200 isn't done yet — ask Claude to fix the wiring (a base URL missing its route key is the usual cause). -
Now break the dependency. Ask Claude Code:
Run the service again with the Movies API returning a 500 error and with it timing out. Tell me what the service does in each case and whether it handles the failure well.
-
Review what Claude found. Expect a clean 502 from the service in both cases — it should stay up and answer other requests. Injected failures are answered by the simulation itself, so they don't appear as mock requests in the log. A service with no timeout or error logging is a finding worth fixing.