API Mock
Pronunciation: A-P-I Mock
Definition
API Mock is a simulated API implementation that returns controlled responses without invoking the real backend. It is used to support early development, deterministic tests, demonstrations, and failure simulation. It differs from an API sandbox, which is usually a provider-operated test environment with more real workflow behavior.
Overview
Meaning and scope
API Mock is a simulated API implementation that returns controlled responses without invoking the real backend. It is used to support early development, deterministic tests, demonstrations, and failure simulation. It differs from an API sandbox, which is usually a provider-operated test environment with more real workflow behavior.
Mechanism and operation
The mock reads a contract or configured rules, matches incoming requests, and returns example, generated, or scripted responses for selected scenarios. Important failure modes include unrealistic latency, permissive validation, missing side effects, stale schemas, and hard-coded happy paths. Test data, credentials, endpoints, and callbacks used for API Mock should remain clearly separated from production resources. Operational evidence should include mock version, contract revision, scenario, request match, generated response, latency, and test result. API Mock should be documented alongside API Testing, API Sandbox, and API Contract. The API Mock plan should include expected results and assertions for both technical responses and the resulting application state.
Practical payment example
Before a payment gateway is enabled, developers test checkout handling with a mock returning delayed, failed and duplicate responses. The mock verifies application state transitions but does not prove live provider behavior.
Operational checks
Scenario data for API Mock should be repeatable, isolated, and safe to reset without affecting live customers or balances. The API Mock evidence should retain environment, scenario, version, request and event IDs, observed result, and reviewer decision.
Distinctions and limits
Coverage reporting for API Mock should identify unsupported production behaviors rather than presenting sandbox success as complete readiness.
Related reading
Related definitions: API Testing, API Sandbox.
Example
Before a payment gateway is enabled, developers test checkout handling with a mock returning delayed, failed and duplicate responses. The mock verifies application state transitions but does not prove live provider behavior.
Comparison
It differs from an API sandbox, which is usually a provider-operated test environment with more real workflow behavior. Coverage reporting for API Mock should identify unsupported production behaviors rather than presenting sandbox success as complete readiness.
Key Takeaway
Generate from versioned contracts, validate requests, simulate errors and timing, version scenarios, and complement mocks with sandbox and integration testing.
Sources
- Mock Servers — Postman (2026-08-03)
- OpenAPI Specification — OpenAPI Initiative (2026-08-03)
- Testing — Stripe (2026-08-03)