Skip to content
subcloakdocs

API client

Import and export

Import Postman, OpenAPI, Swagger, HAR, Insomnia, .http and cURL into Cloak Proxy's API client; export to Postman, OpenAPI, .http and HTML docs.

The API client reads the formats other API tools write, so you can bring a Postman workspace, a spec or a teammate’s cURL command over in one step, and it writes them back out for people who use other tools. The client works out the format from the content, so you don’t have to say what you’re importing.

Choose files or paste text; the format is detected for you.

  1. Choose one or more files
  2. Or paste JSON, YAML or a cURL command
  3. Import what you pasted
The Import sheet listing the supported formats, a Choose Files button, a large empty text area to paste into, and Cancel and Import buttons
  1. Click Import in the toolbar, or + › Import… in the Collections sidebar.
  2. Click Choose Files… and select one or more .json, .yaml, .yml or .har files.
  3. Each file is imported. If one fails, an alert says “Couldn’t import” with the file name and the reason, and the others still import.

On Linux, drop files on the API client window or choose them in the Import sheet. Exports, and generated SDKs and MCP servers, are saved to your Downloads folder.

Format Detected by Becomes
cURL command Text that starts with curl A new unsaved request tab.
OpenAPI 3 or Swagger 2, JSON or YAML An openapi or swagger field A collection, plus the spec in Specs.
Postman environment A values list and no info A new environment.
Postman globals A globals export (_postman_variable_scope is globals) Variables added to Globals.
HAR A log.entries list A collection named after the file, with one folder per host.
Insomnia export: v4 (JSON or YAML) or v5 (YAML) Since 0.5.1 _type: export (v4), or a type ending in insomnia.rest/5.0 (v5) One collection per Insomnia collection, with its folders, requests, environments and cookies. A design document also adds its spec to Specs; a v5 environment file becomes environments. See Insomnia exports.
.http / .rest file Since 0.4.1 Its first request line (after comments, @variables and ###) is a method and a URL A collection: variables, requests and folders from ### Folder / Name. See .http files.
Postman collection v2.0 or v2.1 Anything else with an info object A collection. Exports from the Postman API, wrapped in {"collection": …}, work too.

Postman collections come in with almost everything:

Postman In Cloak Proxy
Folders and requests, in order Folders and requests. A request given as a bare URL string works too.
Descriptions Docs on the collection, folders and requests.
Collection variables Collection variables. Variables of type secret are marked secret.
Auth on the collection, folders and requests The same auth, including inherit. Types the client doesn’t support, such as NTLM, become No Auth so the import still works. See Authorization.
Pre-request and test scripts Pre-request and post-response scripts. See Scripts and tests.
URL, query and path variables URL, Params and Path Variables.
Headers, including disabled ones Headers, with disabled ones switched off.
Bodies: raw (with language), urlencoded, form-data (with files), file, GraphQL The matching body type. A GraphQL body makes the request a GraphQL request.
Saved responses Examples.
followRedirects: false and strictSSL: false Follow redirects and Verify TLS certificates turned off in the request’s settings.

Form-data and binary file paths point at files on the machine that exported them; pick the files again on your Mac.

  1. Import the spec (or drop the file onto the window).
  2. The client creates a collection named after the spec’s info.title, with its description as docs, and adds the spec to Specs.
  3. Set the collection’s baseUrl variable if the spec’s server URL isn’t the one you want to call.
Spec In the collection
The first server, with its variables’ defaults filled in (OpenAPI), or the first scheme, host and basePath (Swagger) The collection variable baseUrl. Without one, http://localhost.
Tags One folder per tag, in the order the spec lists them. Operations go in their first tag’s folder; untagged ones at the top level.
Each operation A request named after its summary (or operation ID, or method and path), with URL {{baseUrl}}/path.
Path parameters, {id} :id path variables, with example values and descriptions.
Query and header parameters Params and headers with example values. Required ones are switched on, optional ones off.
Request bodies JSON bodies built from the spec’s example or schema; form and multipart bodies as form fields (binary properties become file fields).
Responses One example per response code, with a body from the spec’s example or schema.
Security schemes Collection auth from the first scheme, with credential variables.
deprecated: true Docs that start with “Deprecated.”

Local $ref references (#/components/…) are followed. To keep a collection in step with a spec as the spec changes, use Sync Collection in Specs.

Each request in the HAR becomes a saved request in a folder named after its host, with its response as an example. It’s the same conversion as saving captured requests. To get a HAR file from Cloak Proxy, see Export sessions.

Since 0.5.1

Export from Insomnia (Export on a collection, or Preferences › Data › Export the “…” Project), then import the file. Both formats work: Insomnia 11’s v5 YAML (one file per collection, design document or environment) and the older v4 export (JSON or YAML, possibly holding several collections). An Insomnia project with several collections becomes several collections here.

After an import, anything that didn't come across as it was is listed, with the requests it's about.

The sheet after importing ShopApp API from Insomnia v5: 4 requests, 1 environment and 1 cookie, then a Check these list: NTLM auth isn't supported, a response tag kept as text, folder variables that became collection variables, a script with insomnia.* renamed to pm.*, and a form file path to check
In Insomnia Becomes
Collection (workspace) and its description A collection and its docs.
Folder (request group): auth, headers, scripts, description A folder with the same auth, headers, scripts and docs.
Request: method, URL, query parameters, path parameters (:id), headers, description The same. Query parameters are added to the URL; disabled ones stay in Params, switched off.
JSON, XML, plain text, YAML and other text bodies A Raw body in the matching language. A type Raw doesn’t have (YAML, EDN) keeps its Content-Type header.
Form URL Encoded x-www-form-urlencoded, disabled fields switched off.
Multipart Form form-data; file fields keep their path.
GraphQL A GraphQL request with its query and variables.
Binary File A Binary body with the file’s path.
Auth: Basic, Digest, Bearer, API Key, OAuth 1.0, OAuth 2.0, Hawk, AWS IAM, Atlassian ASAP, No Auth, inherit Basic, Digest, Bearer Token, API Key, OAuth 1.0, OAuth 2.0 (with an access token Insomnia fetched, when the export has one), Hawk, AWS Signature, JWT Bearer, No Auth, inherit. Auth that’s switched off becomes No Auth.
Pre-request and after-response scripts Pre-request and post-response scripts, with insomnia. renamed to pm. (Insomnia’s script API follows Postman’s).
Request settings: follow redirects, encode URL, send cookies, store cookies The request’s Settings: Follow redirects, Encode the URL automatically, Send cookies from the cookie jar and Save cookies the response sets.
Base environment The collection’s variables, so they apply whichever environment is chosen. Nested values are flattened: auth.client_id for {"auth": {"client_id": …}}, which {{ _.auth.client_id }} reads.
Sub-environments Environments. A private one’s values are secret.
Folder environments Collection variables (folders don’t have variables of their own). A name another folder or the base environment already uses is left out, and listed.
Cookie jar The API client’s cookie jar. Expired cookies are left out.
WebSocket request and its saved messages A WebSocket request with its headers (bearer, API key and basic auth as headers) and the messages in its Saved menu.
gRPC request A gRPC request with its method, message and metadata, using server reflection (the .proto files stay in Insomnia: import them in Settings › Protobuf to use them instead).
Design document’s spec A spec in Specs.
Global environments (v5 environment file, or v4 workspace of environments) Environments: the base one, and the others building on it.

Insomnia’s {{ _.name }} and {{ _['name'] }} become {{name}}. Its {% uuid %}, {% now 'iso-8601' %}, {% now 'unix' %} and {% faker 'randomFullName' %} tags become the matching dynamic variables ({{$randomUUID}}, {{$isoTimestamp}}, {{$timestamp}}, {{$randomFullName}}).

When something doesn’t come across as it was, a sheet lists it with the requests it’s about, and the same list is added to the collection’s docs. These are listed:

  • NTLM and .netrc auth, which the API client doesn’t have: those requests are set to No Auth.
  • Template tags with no equivalent, such as {% response %} (set a variable from the other response in a post-response script with pm.environment.set, and use {{name}}) and {% prompt %}. They stay in the request as text.
  • Variables with Nunjucks filters, such as {{ _.name | upper }}.
  • OAuth 2.0’s implicit grant (set to authorization code with PKCE) and resource parameter; OAuth 1.0 with RSA-SHA1.
  • File paths in forms and binary bodies, which point to the computer that made the export.
  • Scripts, after insomnia. is renamed to pm..
  • Folder variables, now collection variables.
  • Insomnia vault secrets, which are encrypted in the export and come in empty.
  • Unit tests, mock servers and client certificates, which aren’t imported.

cloakctl collection import and the import_into_client MCP tool print the same list. They don’t have a cookie jar, so they say how many cookies weren’t kept; import the file in the app to add them.

Paste a curl command into the Import sheet, or straight into a request’s URL field.

A command copied from a browser's developer tools
curl 'https://api.example.com/v1/orders' \
-H 'Authorization: Bearer {{token}}' \
-H 'Content-Type: application/json' \
--data-raw '{"sku":"A-100","qty":2}'

From the Import sheet, the client opens a new unsaved request named after the URL’s last path segment. Pasted into a URL field, it replaces that request’s method, URL, query params, headers and body. A JSON body becomes a Raw JSON body; any other body becomes TEXT.

Flags Effect
-X, --request Method. Without it, the method is POST when there’s a body, otherwise GET.
-H, --header A header.
-d, --data, --data-raw, --data-binary, --data-ascii Body data. Several are joined with &. Adds Content-Type: application/x-www-form-urlencoded if no type is set.
--data-urlencode Body data, URL-encoded.
--json Body data, plus Content-Type and Accept of application/json.
-F, --form A multipart field. The fields are written into a raw body; @file parts become a <file> placeholder.
-u, --user An Authorization: Basic header.
-A, --user-agent A User-Agent header.
-e, --referer A Referer header.
-b, --cookie A Cookie header (when it contains =).
-I, --head Method HEAD.
-G, --get Moves the data into the query string and uses GET.
--url The URL.

Flags that don’t change the request, such as -L, -k, --compressed, -s, -v, -o, -x and -m, are ignored. -d @file can’t read the file, so the body says <contents of file> for you to replace. A URL without a scheme gets http://.

For a form upload, switch the body to form-data after importing and choose the files.

Export Where File
Postman Collection v2.1 Right-click a collection › Export › Postman Collection v2.1…, or More in the collection’s tab <name>.postman_collection.json
OpenAPI 3.0 (YAML) Export › OpenAPI 3.0 (YAML)… <name>.openapi.yaml
.http file Since 0.4.1 Export › .http File (REST Client, JetBrains)… <name>.http. See .http files.
API Documentation (HTML) Export › API Documentation (HTML)… <name> docs.html, opened in your browser. See Examples and docs.
Postman environment Right-click an environment › Export…, or Export… in its tab <name>.postman_environment.json

The export keeps folders, requests, docs, auth (with inheritance), scripts, variables, headers (with disabled ones marked), every body type, path and query variables, examples as saved responses, and the Follow redirects and Verify TLS certificates settings. Postman, Newman and other tools that read Postman collections can open it.

The client writes a spec from the collection:

  • The baseUrl collection variable becomes the server.
  • Each HTTP request becomes an operation. Its path is the URL without {{baseUrl}}, with :id turned into {id}.
  • Operations are tagged with their top-level folder’s name.
  • Request bodies get a JSON Schema inferred from their JSON.
  • Saved examples become the documented responses.

Use it as a starting point for a real spec in Specs, where you can lint and edit it.

  • Secret variables are exported with empty values, in both collections and environments.
  • Values in auth fields, headers, URLs and bodies are exported as typed. A token pasted into a Bearer Token field is in the file.

You can also export captured traffic, rather than a collection, as a Postman collection or OpenAPI spec from the proxy. See Export sessions.