Skip to content

// Mock Responses

Model the responses your frontend must handle.

Configure success and failure variants, then call enabled mocks through the authenticated hosted runtime while the backend is still being built.

Payments API / mocks / example preview
Response variants

Defined on POST /payments

+ Add
Payment created

Delay 120 ms

201
Card declined

Delay 300 ms

422
Service unavailable

Delay 1,000 ms

503

Exercise a declined payment without a live payment backend

Save and enable a Card declined variant on POST /payments with status 422 and the body below. Configuration alone sends no request. Execute it using the workspace mock base URL and a mock server key; hosted calls consume the account quota. Keep the key out of public frontend bundles.

POST /api/public/v1/mock/<workspaceId>/payments
Authorization: Bearer <mock-server-key>
X-Rest-Test-Mock: Card declined

Expected configured response: 422
{ "code": "card_declined" }
Follow the practical guide

Capabilities

Mock Responses capabilities

  • Define several named variants for one operation.
  • Model success, validation, authorization and server errors.
  • Set status code, headers, JSON body and response delay.
  • Keep frontend expectations beside the endpoint contract.

Workflow

Your mock responses workflow

01

Open an operation

Choose the endpoint in API Designer.

02

Add a variant

Create a named success or error response.

03

Define behavior

Set status, headers, body and optional delay.

04

Share the contract

Review variants with workspace members, then execute enabled mocks with a scoped workspace mock server key.

Built for real handoffs.

Parallel development

Define expected response shapes while backend implementation is still moving.

Error-state design

Give frontend work concrete authorization, validation and server errors to handle.

Contract review

Keep variant bodies and headers attached to the operation being discussed.

Related features

// FAQ

Questions, answered.

// GET STARTED

Bring your API workflow into one workspace.

Start with an OpenAPI or Swagger JSON definition and keep the workflow together.

Start for free