Store Systems in Mockarty
Open Mocking → Variables for global, chain and mock data and response templates. The separate Stores menu opens the prompt templates and secrets available in your space.
Table of Contents
- Store Systems Overview
- Mock Store (MStore)
- Chain Store (CStore)
- Global Store (GStore)
- Store Management API
- Usage Examples
- Best Practices
Tip: Code examples are available for cURL, CLI, and SDK clients (Go, Python, Java). See the SDK Guide for installation and setup. See the CLI User Guide for the command-line tool.
About URLs in examples: All examples use
localhost:5770as the default Mockarty address. If your instance runs on a remote server, replacelocalhost:5770with its actual address (e.g.https://mockarty.company.comorhttp://192.168.1.50:5770). See Tips & Useful Features for details.
Store Systems Overview
Key Concepts for Beginners
Before diving into Store systems, here are a few key terms:
- Mock – a simulated API endpoint that returns predefined responses instead of calling a real service.
- Namespace – a logical grouping of mocks (like a folder). Mocks in different namespaces are isolated from each other.
- Chain – a sequence of related mocks that share state. For example, “create order” -> “pay for order” -> “ship order” form a chain.
- Extract – the process of pulling data from a request (or generating data) and saving it into a store for later use.
- JsonPath – a query language (like
$.mS.userId) used to reference stored values in mock responses.
File templates in the UI
Open Mocking → Variables → Templates to upload, preview, download, edit or delete a file in the selected namespace. A failed list read shows an error and Retry; filtering does not replace it with an empty list. Closing a preview or opening another file prevents a late response from replacing the current file. Text editing is temporarily unavailable while saving. Switching namespace closes the preview and retires pending deletion confirmations. An upload or save already sent may still complete: check the list before repeating it after a connection problem.
When to Use Which Store
Not sure which store to pick? Use this simple decision guide:
- Mock Store (mS) – Use when you need temporary data within a single mock call. Example: generate a UUID and use it in multiple places in the same response. Data disappears after the request is processed.
- Chain Store (cS) – Use when you need to share data between related mocks that form a workflow. Example: a user registration flow where the registration mock saves a userId, and the profile mock reads it. Data persists across calls within the same chain.
- Global Store (gS) – Use when you need shared state across all mocks in a namespace. Example: request counters, feature flags, or system configuration. Data persists indefinitely until explicitly cleared.
Global Store values are retained between Desktop launches. After restarting Desktop, open Mocking → Variables → Global Store and select the namespace whose saved values you want to view.
Store Concept
Store is a data storage system in Mockarty that allows you to:
- Save data between mock invocations
- Share data between related mocks
- Accumulate state for complex scenarios
- Create dynamic responses based on accumulated data using JsonPath and Faker
Store Architecture
graph TB
subgraph "Store Hierarchy"
MSTORE["Mock Store (mS)"]
CSTORE["Chain Store (cS)"]
GSTORE["Global Store (gS)"]
end
subgraph "Scope"
MOCK_SCOPE["Single Mock"]
CHAIN_SCOPE["Chain of Mocks"]
GLOBAL_SCOPE["All Mocks in Namespace"]
end
subgraph "Persistence"
SESSION["Ephemeral (request only)"]
PERMANENT["Persistent (database)"]
NAMESPACE_ISOLATED["Persistent + Namespace Isolated"]
end
MSTORE --> MOCK_SCOPE
CSTORE --> CHAIN_SCOPE
GSTORE --> GLOBAL_SCOPE
MSTORE --> SESSION
CSTORE --> PERMANENT
GSTORE --> NAMESPACE_ISOLATED
classDef store fill:#4a90d9,stroke:#2c5f8a,color:#fff
classDef scope fill:#8e6fbf,stroke:#5e4590,color:#fff
classDef persistence fill:#5aad6e,stroke:#3a7d4e,color:#fff
class MSTORE,CSTORE,GSTORE store
class MOCK_SCOPE,CHAIN_SCOPE,GLOBAL_SCOPE scope
class SESSION,PERMANENT,NAMESPACE_ISOLATED persistence
Store Type Comparison
| Store Type | Scope | Lifetime | Namespace | JsonPath Access |
|---|---|---|---|---|
| MStore | Local mock | During mock processing | N/A | $.mS.key |
| CStore | All mocks in Chain | Permanent | Yes | $.cS.key |
| GStore | All mocks in Namespace | Permanent | Yes | $.gS.key |
Store Management UI
The Variables page in the Mockarty web UI provides a visual interface for viewing and managing all three store types. Use the tabs at the top to switch between Global Store, Chain Store, and Mock Store.
On the Mock Store tab, use Choose a mock to search by name. Scroll the results or use the arrow keys and Enter to choose an active mock in the current Space. Archived mocks are excluded.
On the Global Store and Chain Store tabs, use the edit and delete buttons at the end of each row.

Note: Mock Store values are available in the same response. Chain and Global Store writes are performed asynchronously, so a value saved by one request may not be visible to a request that arrives at the same moment; read it on a later call.
Mock Store (MStore)
What is Mock Store?
Mock Store (MStore) is a local data storage for a specific mock, available only during the processing of that mock.

Features:
- Isolation – data is accessible only within a specific mock
- Ephemeral – data exists only during request processing
- Fast – stored in mock memory
- Simple – does not require namespace or chainId management
Using MStore
Extracting to MStore
An extract rule saves a value taken from the request. It can read the JSON body ($.req.*), query parameters ($.queryParams.*) and headers ($.headers.<name>; use a header name without hyphens). It does not generate data, so a Faker, math or literal value written in an extract rule saves nothing — generate such a value directly in the response instead.
{
"id": "user-create",
"http": {
"route": "/api/users",
"httpMethod": "POST"
},
"response": {
"payload": {
"id": "$.fake.UUIDDigit",
"name": "$.mS.userName",
"email": "$.mS.userEmail",
"welcomeMessage": "Hello, $.mS.userName!"
}
},
"extract": {
"mStore": {
"userName": "$.req.name",
"userEmail": "$.req.email"
}
}
}
Accessing MStore in the Response
{
"response": {
"payload": {
"userId": "$.mS.userId",
"processedAt": "$.mS.requestTime",
"metadata": {
"userName": "$.mS.userName",
"userEmail": "$.mS.userEmail"
}
}
}
}
Typical MStore Use Cases
-
Reusing one request value in several response fields:
"extract": { "mStore": { "userName": "$.req.name" } }Then write
$.mS.userNamewherever the name is needed. -
Reading request metadata:
"extract": { "mStore": { "traceId": "$.req.traceId", "clientVersion": "$.queryParams.v" } } -
Keeping calculations readable. Calculate in the response, where math functions are available, and read request values through the extract:
"response": { "payload": { "basePrice": "$.mS.basePrice", "tax": "$.multiply($.mS.basePrice, 0.2)", "totalPrice": "$.sum($.mS.basePrice, $.multiply($.mS.basePrice, 0.2))" } }, "extract": { "mStore": { "basePrice": "$.req.price" } }
Chain Store (CStore)
What is Chain Store?
Chain Store (CStore) is a shared data storage across all mocks with the same chainId within a single namespace.

Features:
- Shared – data is accessible to all mocks in the chain
- Persistent – data is preserved between invocations
- Namespace isolation – data is isolated by namespace
- Accumulation – data accumulates as the chain progresses
CStore Lifecycle
sequenceDiagram
participant M1 as Mock 1
participant CS as Chain Store
participant M2 as Mock 2
participant M3 as Mock 3
M1->>CS: Extract data (step 1)
CS-->>M1: Store updated
M2->>CS: Read data from step 1
CS-->>M2: Return step 1 data
M2->>CS: Extract additional data (step 2)
CS-->>M2: Store updated
M3->>CS: Read data from steps 1 & 2
CS-->>M3: Return accumulated data
M3->>CS: Extract final data (step 3)
CS-->>M3: Store updated (complete)
Using CStore
Initial Mock in the Chain
{
"id": "order-start",
"chainId": "order-processing",
"namespace": "e-commerce",
"http": {
"route": "/api/orders/create",
"httpMethod": "POST"
},
"response": {
"payload": {
"orderId": "$.cS.orderId",
"status": "created",
"items": "$.cS.items"
}
},
"extract": {
"cStore": {
"orderId": "$.req.orderId",
"customerId": "$.req.customerId",
"items": "$.req.items",
"totalAmount": "$.req.totalAmount",
"currentStep": "$.req.step"
}
}
}
Intermediate Mock in the Chain
{
"id": "order-payment",
"chainId": "order-processing",
"namespace": "e-commerce",
"http": {
"route": "/api/orders/payment",
"httpMethod": "POST"
},
"response": {
"payload": {
"orderId": "$.cS.orderId",
"customerId": "$.cS.customerId",
"amount": "$.cS.totalAmount",
"paymentId": "$.req.paymentId",
"status": "paid"
}
},
"extract": {
"cStore": {
"paymentId": "$.req.paymentId",
"paidAt": "$.req.paidAt",
"paymentMethod": "$.req.paymentMethod",
"currentStep": "$.req.step"
}
}
}
Final Mock in the Chain
{
"id": "order-fulfill",
"chainId": "order-processing",
"namespace": "e-commerce",
"http": {
"route": "/api/orders/fulfill",
"httpMethod": "POST"
},
"response": {
"payload": {
"orderId": "$.cS.orderId",
"customerId": "$.cS.customerId",
"paymentId": "$.cS.paymentId",
"trackingNumber": "$.req.trackingNumber",
"estimatedDelivery": "$.req.estimatedDelivery",
"orderSummary": {
"items": "$.cS.items",
"totalAmount": "$.cS.totalAmount",
"paidAt": "$.cS.paidAt",
"fulfilledAt": "$.req.fulfilledAt"
}
}
},
"extract": {
"cStore": {
"trackingNumber": "$.req.trackingNumber",
"fulfilledAt": "$.req.fulfilledAt",
"currentStep": "$.req.step"
}
}
}
Chain Store API
Finding a chain
The Chain ID fields (the Stores page, “Create mocks” from undefined requests, a temporal probe’s store scope) suggest the chains of your namespace as you type — every chain used by a mock or holding store keys, with how many mocks share it and how many keys it holds. The same list over the API:
GET /api/v1/stores/chains?namespace=e-commerce&q=order
{"items":[{"chainId":"order-processing","mockCount":3,"storeKeys":5}]}
Retrieving Chain Store Data
GET /api/v1/stores/chain/{chainId}?namespace=e-commerce
Adding Data to Chain Store
Each request adds a single key-value pair. To add multiple entries, make separate requests for each key.
POST /api/v1/stores/chain/order-processing
Content-Type: application/json
{
"key": "manualStep",
"value": "admin-review",
"namespace": "e-commerce"
}
Deleting Data from Chain Store
Delete a single key by specifying it in the URL path:
DELETE /api/v1/stores/chain/order-processing/temporaryData?namespace=e-commerce
Global Store (GStore)
What is Global Store?
Global Store (GStore) is a global data storage accessible to all mocks within a single namespace.

Features:
- Global – data is accessible to all mocks in the namespace
- Persistent – data is preserved across all invocations
- Namespace isolation – data is isolated by namespace
- Accumulation – ideal for counters and statistics
Using GStore
Counters and Statistics
$.increment both returns the next value and updates the Global Store, so counters belong in the response. An extract rule can only copy a value from the request.
{
"id": "api-request-counter",
"namespace": "monitoring",
"http": {
"route": "/api/*"
},
"response": {
"payload": {
"requestId": "$.fake.UUID",
"timestamp": "$.fake.RFC3339",
"stats": {
"totalRequests": "$.increment($.gS.totalRequests || 0)",
"todayRequests": "$.increment($.gS.todayRequests || 0)",
"lastUserID": "$.gS.lastUserID"
}
}
},
"extract": {
"gStore": {
"lastUserID": "$.req.userId"
}
}
}
System Configuration
Save the values first in Mocking → Variables → Global Store, or through the store API, then read them in the response:
{
"id": "system-config",
"namespace": "system",
"http": {
"route": "/api/config"
},
"response": {
"payload": {
"config": {
"version": "$.gS.systemVersion",
"maintenanceMode": "$.gS.maintenanceMode",
"lastUpdated": "$.gS.configLastUpdated"
},
"configAccessed": "$.increment($.gS.configAccessed || 0)"
}
},
"extract": {
"gStore": {
"lastCaller": "$.req.userId"
}
}
}
Feature Flags
{
"id": "feature-toggle",
"namespace": "features",
"http": {
"route": "/api/features/status"
},
"response": {
"payload": {
"feature": "$.req.featureName",
"enabled": "$.gS.newDashboardEnabled",
"rolloutPercentage": "$.gS.newDashboardRollout",
"accessCount": "$.increment($.gS.featureAccessCount || 0)"
}
},
"extract": {
"gStore": {
"lastFeatureUser": "$.req.userId"
}
}
}
A whole object or array can be stored when the extract copies it from the request in one rule, for example "profile": "$.req.profile". You cannot build an object out of several keys inside the extract rule.
Global Store API
Retrieving Global Store Data
GET /api/v1/stores/global?namespace=monitoring
Adding Data to Global Store
Each request adds a single key-value pair. To add multiple entries, make separate requests for each key.
POST /api/v1/stores/global
Content-Type: application/json
{
"key": "systemVersion",
"value": "1.2.3",
"namespace": "monitoring"
}
Deleting Data from Global Store
Delete a single key by specifying it in the URL path:
DELETE /api/v1/stores/global/oldConfig?namespace=monitoring
Store Management API
Full API Reference
For the complete API documentation, see the API Reference.
Global Store Endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/v1/stores/global |
Get Global Store |
| POST | /api/v1/stores/global |
Add a key-value pair to Global Store |
| DELETE | /api/v1/stores/global/{key} |
Delete a key from Global Store |
Query Parameters:
namespace(optional) – namespace (default: “sandbox”)
POST Body: {"key": "...", "value": "...", "namespace": "..."}
Chain Store Endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/v1/stores/chain/{chainId} |
Get Chain Store |
| GET | /api/v1/stores/chains |
List the namespace’s chains (q filters by id) |
| POST | /api/v1/stores/chain/{chainId} |
Add a key-value pair to Chain Store |
| DELETE | /api/v1/stores/chain/{chainId}/{key} |
Delete a key from Chain Store |
Path Parameters:
chainId– chain IDkey– key to delete (for DELETE only)
Query Parameters:
namespace(optional) – namespace (default: “sandbox”)
POST Body: {"key": "...", "value": "...", "namespace": "..."}
API Call Examples
Adding to Global Store
Each API call adds a single key-value pair. Make multiple calls to set multiple keys.
cURL
# Add a key-value pair to Global Store
curl -X POST http://localhost:5770/api/v1/stores/global \
-H "Content-Type: application/json" \
-d '{"key": "appVersion", "value": "1.0.0", "namespace": "testing"}'
# Add another key
curl -X POST http://localhost:5770/api/v1/stores/global \
-H "Content-Type: application/json" \
-d '{"key": "environment", "value": "testing", "namespace": "testing"}'
CLI
mockarty-cli store global set --namespace testing appVersion "1.0.0"
mockarty-cli store global set --namespace testing environment "testing"
Go
import mockarty "github.com/mockarty/go-sdk"
client := mockarty.NewClient("http://localhost:5770", "YOUR_TOKEN")
// Namespace is configured on the client (mockarty.WithNamespace("testing"))
err := client.Stores().GlobalSet(ctx, "appVersion", "1.0.0")
err = client.Stores().GlobalSet(ctx, "environment", "testing")
Python
from mockarty import MockartyClient
client = MockartyClient("http://localhost:5770", token="YOUR_TOKEN")
# Namespace is configured on the client (MockartyClient(..., namespace="testing"))
client.stores.global_set(key="appVersion", value="1.0.0")
client.stores.global_set(key="environment", value="testing")
Java
import ru.mockarty.MockartyClient;
MockartyClient client = new MockartyClient("http://localhost:5770", "YOUR_TOKEN");
client.stores().globalSet("testing", "appVersion", "1.0.0");
client.stores().globalSet("testing", "environment", "testing");
Adding to Chain Store
cURL
curl -X POST http://localhost:5770/api/v1/stores/chain/user-journey \
-H "Content-Type: application/json" \
-d '{"key": "journeyStarted", "value": "true", "namespace": "testing"}'
curl -X POST http://localhost:5770/api/v1/stores/chain/user-journey \
-H "Content-Type: application/json" \
-d '{"key": "startTime", "value": "2024-01-01T10:00:00Z", "namespace": "testing"}'
CLI
mockarty-cli store chain set --namespace testing user-journey journeyStarted "true"
mockarty-cli store chain set --namespace testing user-journey startTime "2024-01-01T10:00:00Z"
Go
err := client.Stores().ChainSet(ctx, "user-journey", "journeyStarted", "true")
err = client.Stores().ChainSet(ctx, "user-journey", "startTime", "2024-01-01T10:00:00Z")
Python
client.stores.chain_set(chain_id="user-journey", key="journeyStarted", value="true")
client.stores.chain_set(chain_id="user-journey", key="startTime", value="2024-01-01T10:00:00Z")
Java
client.stores().chainSet("user-journey", "testing", "journeyStarted", "true");
client.stores().chainSet("user-journey", "testing", "startTime", "2024-01-01T10:00:00Z");
Deleting Store Data
Delete one key at a time by specifying it in the URL path.
cURL
# Delete a key from Global Store
curl -X DELETE http://localhost:5770/api/v1/stores/global/tempData?namespace=testing
# Delete a key from Chain Store
curl -X DELETE http://localhost:5770/api/v1/stores/chain/user-journey/debugData?namespace=testing
CLI
# Delete a key from Global Store
mockarty-cli store global delete --namespace testing tempData
# Delete a key from Chain Store
mockarty-cli store chain delete --namespace testing user-journey debugData
Go
// Delete a key from Global Store
err := client.Stores().GlobalDelete(ctx, "tempData")
// Delete a key from Chain Store
err = client.Stores().ChainDelete(ctx, "user-journey", "debugData")
Python
# Delete a key from Global Store
client.stores.global_delete(key="tempData")
# Delete a key from Chain Store
client.stores.chain_delete(chain_id="user-journey", key="debugData")
Java
// Delete a key from Global Store
client.stores().globalDelete("testing", "tempData");
// Delete a key from Chain Store
client.stores().chainDelete("user-journey", "testing", "debugData");
Usage Examples
The sections above already show basic patterns for each store type – counters, configuration, and chain workflows. The examples below demonstrate more advanced scenarios that combine multiple store types or show cross-store interaction.
Complex Chain Scenarios
Multi-step Workflow
{
"id": "workflow-step-1",
"chainId": "approval-workflow",
"namespace": "workflows",
"http": {
"route": "/api/workflow/submit",
"httpMethod": "POST"
},
"response": {
"payload": {
"workflowId": "$.cS.workflowId",
"status": "submitted",
"submittedBy": "$.req.userId",
"nextStep": "manager-review"
}
},
"extract": {
"cStore": {
"workflowId": "$.req.workflowId",
"submittedBy": "$.req.userId",
"submittedAt": "$.req.submittedAt",
"currentStep": "$.req.step",
"approvalChain": "$.req.approvalChain"
}
}
}
{
"id": "workflow-step-2",
"chainId": "approval-workflow",
"namespace": "workflows",
"http": {
"route": "/api/workflow/approve",
"httpMethod": "POST"
},
"response": {
"payload": {
"workflowId": "$.cS.workflowId",
"approvedBy": "$.req.approverId",
"currentStep": "manager-approved",
"nextStep": "director-review",
"progress": {
"submittedBy": "$.cS.submittedBy",
"submittedAt": "$.cS.submittedAt",
"percentage": 33
}
}
},
"extract": {
"cStore": {
"managerApprovedBy": "$.req.approverId",
"managerApprovedAt": "$.req.approvedAt",
"currentStep": "$.req.step"
}
}
}
Experiment Tracking with Stores
Tracking Experiment Assignments
{
"id": "experiment-tracker",
"namespace": "experiments",
"http": {
"route": "/api/experiment/assign",
"httpMethod": "POST"
},
"response": {
"payload": {
"userId": "$.req.userId",
"experiment": "new-checkout-flow",
"variant": "$.req.variant",
"assignedAt": "$.fake.RFC3339",
"totalAssignments": "$.increment($.gS.totalAssignments || 0)"
}
},
"extract": {
"gStore": {
"lastAssignedUser": "$.req.userId",
"lastAssignedVariant": "$.req.variant"
}
}
}
Best Practices
Recommendations
-
Use the right Store type for the task:
- MStore – for temporary computations within a mock
- CStore – for passing data between scenario steps
- GStore – for global counters and configuration
-
Structure data in Stores: keep one key per value, and copy a whole object from the request when you need a group:
"response": { "payload": { "totalUsers": "$.increment($.gS.totalUsers || 0)", "lastProfile": "$.gS.lastProfile" } }, "extract": { "gStore": { "lastProfile": "$.req.profile" } } -
Use meaningful keys (inside a response payload):
Good – descriptive key name that explains what is being counted:
"userRegistrationCount": "$.increment($.gS.userRegistrationCount || 0)"Bad – generic key name that does not convey meaning:
"count": "$.increment($.gS.count || 0)" -
Initialize default values:
With default (recommended) – uses
|| 0to start from zero if key does not exist. Put the counter in the response, where$.incrementruns:"response": { "payload": { "totalUsers": "$.increment($.gS.totalUsers || 0)" } }Without default (risky) – the first call has no number to increment:
"totalUsers": "$.increment($.gS.totalUsers)" -
Group related data by copying one object from the request:
"extract": { "cStore": { "order": "$.req.order", "customer": "$.req.customer" } }The response can then read nested fields, for example
$.cS.order.idor$.cS.customer.email.
Things to Avoid
- Do not store sensitive data in Stores (passwords, tokens)
- Do not create overly deep nesting (more than 3 levels)
- Do not forget about namespace isolation
- Do not use Stores for simple static responses
- Do not overload Stores with large data objects
Data Management
Cleaning Up Stale Data
An extract rule cannot delete a key: a null entry is simply skipped. Remove Global Store keys in Mocking → Variables → Global Store (the delete button on the row) or over the API:
curl -X DELETE "http://localhost:5770/api/v1/stores/global/tempData?namespace=maintenance" \
-H "X-API-Key: $MOCKARTY_API_TOKEN"
Archiving Data
A mock cannot copy a value from one store key to another. Read the value in a response (or over the store API), then save it under the new key yourself; removing the old key is a separate delete:
{
"id": "archive-data",
"http": {
"route": "/api/archive"
},
"response": {
"payload": {
"archivedData": "$.gS.currentData"
}
}
}
Use Store systems to create powerful dynamic scenarios with state preservation!
See Also
- JsonPath Guide – query language for accessing and manipulating Store data
- Faker Reference – generate random data to populate Stores
- API Reference – complete REST API for Store management endpoints
- Web UI Guide – manage Stores visually through the web interface
- Webhooks & Callbacks – use Store data in webhook payloads