Field guide / API mocking

Design API mocks that reveal integration problems instead of hiding them

A practical approach to choosing endpoints, examples, errors, state, latency, and ownership for mocks that teams can trust.

What goes in, what comes out, and what the result can prove.

INPUTA client dependency and the behaviors it must handle
OUTPUTMock matrix covering success, errors, timing and state

Design a behavior matrix before writing fixtures

Scenario       Status  Delay  State transition
happy path     200      80ms   none
not found      404      40ms   none
rate limited   429      20ms   retry after 30s
accepted       202     120ms   pending → complete

Three checks before the result becomes a decision.

01

Contract fidelity

Use realistic status, headers and payload shape.

02

Failure coverage

Include validation, auth, rate-limit and upstream failures.

03

State

Model transitions only when the client depends on them.

What this workflow does not prove.

Before you put it into a real workflow.

Should every endpoint be mocked?

No. Start with the consumer journeys that are blocked or carry the highest integration risk.

Where should examples come from?

Prefer contract examples and sanitized representative payloads over arbitrary generated shapes.

How do mocks become stale?

They drift when the source contract or real behavior changes without an owner updating the scenarios.

Start with one concrete API problem.

Keep the first step small. Move into a workspace when the result deserves to be saved, repeated, or shared.