Docs Tips & Useful Features

Tips & Useful Features

Mockarty’s UI includes many productivity features that are not immediately obvious. This page describes them so you can work faster and get more out of the tool.


Table of Contents

  1. Understanding URLs in Examples
  2. Keyboard Shortcuts
  3. Quick Search
  4. Constructor: Smart Autocomplete
  5. Constructor: Request-Based Suggestions
  6. Constructor: Info Tooltips
  7. Constructor: URL Preview
  8. Constructor: Auto-Generated Mock ID
  9. Constructor: Form Validation
  10. API Tester: Environments and Variables
  11. API Tester: Pre-Request and Test Scripts
  12. API Tester: Import and Export
  13. API Tester: Collection Sharing
  14. Recorder: Saved Configurations
  15. Recorder: Map Local
  16. Recorder: AI Analysis
  17. Templates: Reusable Response Bodies

Understanding URLs in Examples

Examples use localhost:5770 for a local Mockarty installation. Replace it with your instance’s address when you use a remote server. Quick Start explains the URLs, including the separate address used by server-side features such as Recorder.


Keyboard Shortcuts

Mockarty provides these keyboard shortcuts in the web interface:

Shortcut Action
Ctrl+S (Cmd+S on Mac) Save when the current page offers a supported Save action
Ctrl+Enter (Cmd+Enter) Test a mock or send a request when that action is available
Ctrl+K (Cmd+K) Open the Quick Search modal
Ctrl+Shift+/ (Cmd+Shift+/) Show the keyboard shortcuts help dialog
Escape Close Quick Search or the shortcuts help dialog; other panels handle Escape locally

Note: Ctrl/Cmd shortcuts work even when your cursor is in a text input. Non-modifier shortcuts are disabled while typing so they don’t interfere with your text.


Press Ctrl+K (Cmd+K) to open Quick Search. It finds:

  • Mocks by name or route in the current space
  • Test cases and test plans in the current space
  • Main pages (Mocks, API Tester, Stores, Settings and others) and available plugin commands

Type at least 2 characters to see results. Use Arrow Up/Down to navigate results and Enter to open the selected item.
Recently opened items appear while the search box is empty and remain available only in the current tab and namespace. They are cleared when you switch namespaces or reload or close the tab.


Constructor: Smart Autocomplete

The Mock Constructor has a smart autocomplete system that suggests interpolation expressions, Faker functions, headers, and store references. It works in several contexts:

Response Body Fields

When editing response body values, the autocomplete suggests:

  • JsonPath prefixes — $.req, $.reqHeader, $.queryParams, $.pathParam, $.fake, $.gS, $.cS, $.mS. The available prefixes depend on the mock protocol (e.g., HTTP mocks have $.queryParams and $.pathParam, but gRPC mocks do not).
  • Faker functions — type $.fake. to browse 74 built-in functions by category (Address, DateTime, Internet, Person, Payment, ID & Hashes, Text, Business, Phone, Russian, Common). Each function shows an example value. Plugins may add more functions.
  • Math functions — $.increment(...), $.sum(a, b), $.multiply(a, b), $.subtract(a, b), $.divide(a, b), $.modulo(a, b).
  • Store references — $.gS.key (Global Store), $.cS.key (Chain Store), $.mS.key (Mock Store) with suggestions for common key names (counter, token, sessionId, userId, orderId, status).

How to Activate

  • Click or focus on a response body value field — autocomplete appears automatically.
  • Start typing $. — see prefix suggestions.
  • In the CodeMirror editor (full JSON response body mode), press Ctrl+Space to trigger autocomplete.
  • Use Arrow Up/Down to navigate suggestions, Enter to select, Escape to dismiss.

Condition Fields

When editing condition body fields, the autocomplete suggests request body field paths. When editing condition header fields, it suggests common HTTP header names (Content-Type, Authorization, Accept, X-Request-Id, and more).

Webhook Fields

When editing webhook body templates, the autocomplete suggests $.response.* paths to reference the mock’s own response data.


Constructor: Request-Based Suggestions

The autocomplete system becomes smarter when you provide an Example Request in the constructor:

  1. In the Constructor, open Request Conditions and paste a sample JSON body that your mock expects to receive into Example Request Body.
  2. After that, when you edit response body values or condition body fields, the autocomplete will suggest field names extracted from your example request — with hierarchical dot-navigation for nested objects.

For instance, if your example request is:

{
  "user": {
    "name": "John",
    "email": "john@example.com"
  },
  "orderId": 123
}

The autocomplete will suggest $.req.user, $.req.user.name, $.req.user.email, $.req.orderId — so you can build dynamic responses that reference the incoming request without memorizing the field paths.

Tip: If no example request is provided, the autocomplete falls back to suggesting common field names (id, name, email, status, etc.).


Constructor: Info Tooltips

Throughout the constructor form, you will see small info buttons (ⓘ) next to field labels. Click or hover on them to see a tooltip explaining what the field does, what format it expects, and practical examples.

They are available on most fields, including Protocol, Mock ID, Path Prefix, Response Status Code, Delay, Conditions and Extractors.


Constructor: URL Preview

When you fill in the path and Path Prefix fields in the constructor, a live path preview updates below them under Full path:. It shows the path the resolver matches. Clients call it with the space prefix in front: /stubs/{space}/<full path>.


Constructor: Auto-Generated Mock ID

If you leave the Mock ID field empty, Mockarty generates a unique ID automatically when you save the mock. You can also click the sparkle button (✦) next to the Mock ID field to auto-generate a readable ID based on the route and method.


Constructor: Form Validation

The constructor validates your inputs in real time:

  • Route must start with / and must not contain spaces.
  • Status Code must be between 100 and 599.
  • Delay must be non-negative and at most 300,000 ms (5 minutes).

Validation errors appear as red borders and error messages directly below the field. Errors clear automatically when you correct the value.


API Tester: Environments and Variables

The API Tester has a full environment variable system, similar to Postman:

Creating Environments

  1. Open API Tester in the sidebar.
  2. In the top toolbar, click the gear next to the env selector (tooltip Manage Environments).
  3. Click New, give the environment a name and confirm (e.g. “Development”, “Staging”, “Production”).
  4. Add key-value pairs (e.g. base_url = http://localhost:5770, api_token = mk_your_token).

Using Variables in Requests

Reference environment variables in any field using double curly braces:

{{base_url}}/api/v1/mocks

Variables are interpolated in: URL, headers, query parameters, request body, and authentication fields. This works across all protocols (HTTP, gRPC, GraphQL, SOAP, Kafka, RabbitMQ, WebSocket, SSE, MCP, SMTP).

For an MCP tool request, use Auth → Bearer and enter the token without the
Bearer prefix, or set the complete Authorization value in Headers.
Bearer tokens, Basic credentials and header values in tool requests can use
environment variables, for example {{api_token}}, including during Connect. Prefer a header or an Auth
field over putting a credential in the server URL. Keep the variable reference
in the saved request and select the intended environment before sending.
Server-side MCP initialization retains authentication through same-origin
redirects that preserve the HTTP method (for example /mcp to /mcp/). A
redirect to another scheme, host or port is refused: use that server’s direct
endpoint instead. This prevents custom credentials and session headers from
being forwarded to another server. Subsequent tool calls use the initialized
endpoint and refuse redirects to avoid repeating a potentially completed action.
If the response is lost, check the remote result before sending again.
The MCP connection is ready only after initialization and tool discovery both
succeed. A valid empty tool list is allowed; a discovery error is not reported
as a successful connection. Connect again after changing the server.

Direct browser execution of MCP tool calls is unavailable: a browser can resend
a request when a connection closes without a response. Mockarty refuses this
mode before sending an MCP request or running request scripts. It does not
silently send the endpoint or credentials through the Mockarty server instead.
Use a Mockarty instance that can reach the MCP server, such as a local Desktop
instance for services on your machine. Existing server-side execution remains
subject to the instance’s network access policy. If an executed request loses
its response, check the remote result before sending again.

For SOAP, the Action field supplies SOAPAction, and XML Content-Type is
added when you have not set one. An explicit header takes precedence, regardless
of its spelling case. Imported SOAP requests keep their original Content-Type,
including the action parameter used by SOAP 1.2.

For GraphQL execution, application/json is used only when you
have not supplied a Content-Type. Your explicit header is kept without adding
a second default value, regardless of its spelling case.

For server-side HTTP, SOAP and GraphQL requests with a nonempty body, a lost
response does not silently replay that body, even with an Idempotency-Key
header. Explicit redirect settings and authentication challenges still apply.
An error after dispatch does not prove that the remote operation failed: check
its result before sending again.

Switching Environments

Select a different environment in the env selector — all {{variable}} references in your requests instantly use the new environment’s values. This lets you quickly switch between dev/staging/production without editing each request.

Values keep their leading and trailing spaces. A shared environment owned by another user is read-only in the manager. Choose Create personal copy to edit a separate environment; script changes to the shared environment apply only to the current execution. Saving script variables in your own environment preserves its name and sharing settings.


API Tester: Pre-Request and Test Scripts

Each request in the API Tester can have two scripts:

Send runs the script exactly as it is in the editor, including edits you have not saved yet. Clear empties the active script editor. Choose Save to Collection to keep the request together with its scripts.

Pre-Request Script

JavaScript code that runs before the request is sent. Use it to set dynamic headers, compute signatures, or prepare test data.

Test Script (Post-Response)

JavaScript code that runs after the response is received. Use it to assert response status, validate body fields, or extract values for subsequent requests.

When a run writes environment values with pm.environment.set(...), the change lands in your own selected environment. A shared environment owned by another person is never modified, and an isolated test or load run keeps its script changes inside that run.

Postman-Compatible API

The script editor supports a Postman-compatible pm.* API:

// Environment variables
pm.environment.get("key")       // Read variable
pm.environment.set("key", "v")  // Write variable
pm.environment.has("key")       // Check existence

// Collection variables
pm.collectionVariables.get("key")
pm.collectionVariables.set("key", "value")

// Request info; headers can be changed in pre-request scripts
pm.request.url       // Request URL
pm.request.method    // HTTP method
pm.request.headers   // Headers object
pm.request.body      // Request body

// Response assertions (only in test scripts)
pm.response.code                    // Status code (number)
pm.response.json()                  // Parse response as JSON
pm.response.text()                  // Response as text
pm.response.to.have.status(200)     // Assert status
pm.response.to.have.header("name")  // Assert header exists

// Test assertions
pm.test("Status is 200", function() {
    pm.expect(pm.response.code).to.equal(200);
});

The script editor has syntax highlighting, auto-completion for pm.* methods (press Ctrl+Space), bracket matching, and code folding.

Use Snippets for a ready example, or open the Visual builder to compose requests, variables and assertions from blocks. Selected snippets stay selected while you search. The builder keeps hand-written conditions and, for load scripts, setup, teardown and options. A manual module appears as a code block so editing the surrounding blocks does not discard it. Invalid variable names or stage lines are reported before replacing your editor text.

Set Variable writes a request-scoped value, not a JavaScript variable. For example, after mk.variables.set("myVar", "5"), a Log block with Expression disabled and message ${myVar} prints 5. A JavaScript variable of the same name takes precedence; otherwise a simple ${name} reads request variables, then environment variables, then collection variables. Zero, false, null and an empty string remain valid values; a missing name raises an error. For explicit code or a key such as my-var, use mk.variables.get("my-var") with Expression enabled. Complex ${…} expressions remain JavaScript expressions.

Run a test stored in a collection to use that collection’s variables. Read the assertion results: a script that executes without an exception can still fail a test. Skipped assertions are listed separately. pm.execution.skipRequest() skips the current request and its response scripts; it does not stop the collection. Use pm.execution.setNextRequest(null) to stop the sequence.


API Tester: Import and Export

The API Tester supports importing and exporting collections in multiple formats:

Import

Format Description
Postman Collection (v2.1) Import your existing Postman collections. Variables ({{var}}) are converted automatically.
OpenAPI / Swagger Generate HTTP requests from an OpenAPI spec (URL or file upload).
HAR file Import recorded traffic from Chrome DevTools or other tools.
SoapUI Project Import SoapUI test projects for SOAP testing.
WSDL Generate SOAP requests from a WSDL definition.
cURL Paste one or more cURL commands. Protocol (HTTP, GraphQL, SOAP) is auto-detected. Multiple commands are grouped by protocol into separate collections.

Export

Format Description
Mockarty native Full collection export with all metadata and scripts.
Postman Collection (v2.1) Export as a Postman-compatible collection.

API Tester: Collection Sharing

Collections can be shared with other users:

Sharing choice Who sees the collection
Not shared Only you
Share with space Everyone in the collection’s space
Share with specific users The people you name, with the role you give them

Open Share on the collection to change these settings. Inside a shared collection a person has one role: Viewer (read-only), Editor (can change requests), or Owner (full control, including sharing and deletion).

A collection shared to another space appears there when you select that space. Viewers can inspect, run and export its requests; editors can also change them. The collection stays owned by the space that created it.


Recorder: Saved Configurations

If you frequently record traffic from the same upstream service, save the session configuration for quick reuse:

  1. Set up the session in New (target URL, filters, toxicity rules, modifications), then click Save Config.
  2. Give the config a name (e.g. “Stripe Dev”, “Internal API Staging”).
  3. Next time open the Configs tab and press the play button on the config to start a session with those settings, or the pencil to edit it.

Each config also has Download as JSON and delete actions, and + Import JSON config adds a saved config from another Mockarty instance.

Limit: 10 saved configs.


Recorder: Map Local

Map Local lets you mix real upstream responses with Mockarty mock responses in a single recording session:

  1. In New, expand Map Local (Auto-Responder) and tick Enable Map Local.
  2. Optionally set Override Namespace; otherwise the session’s space is used.
  3. The recorder looks for a matching mock before forwarding to the upstream.
  4. When a mock matches by route and HTTP method, its response is served locally — no network call.
  5. When nothing matches, the request goes to the real upstream as usual.
  6. Both types of entries appear in the session; mock-served entries are labelled mapLocal: true.

Use cases:

  • Stub out a flaky upstream endpoint while testing the rest of the integration.
  • Inject specific error responses for edge-case testing.
  • Gradually replace real upstream calls with mocks.

Recorder: AI Analysis

AI analysis needs an LLM profile (see Admin → AI & LLM). Open a session and choose AI Analyze in the session toolbar:

  • Analyze Traffic — summarize traffic patterns, find anomalies and suggest optimizations.
  • Find Scenarios — identify correlated request sequences and user scenarios.
  • Security Audit — scan recorded traffic for security issues such as sensitive data in URLs or missing auth headers.

Field hints next to each action describe what it looks at. Without a configured profile the panel says AI analysis unavailable: no LLM profile configured.


Templates: Reusable Response Bodies

Open Stores → Templates to keep reusable files: response bodies, OpenAPI specs, fixtures for S3 mocks and files a recorder replay reads.

  • Upload template adds a file. Any text or binary file works, not only JSON: images, XML and HTML are kept as they are.
  • The list can be searched by name and filtered by format.
  • Preview shows a text file; Download saves any file, including a binary one.
  • Edit and Delete manage the stored copy.

Templates belong to the current space. In the Constructor, set the response body type to Template and pick the file in Template File (or press Browse… next to it) instead of writing the body by hand.


See Also