/postman:api-mockingfrom Postman
Finds, builds, runs, and publishes API mocks for frontends, clients, or demos when the real API isn't available. Supports published mocks, spec-based mocks, and stateful mocks backed by real data.
Ships in Postman. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
A mock is a folder, config.yaml plus a handler such as default.js, that
answers like an API. The handler is a Node HTTP server that calls
listen(process.env.PORT). It loads as CommonJS even in an ESM project, so
import fails: use require. The same mock lives in your repo
(postman/mocks/<name>/, run with postman mock run, no sign-in needed),
in a Postman workspace after postman mock push, where other teams pull it
from, and on a mock server after postman mock deploy, for callers that
can't run it themselves.
Several APIs at once, for a service, a frontend or a test suite? Use
api-simulation, which gets each member's mock here.
When the API belongs to another team or a third-party provider, look for a published mock before writing one: a maintained mock encodes the contract and the service's state; yours encodes a guess.
Every step below needs a signed-in CLI. Check postman status first; signed
out, skip to building one and say the search was skipped.
Find the mock.
postman search workspaces "<service>" -o json. Name the service
plainly, as your code does, not by what it returns: a description
matches lookalike services. Prefer a Git-connected workspace
(isGitConnected) named for that service, then list its mocks with
postman mock list -w <workspaceId> --json. postman search mocks
misses some, and a same-named mock in another workspace isn't the
owner's.postman search mocks "<provider>" --ownership all -o json. The
workspace that holds one is rarely named for the provider, and the
default ownership searches only your organization. Prefer a codeMock
named for the provider from a verified organization
(organization.isVerified).A classicMock only replays a collection's saved examples: postman mock
can't pull or run it, so call one at https://<mockId>.mock.pstmn.io with
postman request, or generate a code mock from its collection.
Pull it with postman dependency add mock <mockId>, run the folder it
writes with postman mock run, and use it as it is. Commit
postman/.dependencies/ when CI should run it without signing in;
otherwise CI restores it with dependency install, which needs a sign-in
(see api-discovery). Never edit postman/.dependencies/:
dependency update overwrites it, so copy a mock to postman/mocks/ to
change it. A mock is code that runs as you; pull only from publishers you
trust.
Callers shouldn't be able to tell the difference on the paths they use. A mock that returns invented JSON passes your tests and fails against the real service.
Start from the contract. postman mock generate <spec or collection>
writes each documented response. It's a replay: a POST and a later
GET share nothing, and it accepts any request, so a call that breaks the
contract still gets its answer. x-mock-response-code picks only a
documented status; any other code gets the default 200, so put the errors
callers handle (the unknown-id 404, the conflict 409, the bad-input 400) in
the contract. From a spec
it serves the server URL's base path (/v2/...); from a collection,
routes start after the base-URL variable. --update regenerates the
handler and overwrites your edits. With no contract, write it from how
your code calls the API and say what you assumed.
Answer from the real records. When the data an API serves already
lives in a catalog sheet, a CSV or a database table, put it in a dataset
(named, queryable tables built from your CSV, JSON, sheet or database)
and have the handler query it per request: it returns real ids, prices
and edge cases, while hand-written JSON returns what you invented and
drifts as the data changes. The same dataset also feeds the API's tests,
CI and monitors, so there's no separate seed file to keep in step. To
create the dataset's .dataset.yaml file, see datasets. mock run --dataset <that file> gives the handler pm.datasets('<datasetId>'),
which takes the id: from that file, not its name or path. It works
signed out for file sources, and a --ref-only source serves edits to
the file without a restart.
// Parameters bind to $1, $2, ... in order.
const { rows } = await pm.datasets('<datasetId>')
.executeQuery('SELECT * FROM products WHERE sku = $1', [sku]);
const found = [];
for await (const r of rows) found.push(r); // rows can be read only once
if (!found.length) { res.writeHead(404); return res.end(); }
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(JSON.stringify(found[0])); // CSV values are text: "price":"9.99"
With interceptRequests: true (below), a failed query, such as a wrong
id, answers 500 with the reason. A mock that only needs the contract's
examples needs no dataset, and writes followed by reads still belong in
pm.state. For a demo or a frontend that needs a backend it can write to
and read back, seeded from those same rows, mock generate --dataset
bakes up to 20 rows per table into a stateful handler. It needs a sign-in
and sends the rows to Postman, so use fixture data, and rerun with
--update after the data changes.
Set interceptRequests: true in config.yaml. Without it req.body
and req.query are undefined, x-mock-session is ignored, and a throw in
an async handler kills the mock instead of returning a 500.
Make it stateful when callers write then read. Keep records in
pm.state, seed them on first use, add a reset route so a test can start
clean, and answer an unknown id with the real 404. Every mock run starts
empty.
Know who shares state. Locally, all callers share one state unless
each sends x-mock-session: <id>. A mock server deployed from the CLI
isolates each caller: one that keeps neither the same x-mock-session nor
the pm_mock_session cookie starts from the seed on every request, so its
POST and later GET never meet.
Scenarios are named handlers in config.yaml's scenarios list, picked
per request with x-mock-scenario: <name>. An unknown name falls back to
the default locally but is a 404 on a mock server.
postman mock run prints the URL it bound; a busy configured port moves
unless you pass --port, so take the URL from that line. Nothing reloads:
restart it after an edit.
A mock checked against the handler you just wrote proves nothing, so call
it with requests from the contract: postman request, or the API's
collection with
postman collection run <collection> --use-mock "{{baseUrl}} mock:postman/mocks/<name>"
(--mock alone only starts it). That form replaces the variable's whole
value, base path included, so a mock generated from a spec that serves
/v2/... answers 404; start that one with --mock <path> --port <n> and
pass --env-var "baseUrl=http://localhost:<n>/v2". To check your own calls
against a contract, compare each one, from the code or a simulation log,
with the spec; the mock won't reject a wrong one.
x-api-key, or, if they can
view the workspace, an access token as x-access-token. Deploying needs a paid plan; a team's first
server can take minutes to answer, and teams that review deploys hold them
for approval. Each later push changes what every caller of the server
gets, so treat it as a release, not a backup.fs or child_process: no local
requires, no pm.mock examples, no environment, no console output, and
no caller authorization, cookie or x-api-key headers. A mock that
relies on any of these works locally and breaks once deployed.--public. It serves the mock and its data to anyone with
the URL, and a scripted redeploy can't make it private again.A mock isn't done because it started. Call it: a documented error comes
back, a valid scenario changes the response, a POST then GET shows state
if it should. Say where it runs and who can call it, where it lives, and
what you assumed.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
20 skills in this plugin
/ai-readinessUse when assessing or improving how well AI agents can discover, call, and recover from errors with an API. Scores an existing Postman collection or OpenAPI spec and turns measured gaps into contract improvements; supports a separate CI readiness threshold. Use for requests such as "is this API ready for agents"./api-discoveryUse when finding an API or owner, integrating a public provider, locating Postman resources, or investigating consumers and change impact across services. Turns discovered contracts and mocks into reusable dependencies and identifies evidence outside the current checkout. Use for requests such as "who consumes this endpoint"./api-documentationUse when defining or improving an API contract, generating documentation from a collection or OpenAPI spec, publishing API docs, or sharing a documentation link. Makes auth, inputs, responses, and examples reusable by callers, tests, and mocks. Use for requests such as "publish API docs"./api-engineerUse when an HTTP API task spans several steps, such as building a new endpoint end to end with its contract, implementation, tests and mocks, or when it is API work and no narrower Postman skill fits. Prefer the narrower Postman skill when one fits. Routes to the relevant Postman skills and keeps contracts, tests and mocks reusable across the work, using organization-wide dependency context. Not for UI-only changes, library or CLI code, or questions about what existing code does. Use for requests such as "implement this endpoint"./api-monitoringUse when setting up recurring API checks, running or diagnosing a Postman Monitor, changing its schedule, or reaching private APIs through a self-hosted runner. Reuses collection assertions and their test rows to detect live regressions and traces failures to individual run evidence. Use for requests such as "check this API every minute"./api-simulationUse when you add or change code that calls other services and need to run it, test it, prove a fix or reproduce an upstream failure (timeouts, 5xx, 409, 429) end to end, locally or in CI, without the real services because they're unreachable, need credentials, cost money, have side effects or don't exist yet. Also use it to answer what happens to a request, or the data it writes, when a service it calls is down, slow or erroring ("what happens to a booking if the email service is down?"). Runs services, frontends, tests or demos against stand-ins for their HTTP dependencies, optionally backed by file or database records, served locally or at a deployed URL. A `postman/simulations/` directory is itself a reason to load it, even if nobody says mock or simulation. To give a frontend or another team a stand-in for an API, use api-mocking. Covers `postman simulation`.npx claudepluginhub postmanlabs/postman-plugin --plugin postmanOther plugins' skills for the same job