Skip to main content

Import & Export

Mercury imports Postman and Insomnia exports and cURL commands, and it can copy any request as a cURL command.

Where imports go​

Choose Import from Postman… or Import from Insomnia… from the workspace menu in the top bar. With no folder open, the sidebar also lists Postman collection and Insomnia export under Import. Pick the export file (or several at once: a Postman collection and its environment exports), and then:

  • if a workspace is open, the requests are written into it, in a new folder named after the collection (acme-api/), so they can't mix with or replace your own
  • if no workspace is open, Mercury asks for a folder to write to and opens it as the workspace; an empty folder (or one holding only .env files) gets the requests directly

Environments go in the workspace root as .env.<name>, where Mercury looks for them. When the import is done, its first request is open and its environment selected, and a notification says what was imported and where.

File and folder names are sanitized: they're lowercased, and spaces and characters such as / \ : * ? " < > | become -. For example, "Get User" becomes get-user.json. Nothing is ever overwritten: a name that's taken gets a suffix (.env.acme-api-2, list-users-2.json).

Postman​

Export the collection from Postman as Collection v2.1 (JSON); v2.0 works too. Your environments are separate exports in Postman (Environments β†’ β‹― β†’ Export): select them together with the collection, or import each one later, and each becomes .env.<name>. A globals export becomes .env, which every environment shares (or .env.<name> if the folder already has a .env). Disabled variables are left out.

PostmanMercury
Request<name>.json
Folder (any depth)Folder, with the same nesting
Collection variables.env.<collection-name> in the import folder
HeadersHeaders; disabled ones stay, switched off (# Name: value)
Request descriptionA description field in the request file
Raw bodyBody
GraphQL bodyThe JSON body Postman sends ({"query": …, "variables": …}), with Content-Type: application/json
URL-encoded bodyA Form body, with the matching Content-Type
Form-data bodyA Multipart body. File fields arrive switched off: tick one once you've checked which file it uploads
Bearer / Basic / API key authThe Authorization (or API key) header, or a query parameter
URLThe raw URL. Without one, the URL is rebuilt from its parts, skipping disabled query params.

Auth set on the collection or a folder applies to every request under it, and a request's own auth wins over it.

Postman {{variables}} stay as they are in URLs, headers and bodies, so they work with the generated .env file. Path variables are filled in (/users/:userId with value 42 becomes /users/42), or become {{userId}} when the collection has no value for them. A raw body's language (JSON, XML, text) sets the Content-Type Postman would have sent. Postman's built-in {{$guid}}, {{$timestamp}}, {{$isoTimestamp}} and {{$randomInt}} work as they are. Scripts and tests aren't imported.

What Mercury can't express is named in the notification rather than dropped quietly: OAuth 2 and other token-exchange auth, and binary-file bodies. Anything listed there needs finishing by hand on the Auth tab or the Body tab.

Example: importing a collection named "My API":

workspace/
β”œβ”€β”€ .env.my-api
β”œβ”€β”€ auth/
β”‚ └── login.json
β”œβ”€β”€ users/
β”‚ └── admin/
β”‚ └── list-admins.json
└── health-check.json

Insomnia​

In Insomnia, use Export on a collection (v5 YAML, Insomnia 10 and later) or Export Data (v4 JSON or YAML, older versions). Both work.

InsomniaMercury
Folder (any depth)Folder, with the same nesting
Request outside any folder<name>.json at the top
Sub-environment (Dev, Production…).env.<name>, including the base environment's values (Insomnia merges them the same way)
Base environment with no sub-environments.env.<collection-name>
{{ _.base_url }}{{base_url}}; nested values (_.api.url) become api.url
Bearer, API key and Basic authThe Authorization (or API key) header, or a query parameter
JSON / text bodyBody, with its Content-Type
GraphQL bodyIts JSON body, with Content-Type: application/json
Form URL-encoded / Multipart bodyA Form / Multipart body. File fields arrive switched off
HeadersHeaders; disabled ones stay, switched off
DescriptionA description field in the request file

Named in the notification, because Mercury can't express them: OAuth 2 and other token-exchange auth, Basic auth whose username or password is a variable (the header is base64, which would hide it), a file as the whole body, and template tags such as {% response %} or {% uuid %}.

workspace/
β”œβ”€β”€ .env.dev
β”œβ”€β”€ .env.production
β”œβ”€β”€ users/
β”‚ β”œβ”€β”€ admin/
β”‚ β”‚ └── ban-user.json
β”‚ β”œβ”€β”€ get-user.json
β”‚ └── list-users.json
└── health.json

Import from cURL​

Paste a command that starts with curl into the URL bar. Mercury parses it into the method, URL, headers and body. Pasted over a saved request, it opens as a new unsaved request instead, so the file is never overwritten. Typing curl … by hand is left alone; only a paste converts. This works with commands copied from browser DevTools or API docs, including multi-line commands that use \ continuations.

curl -X POST https://api.example.com/users \
-H "Content-Type: application/json" \
-d '{"name": "John"}'
FlagEffect
-X, --requestMethod
-H, --headerHeader (Name; is a header with an empty value, as in curl)
-d, --data, --data-raw, --data-binaryBody. Changes a GET to POST, unless the command says -X GET. Repeated flags are joined with &, as curl does. Without a Content-Type header, adds application/x-www-form-urlencoded, which is what curl sends.
--data-urlencodeBody, percent-encoded: in name=value only the value is encoded.
--jsonBody plus Content-Type: application/json. Changes a GET to POST.
-u, --userAuthorization: Basic ...
-A, --user-agentUser-Agent header
-b, --cookieCookie header
-I, --headHEAD
-G, --getGET, with any -d data appended to the URL as the query string
-F, --form, --form-stringA Multipart body, one field per -F (name=@path is a file; curl's ;type= is dropped). Changes a GET to POST. Copy as cURL writes Multipart bodies back as -F.
-o, -x, -c, -m, -w, -e, --output, --proxy, --cookie-jar, --connect-timeout, --max-time, --write-out, --cacert, --cert, --key, --refererIgnored, along with their argument
Other flags (-s, -L, -k, -v, --compressed, ...)Ignored

The first argument that isn't a flag is used as the URL. If there isn't one, you get an error. A value glued to a short flag (-XPOST, -HAccept:text/plain), short flags sharing one dash (-sX POST, -sI) and bash's $'…' quoting, which Chrome uses when a body contains a quote or a newline, all work.

Copy as cURL​

Press ⌘ Shift C to copy the current request to the clipboard as a cURL command:

curl -X GET 'https://api.example.com/users' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer abc123'
  • Variables from the selected environment are substituted in. Undefined ones stay as {{NAME}}.
  • Disabled (#) headers are left out.
  • Arguments are single-quoted, so you can paste the command into a POSIX shell as is.
  • The body goes in --data-raw, so one starting with @ is sent as text, not read from a file. A HEAD request is -I, a URL with [ ] or { } gets -g so curl doesn't read it as a pattern, and a header with an empty value is written Name;.
  • Pasted back into the URL bar, the command gives the same request.

Sharing request files​

Requests are plain .json files, so you can also share them by copying them, committing them to Git, or sending them to someone. See File Format.