Save a response as an example
Keep a response on a saved request, masked, for a mock server to answer with.
In short
An example is a response kept on a saved request: its status, headers and body. A mock server answers with a request's examples. Secrets are masked before an example is saved.
Before you start
- Who: saving, changing or deleting an example needs Edit on the project. Anyone who can open it reads them.
- Plan: every plan.
- First: save the request, then send it so there is an answer to keep.
Steps
- Open a saved request and press "Send".
- On the answer, press "Save as example". A small form opens in place.
- Name it - the status is suggested, such as 200 OK - and tick "Make it the default example" if it should be the usual answer.
- Press "Save example". The message has Undo.
Result: the example is listed in the request's "Notes" tab with its status, content type and size, and {{brand}} says how many values it masked.
What is masked
- Credential headers and cookies are dropped.
- Fields that look like secrets have their values replaced.
- Values that look like tokens are replaced.
Editing an example masks it again. Read an example once before you share a mock address that answers with it.
Good to know
- The default example is what a mock answers when the caller asks for nothing in particular. Press "Make default" in the request's "Notes" tab to change it.
- Click an example to change its name, status, content type, headers or body. "Delete example" removes it, and a mock stops answering with it.
- A request holds up to 20 examples, each with its own name, and a body of up to 256 KB of text.
- Examples travel with the project: a {{brand}} JSON export carries them, saved responses in a Postman collection import as examples, and documented responses in an OpenAPI document import as examples.
If something goes wrong
- "Save as example" is switched off: the request is not saved yet. Save it first.
- A body that is not text is refused.
Related
- /help/api-testing/mock-servers
- /help/api-testing/import-export-packages