Skip to content

Import from Postman ​

If you already have a Postman collection, Mock Studio can turn it into a mock. Each request becomes an endpoint, and the examples saved with the request become its responses.

Before you start ​

Export the collection from Postman as a .json file. In Postman, open the collection's menu, choose Export and pick Collection v2.1.

Mock Studio reads:

  • collections in format v2.1, v2.0 and the older v1;
  • a single request or a folder, copied as JSON;
  • one file or several at once, or JSON pasted into the dialog.

The mock answers with what the collection contains. A request that has saved examples in Postman gets those as responses. A request with none gets a placeholder 200 response, so save examples in Postman first if you want realistic replies.

Import a collection ​

  1. Select Import in the rail, then From Postman collection.

  2. Select Choose files and pick one or more collection .json files. Or paste JSON into Or paste Postman JSON here and select Add.

    You can add several collections before importing. The box reads Added: followed by their names.

  3. Read the preview: the number of endpoints, folders and saved examples, and any notes under them.

  4. In Import into, choose where the endpoints go.

  5. Select Import.

The Import from Postman dialog with a collection added and a preview of four endpoints
  1. 1Choose files — Pick collection files. Added collections are listed here.
  2. 2Add — Adds the JSON you pasted in the box.
  3. 3Preview — How many endpoints, folders and saved examples were found.
  4. 4Notes — Anything that did not convert cleanly.
  5. 5Import into — A new project or one of your existing projects.
  6. 6Import — Creates the endpoints.

A message confirms the result, such as Created "Shop API" with 4 endpoints.

Import into a new or an existing project ​

Import intoResult
A new projectA project named after the collection, on the next free port. With several collections the choice reads New projects (one per collection).
Existing: a project nameThe endpoints are added to that project. Existing endpoints are left as they are.

When you import into an existing project, a checkbox offers to put the new endpoints in a folder named after the collection, or Put each collection in its own folder when there are several. Keep it ticked to hold the imported endpoints together in the list.

A project created from a Postman collection, with an Orders folder and an endpoint using Conditional rules
After the import: folders from Postman, and an endpoint whose two examples became conditional rules.

How a collection is converted ​

Requests become endpoints ​

In PostmanIn Mock Studio
Request nameEndpoint name
MethodMethod. A method Mock Studio does not have is imported as ANY.
URLPath. The host is dropped.
DescriptionDescription / notes
FolderFolder in the endpoints list, nested folders included

The path keeps only the part after the host:

Postman URLEndpoint path
https://api.example.com/users/users
{{baseUrl}}/users/:id/users/:id
{{baseUrl}}/users/{{userId}}/users/:userId
{{baseUrl}}/v{{version}}/users/v2/users when the collection sets version to 2, otherwise /*/users

Saved examples become responses ​

Each saved example becomes one response:

In the exampleIn the response
NameLabel, or Example 1, Example 2 when it has no name
Status codeStatus
HeadersResponse headers. Transfer headers such as Content-Length and Date are left out.
BodyBody
Body language or Content-TypeBody type: JSON, XML, HTML or Text; Empty when there is no body

A request with no saved examples gets one response labelled Default, with status 200 and the body {"ok": true}.

Several examples become conditional rules ​

When a request has more than one example, the endpoint uses the Conditional rules strategy, so that every example can be reached:

  • The first example with a 2xx status is moved to the top and has no conditions. It is the fallback, sent when nothing else matches.
  • Every other example gets a condition, chosen like this:
The example's saved requestCondition added
Has a query parameter that the main request does not have, or with a different valueQuery param name equals value
Has no such differenceHeader x-mock-response-name equals the example's name

The header rule is the same convention Postman's own mock servers use. To ask for a particular example, send its name in that header:

bash
curl http://localhost:8080/orders/42 -H 'x-mock-response-name: Not found'

Without the header, the endpoint sends the fallback. You can replace these conditions with ones that suit your tests; see Conditional rules.

Variables ​

In PostmanWhat happens
A collection variable with a value, such as {{baseUrl}}Replaced with its value in bodies and headers
A Postman dynamic variable, such as {{$guid}}Replaced with the matching Mock Studio token
A variable with no value in the collectionLeft as typed, and listed in the notes

Environment and global variables are not part of a collection file, so they count as variables with no value. Replace them with fixed values or tokens after importing.

Dynamic variables that have a Mock Studio equivalent:

PostmanMock Studio
{{$guid}}, {{$randomUUID}}{{uuid}}
{{$timestamp}}{{timestamp}}
{{$isoTimestamp}}{{now}}
{{$randomInt}}{{randomInt(0,1000)}}
{{$randomFullName}}{{faker.name}}
{{$randomFirstName}}{{faker.firstName}}
{{$randomLastName}}{{faker.lastName}}
{{$randomEmail}}, {{$randomExampleEmail}}{{faker.email}}
{{$randomCity}}{{faker.city}}
{{$randomCompanyName}}{{faker.company}}
{{$randomPhoneNumber}}{{faker.phone}}
{{$randomBoolean}}{{faker.bool}}
{{$randomWord}}{{faker.word}}
{{$randomHexColor}}{{faker.color}}

Auth ​

If a request uses auth in Postman, the endpoint gets Require an auth header turned on. Auth set on a folder or on the collection is inherited by the requests inside, as in Postman, and No Auth on a request turns it off.

Postman authRequired header
Bearer token, Basic auth, OAuth and the other types sent in AuthorizationAuthorization
API key added to a headerThe key's header name, or X-API-Key when the name is a variable
API key or token added to the query stringNone. The mock can only require headers, so auth is not enforced.

The mock checks that the header is present, not that the value is right. See Auth, CORS and project settings.

What is not imported ​

Request bodies, pre-request and test scripts, and tests are not used. A mock only needs the responses.

Notes in the preview ​

The preview lists anything that needs your attention. Each note starts with a count.

Note saysWhat to do
Requests had no saved examples and got a default 200 responseAdd examples in Postman and import again, or edit the responses here.
Requests used methods Mock Studio cannot match exactly and were imported as ANYCheck those endpoints. Add a rule on HTTP method if needed.
Requests send credentials as a query parameter, so auth is not enforcedAdd a rule on Query param if you want to test the missing-key case.
A variable such as {{baseUrl}} includes a path that is not part of the imported pathsCall the mock without that prefix, or add it to the endpoint paths.
Path segments mixed text with variables and were turned into *Check the path matches what your app calls.
Some Postman variables have no value and are returned as-is in responsesReplace them with fixed values or tokens such as {{params.id}}.
Endpoints repeat a method and path imported earlierOnly the first is reached. Merge the examples into one endpoint or change a path.

If the file is rejected ​

MessageCause
This file isn't valid JSON.The file is not a Postman export. Export it again as Collection v2.1.
This is a Postman environment (or globals) fileYou picked an environment file. Export the collection itself.
This looks like an OpenAPI document, not a Postman collectionUse Import OpenAPI or Swagger instead.
This JSON isn't a Postman collectionThe JSON has no requests in a format Mock Studio knows.
No requests found in this collection.The collection is empty.

After importing ​

  1. Select Start server.

  2. Point your app at the mock's address in place of the real API's base URL.

  3. Open Live to check that the app's calls match the imported endpoints. A no match tag points to a path that differs, often a prefix such as /api/v1 that was part of {{baseUrl}}.

Coming from Postman altogether? See Postman migration for moving requests and collections to ApiWorkbench.

Next steps ​