Skip to content

Gateway modes

Before you begin

Plan
Included in Pro and Team. How plans and limits work
Role
Admin or higher to change the gateway mode.

A project’s gateway mode decides what answers its requests: its mocks, a real API behind it (the upstream), or a mix.

It is set on the project’s Captures tab under Recording, in What answers a request, beside the Upstream base URL.

In Mock only, mocks answer and anything unmatched gets a 404. In Proxy unmatched, mocks answer first and unmatched requests go to the upstream. In Record everything, every request goes to the upstream and mocks are not consulted.In Mock only, mocks answer and anything unmatched gets a 404. In Proxy unmatched, mocks answer first and unmatched requests go to the upstream. In Record everything, every request goes to the upstream and mocks are not consulted.
The three gateway modes

Mock only is the default. The project answers from its mocks, and a request no mock matches gets a 404. Nothing leaves MockHub.

Proxy unmatched answers from mocks first. A request no mock matches is forwarded to the upstream, and the upstream’s answer goes back to the caller. Use it to mock the endpoints you are working on while everything else still reaches the real API. A running chaos profile shapes the forwarded answers too.

Record everything forwards every request to the upstream, and mocks are not consulted at all. Scenarios, response sequences and chaos profiles do not run in this mode. Use it to capture how a real API answers, then turn the captures into mocks.

Switching the mode takes effect with the next request.

A forwarded request goes to the Upstream base URL with the request’s path and query string appended: with https://api.example.com/v2 as the upstream, GET /orders?page=2 goes to https://api.example.com/v2/orders?page=2.

  • Addresses inside a private network are refused, both when you save the URL and on every forwarded request.
  • If the upstream answers with a redirect, the redirect is returned to your caller. MockHub does not follow it.
  • An upstream response larger than the plan’s traffic response body limit fails with 502, as does an upstream that cannot be reached.

Forwarded requests count against the workspace’s upstream allowance as well as its request limits. With no upstream set, both forwarding modes behave like Mock only.

On a plan without forwarding, both forwarding modes behave like Mock only whatever is saved, and the saved mode applies again once the plan includes forwarding. Switching a project to Mock only is always allowed, whatever the plan.

Settings → Subscription shows Upstream requests today and Upstream requests this month. Once either allowance is used up, a request that needs forwarding receives a 429 quota refusal. Mocks can still answer in Proxy unmatched.

When the project stores request logs, every forwarded exchange is kept as a capture, whether or not Log requests no mock answered is on. Captures are grouped by path, so /orders/8821 and /orders/8822 appear as one group, and each group shows whether a mock already covers it.

Promoting a capture creates a mock that matches its method and path and returns the recorded status, Content-Type and body. The query string is not part of the new mock’s rules.

Recorded traffic is someone’s real data. Before recording, add the fields that must never be stored to Body keys to redact in captures. Redaction applies to the JSON, XML and form bodies of captures, inbox posts and requests the gateway answered with its own 502, 500 or 503 (see Answers the gateway gives itself), on top of a built-in list that includes password, token and authorization:

  • In JSON, a key with that name loses its value, at any depth.
  • In XML, an element or attribute with that name loses its value, whatever its namespace prefix: password covers SOAP’s <wsse:Password>. A redacted element keeps its name only; its attributes and content become [REDACTED].
  • In a body sent as application/x-www-form-urlencoded, such as an OAuth token request, a field with that name loses its value, and so does a field named like a credential in a query string, such as key or sig. Names are compared after decoding, so client%5Fsecret counts as client_secret.
  • A body with nothing to redact is stored exactly as it was sent. A redacted one keeps its layout.
  • An XML body that declares entities in a DOCTYPE and has a field to redact is not stored, because the value could sit in the declaration. Nor is a JSON or XML body nested too deeply to check.
  • Multipart uploads and plain text are stored as sent.

A promoted mock contains the redacted values, never the originals.

  • Record everything does not use your mocks for anything, including requests the upstream fails to answer.
  • Comparing a capture with the mock made from it checks the status, Content-Type and the top-level keys of the body only; see Compare a mocked endpoint with the upstream. Nothing compares them automatically over time.

Report a problem with this page