Docs API Reference

API Reference

Complete REST API reference for Mockarty. Base URL: http://localhost:5770 (default).

All request/response bodies use Content-Type: application/json unless noted otherwise.

About URLs in examples: All examples use localhost:5770 as the default address. If your Mockarty instance is deployed on a remote server (e.g. https://mockarty.company.com or http://192.168.1.50:5770), replace localhost:5770 with the actual address. SDKs accept the base URL in the client constructor, so you only set it once. See the Quick Start Guide for a full table of deployment scenarios.

Tip: All examples below are available in multiple languages. Use the tabs to switch between cURL, CLI, and SDK clients. For SDK installation and detailed usage, see the SDK Guide. For CLI tool documentation, see the CLI User Guide.

Hello World: Your First Mock in 30 Seconds

Create a mock and call it – two commands, no configuration needed:

cURL

# 1. Create a mock
curl -X POST http://localhost:5770/api/v1/mocks \
  -H "Content-Type: application/json" \
  -d '{
    "id": "hello-world",
    "namespace": "sandbox",
    "http": {
      "route": "/api/greeting",
      "httpMethod": "GET"
    },
    "response": {
      "statusCode": 200,
      "payload": {
        "message": "Hello, World!",
        "timestamp": "$.fake.DateTimeISO"
      }
    }
  }'

# 2. Call the mock (namespace is part of the URL)
curl http://localhost:5770/stubs/sandbox/api/greeting
# Returns: {"message": "Hello, World!", "timestamp": "2026-03-22T10:30:00Z"}

CLI

# Install: https://github.com/mockarty/releases

# 1. Create a mock (namespace defaults to "sandbox")
mockarty-cli mock create \
  --id hello-world \
  --route /api/greeting \
  --method GET \
  --status 200 \
  --body '{"message": "Hello, World!", "timestamp": "$.fake.DateTimeISO"}'

# 2. Call the mock — namespace is always part of the URL
curl http://localhost:5770/stubs/sandbox/api/greeting

Go

// go get github.com/mockarty/mockarty-go

package main

import (
	"context"
	"fmt"
	"github.com/mockarty/mockarty-go"
)

func main() {
	// Namespace defaults to "sandbox"
	client := mockarty.NewClient("http://localhost:5770",
		mockarty.WithAPIKey("mk_YOUR_TOKEN"),
	)

	mock := mockarty.NewMockBuilder().
		ID("hello-world").
		HTTP(func(h *mockarty.HTTPBuilder) {
			h.Route("/api/greeting").Method("GET")
		}).
		Response(func(r *mockarty.ResponseBuilder) {
			r.Status(200).JSONBody(map[string]any{
				"message":   "Hello, World!",
				"timestamp": "$.fake.DateTimeISO",
			})
		}).
		Build()

	resp, err := client.Mocks().Create(context.Background(), mock)
	if err != nil {
		panic(err)
	}
	fmt.Printf("Created: %s (overwritten: %v)\n", resp.Mock.ID, resp.Overwritten)
}

Python

# pip install mockarty

from mockarty import MockartyClient
from mockarty.builders import MockBuilder

# Namespace defaults to "sandbox"
client = MockartyClient(
    base_url="http://localhost:5770",
    api_key="mk_YOUR_TOKEN",
)

mock = (
    MockBuilder.http("/api/greeting", "GET")
    .id("hello-world")
    .respond(200, body={
        "message": "Hello, World!",
        "timestamp": "$.fake.DateTimeISO",
    })
    .build()
)

result = client.mocks.create(mock)
print(f"Created: {result.mock.id}, overwritten: {result.overwritten}")

Java

// Gradle: implementation "ru.mockarty:mockarty-java:1.0.0"

import ru.mockarty.MockartyClient;
import ru.mockarty.builder.MockBuilder;
import ru.mockarty.model.Mock;
import ru.mockarty.model.SaveMockResponse;
import java.util.Map;

// Namespace defaults to "sandbox"
try (MockartyClient client = MockartyClient.builder()
        .baseUrl("http://localhost:5770")
        .apiKey("mk_YOUR_TOKEN")
        .build()) {

    Mock mock = MockBuilder.http("/api/greeting", "GET")
        .id("hello-world")
        .respond(200, Map.of(
            "message", "Hello, World!",
            "timestamp", "$.fake.DateTimeISO"
        ))
        .build();

    SaveMockResponse resp = client.mocks().create(mock);
    System.out.println("Created: " + resp.getMock().getId());
}

Kotlin

// Gradle: implementation("ru.mockarty:mockarty-kotlin:1.0.0")

import ru.mockarty.MockartyClient
import ru.mockarty.dsl.createMock

// Namespace defaults to "sandbox"
val client = MockartyClient.builder()
    .baseUrl("http://localhost:5770")
    .apiKey("mk_YOUR_TOKEN")
    .build()

client.createMock {
    id = "hello-world"
    http {
        route = "/api/greeting"
        method = "GET"
    }
    respond {
        statusCode = 200
        body = mapOf(
            "message" to "Hello, World!",
            "timestamp" to "$.fake.DateTimeISO"
        )
    }
}

How it works: You define a mock via POST /api/v1/mocks, then Mockarty serves it at /stubs/<namespace>/<your-route>. The /stubs prefix tells Mockarty to resolve a mock instead of calling its management API. Dynamic values like $.fake.DateTimeISO are replaced at response time.

Mock Creation via API


Table of Contents

  1. Authentication
  2. Mock Management API (Public)
  3. Namespace API
  4. Store API
  5. Template API
  6. CI/CD Integration Guide
  7. API Tester API
  8. Performance Testing API
  9. Fuzzing API
  10. Recorder API
  11. Contract Testing API
  12. Chaos Engineering API
  13. Admin API
  14. Utility Endpoints
  15. Protocol Proxy Endpoints

1. Authentication

Mockarty uses two authentication mechanisms: API tokens for programmatic access and session cookies for the Web UI.

API Tokens

Create tokens in the Web UI (Settings > API Tokens) or via POST /api/v1/auth/tokens.

Include the token in requests using either header:

cURL

# X-API-Key header (namespace "sandbox" is the default)
curl -H "X-API-Key: mk_YOUR_TOKEN" http://localhost:5770/api/v1/mocks

# Authorization: Bearer header
curl -H "Authorization: Bearer mk_YOUR_TOKEN" http://localhost:5770/api/v1/mocks

CLI

# Configure token globally (saved to ~/.mockarty-cli/config.yaml)
mockarty-cli config set token mk_YOUR_TOKEN
mockarty-cli config set namespace sandbox

# Or pass per-command
mockarty-cli mock list --token mk_YOUR_TOKEN

Go

// Token is set via WithAPIKey option; namespace defaults to "sandbox"
client := mockarty.NewClient("http://localhost:5770",
    mockarty.WithAPIKey("mk_YOUR_TOKEN"),
    mockarty.WithNamespace("sandbox"), // optional, "sandbox" is the default
)

Python

# Token is set via api_key parameter; namespace defaults to "sandbox"
client = MockartyClient(
    base_url="http://localhost:5770",
    api_key="mk_YOUR_TOKEN",
    namespace="sandbox",  # optional, "sandbox" is the default
)

Java

// Token is set via apiKey; namespace defaults to "sandbox"
MockartyClient client = MockartyClient.builder()
    .baseUrl("http://localhost:5770")
    .apiKey("mk_YOUR_TOKEN")
    .namespace("sandbox")  // optional, "sandbox" is the default
    .build();

Kotlin

// Token is set via apiKey; namespace defaults to "sandbox"
val client = MockartyClient.builder()
    .baseUrl("http://localhost:5770")
    .apiKey("mk_YOUR_TOKEN")
    .namespace("sandbox")  // optional, "sandbox" is the default
    .build()

Session Authentication

For Web UI and browser-based access:

# Login (returns session cookie)
curl -c cookies.txt -X POST http://localhost:5770/api/v1/auth/login \
  -d '{"username": "admin", "password": "secret"}'

# Use session cookie
curl -b cookies.txt http://localhost:5770/api/v1/mocks

Auth Endpoints

Method Path Auth Description
POST /api/v1/auth/login none Login with username/password
POST /api/v1/auth/logout user End session
GET /api/v1/auth/me user Get current user info
POST /api/v1/auth/change-password user Change own password
POST /api/v1/auth/tokens user Create API token
GET /api/v1/auth/tokens user List own API tokens
GET /api/v1/auth/tokens/:id user Get token details
PATCH /api/v1/auth/tokens/:id user Update token (name, expiration)
DELETE /api/v1/auth/tokens/:id user Revoke token
POST /api/v1/auth/ldap/login none Login via LDAP
GET /api/v1/auth/oauth/login/:provider none Start OAuth flow
POST /api/v1/auth/forgot-password none Request password reset email
GET /api/v1/auth/verify-email none Verify email address

Rate Limiting

API requests are rate-limited based on your license tier. Token-based rate limiting applies per API key.


2. Mock Management API (Public)

Mock Management API

These endpoints manage mock definitions. Available at the server root (port 5770). Require authentication with read or write permission.

Create/Update Mock

POST /api/v1/mocks | Auth: user (write)

Creates a new mock or overwrites an existing one (matched by id).

cURL

curl -X POST http://localhost:5770/api/v1/mocks \
  -H "X-API-Key: mk_YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "id": "get-user",
    "namespace": "sandbox",
    "http": {
      "route": "/api/users/list",
      "httpMethod": "GET"
    },
    "response": {
      "statusCode": 200,
      "payload": {
        "id": "$.fake.UUID",
        "name": "$.fake.FirstName",
        "email": "$.fake.Email"
      }
    }
  }'

CLI

# Namespace defaults to "sandbox"
mockarty-cli mock create \
  --id get-user \
  --route /api/users/list \
  --method GET \
  --status 200 \
  --body '{"id": "$.fake.UUID", "name": "$.fake.FirstName", "email": "$.fake.Email"}'

Go

mock := mockarty.NewMockBuilder().
    ID("get-user").
    Namespace("sandbox"). // optional, "sandbox" is the default
    HTTP(func(h *mockarty.HTTPBuilder) {
        h.Route("/api/users/list").Method("GET")
    }).
    Response(func(r *mockarty.ResponseBuilder) {
        r.Status(200).JSONBody(map[string]any{
            "id":    "$.fake.UUID",
            "name":  "$.fake.FirstName",
            "email": "$.fake.Email",
        })
    }).
    Build()

resp, err := client.Mocks().Create(context.Background(), mock)

Python

mock = (
    MockBuilder.http("/api/users/list", "GET")
    .id("get-user")
    .namespace("sandbox")  # optional, "sandbox" is the default
    .respond(200, body={
        "id": "$.fake.UUID",
        "name": "$.fake.FirstName",
        "email": "$.fake.Email",
    })
    .build()
)

result = client.mocks.create(mock)

Java

Mock mock = MockBuilder.http("/api/users/list", "GET")
    .id("get-user")
    .namespace("sandbox")  // optional, "sandbox" is the default
    .respond(200, Map.of(
        "id", "$.fake.UUID",
        "name", "$.fake.FirstName",
        "email", "$.fake.Email"
    ))
    .build();

SaveMockResponse resp = client.mocks().create(mock);

Kotlin

client.createMock {
    id = "get-user"
    namespace = "sandbox"  // optional, "sandbox" is the default
    http {
        route = "/api/users/list"
        method = "GET"
    }
    respond {
        statusCode = 200
        body = mapOf(
            "id" to "$.fake.UUID",
            "name" to "$.fake.FirstName",
            "email" to "$.fake.Email"
        )
    }
}

Response:

{
  "overwritten": false,
  "mock": {
    "id": "get-user",
    "namespace": "sandbox",
    "createdAt": 1704096000000,
    "useCounter": 0
  }
}

Full mock structure (all fields optional except id):

Field Type Description
id string Unique mock ID
namespace string Namespace (default: “default”)
chainId string Chain ID for linked mocks
priority int64 Higher priority mocks match first (default: 0)
ttl int64 Time-to-live in milliseconds (0 = unlimited)
useLimiter int32 Max usage count (0 = unlimited)
http object HTTP route config (route, httpMethod, conditions, queryParams, header)
grpc object gRPC config (service, method, conditions, meta)
mcp object MCP config (serverName, tool, conditions)
soap object SOAP config (soapAction, route)
graphql object GraphQL config (field, operation)
smtp object SMTP config (serverName, senderConditions, recipientConditions, subjectConditions, bodyConditions, headerConditions)
socket object WebSocket/TCP/UDP config (socketType, serverName, event)
kafka object Kafka config (topic, serverName)
rabbitmq object RabbitMQ config (queue, serverName)
sse object SSE config (route, serverName)
response object Response: statusCode, payload, headers, delay, payloadTemplatePath
oneOf object Multiple responses: order (“order”/“random”), responses array
proxy object Proxy mode: target URL
webhooks array Webhook callbacks triggered on mock match (see Webhooks & Callbacks)
tags array String tags for categorizing and filtering mocks
folderId string Folder ID for hierarchical mock organization
pathPrefix string Unified path prefix for native protocols (HTTP, SOAP, MCP, SSE, GraphQL)
serverName string Server name for grouping mocks by environment (e.g., test, stage, prod) – used by Socket and gRPC
mStore object Mock Store – ephemeral key-value data available only during this mock’s processing
extract object Data extraction: mStore, cStore, gStore

Condition Structure

What are conditions? Conditions let you return different mock responses depending on the incoming request. Without conditions, a mock matches any request to its route. With conditions, Mockarty inspects the request body, headers, or query parameters and only selects the mock if all conditions pass. This is useful when multiple mocks share the same route but should respond differently based on the request content (e.g., return an error when $.body.status equals "invalid").

The conditions array inside http, grpc, and mcp config objects controls when a mock is selected. Each condition is an object with the following fields:

Field Type Required Description
path string Yes The path expression to evaluate (e.g., $.body.user.role, header name, query param name)
assertAction string Yes The comparison operation (see table below)
value any Depends The expected value to compare against. Required for equals, contains, not_equals, not_contains, matches. Ignored for any, notEmpty, empty.
decode string No Set to "base64" to base64-decode the extracted value before comparison. Useful when the request contains base64-encoded fields.
sortArray bool No Sort arrays before comparison. Overrides the global sortArray flag on the protocol config object for this specific condition.
valueFromFile string No Path to a file whose content is used as the condition value instead of value. The path supports template processing ($.fake.*, store references). Takes precedence over value when set.

Assert actions:

Assert Action Description Value Required
equals Exact match (deep equality for objects/arrays) Yes
contains Substring match for strings, subset check for objects, element presence for arrays Yes
not_equals Not equal to value Yes
not_contains Does not contain substring or subset Yes
matches Regex pattern match against string value Yes (regex pattern)
any Always matches (ignores value) No
notEmpty Value exists and is not empty (non-null, non-empty string/array/object) No
empty Value is empty or null ("", [], {}, or null) No

Note: The legacy alias match is also accepted and behaves identically to matches.

Example with advanced condition fields:

{
  "id": "base64-body-mock",
  "http": {
    "route": "/api/validate",
    "httpMethod": "POST",
    "conditions": [
      {
        "path": "$.body.encodedData",
        "assertAction": "contains",
        "value": "expected-content",
        "decode": "base64"
      },
      {
        "path": "$.body.items",
        "assertAction": "equals",
        "value": ["b", "a", "c"],
        "sortArray": true
      },
      {
        "path": "$.body.payload",
        "assertAction": "equals",
        "valueFromFile": "/templates/expected-payload.json"
      }
    ]
  },
  "response": {
    "statusCode": 200,
    "payload": {"status": "validated"}
  }
}

Note: decode, sortArray, and valueFromFile are API-only fields – they are not exposed in the web UI constructor.

Get Mock

GET /api/v1/mocks/:id | Auth: user (read)

cURL

curl -H "X-API-Key: mk_YOUR_TOKEN" http://localhost:5770/api/v1/mocks/get-user

CLI

mockarty-cli mock get get-user

Go

mock, err := client.Mocks().Get(context.Background(), "get-user")

Python

mock = client.mocks.get("get-user")

Java

Mock mock = client.mocks().get("get-user");

Kotlin

val mock = client.mocks().get("get-user")

List Mocks

GET /api/v1/mocks | Auth: user (read)

Query Param Type Description
offset int Pagination offset (default: 0)
limit int Page size (default: 50)
namespace string Filter by namespace

cURL

# Namespace "sandbox" is the default
curl -H "X-API-Key: mk_YOUR_TOKEN" \
  "http://localhost:5770/api/v1/mocks?namespace=sandbox&limit=10"

CLI

mockarty-cli mock list --namespace sandbox --limit 10

Go

page, err := client.Mocks().List(context.Background(), &mockarty.ListMocksOptions{
    Namespace: "sandbox", // optional, "sandbox" is the default
    Limit:     10,
})
for _, m := range page.Items {
    fmt.Println(m.ID)
}

Python

page = client.mocks.list(namespace="sandbox", limit=10)
for mock in page.items:
    print(mock.id)

Java

Page<Mock> page = client.mocks().list("sandbox", null, null, 0, 10);
for (Mock m : page.getItems()) {
    System.out.println(m.getId());
}

Kotlin

val page = client.mocks().list("sandbox", null, null, 0, 10)
page.items.forEach { println(it.id) }

Delete Mock (soft)

DELETE /api/v1/mocks/:id | Auth: user (delete)

cURL

curl -X DELETE -H "X-API-Key: mk_YOUR_TOKEN" \
  http://localhost:5770/api/v1/mocks/get-user

CLI

mockarty-cli mock delete get-user

Go

err := client.Mocks().Delete(context.Background(), "get-user")

Python

client.mocks.delete("get-user")

Java

client.mocks().delete("get-user");

Kotlin

client.mocks().delete("get-user")

Restore Mock

GET /api/v1/mocks/:id | Auth: user (write)

Purge Mock (permanent)

DELETE /api/v1/mocks/:id/purge | Auth: user (delete)

Get Mock Logs

GET /api/v1/mocks/:id/logs | Auth: user (read)

Returns request history for a mock.

{
  "id": "get-user",
  "requests": [
    {
      "calledAt": "2024-01-01T10:05:00Z",
      "req": {
        "header": {},
        "body": {},
        "queryParam": {},
        "url": "/stubs/api/users/123"
      }
    }
  ]
}

Chain Mocks

Method Path Description
GET /api/v1/mocks/chains/:id Get all mocks in a chain
DELETE /api/v1/mocks/chains/:id Delete entire chain

Batch Create

POST /api/v1/mocks/batch | Auth: user (write)

Creates multiple mocks in a single request.

cURL

curl -X POST http://localhost:5770/api/v1/mocks/batch \
  -H "X-API-Key: mk_YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '[
    {"id": "mock-1", "namespace": "sandbox", "http": {"route": "/api/a", "httpMethod": "GET"}, "response": {"statusCode": 200}},
    {"id": "mock-2", "namespace": "sandbox", "http": {"route": "/api/b", "httpMethod": "GET"}, "response": {"statusCode": 200}}
  ]'

CLI

# Batch create from a JSON file (namespace defaults to "sandbox")
mockarty-cli mock create --file mocks.json --batch

Go

mocks := []*mockarty.Mock{
    mockarty.NewMockBuilder().ID("mock-1").
        HTTP(func(h *mockarty.HTTPBuilder) { h.Route("/api/a").Method("GET") }).
        Response(func(r *mockarty.ResponseBuilder) { r.Status(200) }).
        Build(),
    mockarty.NewMockBuilder().ID("mock-2").
        HTTP(func(h *mockarty.HTTPBuilder) { h.Route("/api/b").Method("GET") }).
        Response(func(r *mockarty.ResponseBuilder) { r.Status(200) }).
        Build(),
}

err := client.Mocks().BatchCreate(context.Background(), mocks)

Python

mocks = [
    MockBuilder.http("/api/a", "GET").id("mock-1").respond(200).build(),
    MockBuilder.http("/api/b", "GET").id("mock-2").respond(200).build(),
]

results = client.mocks.batch_create(mocks)

Java

// Java SDK does not have a dedicated batchCreate method;
// use a loop to create each mock individually
Mock mock1 = MockBuilder.http("/api/a", "GET").id("mock-1").respond(200).build();
Mock mock2 = MockBuilder.http("/api/b", "GET").id("mock-2").respond(200).build();

client.mocks().create(mock1);
client.mocks().create(mock2);

Partial Update (Patch)

PATCH /api/v1/mocks/:id | Auth: user (write)

Partially updates a mock (merges provided fields into the existing mock).

cURL

curl -X PATCH http://localhost:5770/api/v1/mocks/get-user \
  -H "X-API-Key: mk_YOUR_TOKEN" \
  -d '{"response": {"statusCode": 201}}'

CLI

# CLI does not expose a dedicated patch command.
# Export the mock, edit it locally, and re-apply the full definition — the server
# will update the existing mock by id.
mockarty-cli mock get get-user -o json > mock.json
# edit mock.json (e.g. change response.statusCode to 201)
mockarty-cli mock create -f mock.json

Go

updated, err := client.Mocks().Patch(context.Background(), "get-user", map[string]any{
    "response": map[string]any{"statusCode": 201},
})

Python

updated = client.mocks.patch("get-user", {"response": {"statusCode": 201}})

Java

Mock updated = client.mocks().patchMock("get-user", Map.of(
    "response", Map.of("statusCode", 201)
));

Mock Version History

Method Path Description
GET /api/v1/mocks/:id/versions List mock version history
GET /api/v1/mocks/:id/versions/:version Get specific version
POST /api/v1/mocks/:id/versions/:version/restore Restore mock to a previous version

Preview Mock Resolution

GET /api/v1/mocks/preview | Auth: user (read)

Preview which mock would be resolved for a given route/method without actually calling the stub endpoint.

Batch Operations (UI API)

Method Path Description
DELETE /api/v1/mocks/batch Batch soft-delete: {"ids": [...]}
POST /api/v1/mocks/batch/restore Batch restore: {"ids": [...]}
PATCH /api/v1/mocks/batch/tags Batch tag update: {"ids": [...], "addTags": [...], "removeTags": [...]}

Tags

Method Path Description
GET /api/v1/tags List all tags
POST /api/v1/tags Create a new tag

Mock Folders

Organize mocks into folders for easier management.

Method Path Description
GET /api/v1/mock-folders List all folders
POST /api/v1/mock-folders Create folder
PUT /api/v1/mock-folders/:id Update folder
DELETE /api/v1/mock-folders/:id Delete folder
PATCH /api/v1/mock-folders/:id/move Move folder (reorder/reparent)
PATCH /api/v1/mocks/batch/move Move mocks to a folder

Undefined Requests

Captured requests that did not match any mock.

Method Path Description
GET /api/v1/undefined-requests List undefined requests
PATCH /api/v1/undefined-requests/:id/ignore Ignore an undefined request
DELETE /api/v1/undefined-requests Delete selected undefined requests
DELETE /api/v1/undefined-requests/all Clear all undefined requests
POST /api/v1/undefined-requests/:requestId/create-mock Create mock from an undefined request

3. Namespace API

Method Path Auth Description
POST /api/v1/namespaces user (write) Create namespace: {"name": "staging"}
GET /api/v1/namespaces user (read) List namespaces
POST /api/v1/mocks/copy-to-namespace user (write) Copy mocks between namespaces
GET /api/v1/namespaces user List accessible namespaces
POST /api/v1/namespaces admin Create namespace (admin route)

Copy mocks example:

cURL

curl -X POST -H "X-API-Key: mk_YOUR_TOKEN" \
  http://localhost:5770/api/v1/mocks/copy-to-namespace \
  -d '{
    "sourceNamespace": "staging",
    "targetNamespace": "production",
    "mockIds": ["mock-1", "mock-2"]
  }'

CLI

mockarty-cli namespace copy \
  --from staging --to production \
  --ids mock-1,mock-2

Go

err := client.Mocks().CopyToNamespace(context.Background(),
    []string{"mock-1", "mock-2"}, "production",
)

Python

client.mocks.copy_to_namespace(
    ids=["mock-1", "mock-2"],
    target_namespace="production",
)

Java

client.mocks().copyToNamespace(
    List.of("mock-1", "mock-2"),
    "production"
);

4. Store API

Store API Overview

Three store types for stateful mock scenarios. See Store Systems for concepts.

Global Store

Method Path Auth Description
GET /api/v1/stores/global?namespace=default user (read) Get all global store data
POST /api/v1/stores/global user (write) Set a key-value pair: {"key": "...", "value": "...", "namespace": "..."}
DELETE /api/v1/stores/global/:key?namespace=default user (write) Delete a key (key in URL path)

Each POST request adds a single key-value pair. Make separate requests to set multiple keys.

cURL

# Set a key-value pair (one per request)
curl -X POST -H "X-API-Key: mk_YOUR_TOKEN" \
  "http://localhost:5770/api/v1/stores/global" \
  -d '{"key": "totalUsers", "value": "100", "namespace": "sandbox"}'

curl -X POST -H "X-API-Key: mk_YOUR_TOKEN" \
  "http://localhost:5770/api/v1/stores/global" \
  -d '{"key": "serviceName", "value": "auth", "namespace": "sandbox"}'

# Read store
curl -H "X-API-Key: mk_YOUR_TOKEN" \
  "http://localhost:5770/api/v1/stores/global?namespace=sandbox"

# Delete a key (key in URL path)
curl -X DELETE -H "X-API-Key: mk_YOUR_TOKEN" \
  "http://localhost:5770/api/v1/stores/global/totalUsers?namespace=sandbox"

CLI

# Set a value (namespace defaults to "sandbox")
mockarty-cli store global set totalUsers 100
mockarty-cli store global set serviceName auth

# Read the store
mockarty-cli store global get

# Delete a key
mockarty-cli store global delete totalUsers

Go

// Set values (uses client's default namespace "sandbox")
err := client.Stores().GlobalSet(context.Background(), "totalUsers", 100)
err = client.Stores().GlobalSet(context.Background(), "serviceName", "auth")

// Read the store
store, err := client.Stores().GlobalGet(context.Background())
fmt.Println(store) // map[totalUsers:100 serviceName:auth ...]

// Delete a key
err = client.Stores().GlobalDelete(context.Background(), "totalUsers")

Python

# Set values (uses client's default namespace "sandbox")
client.stores.global_set("totalUsers", 100)
client.stores.global_set("serviceName", "auth")

# Or set multiple at once
client.stores.global_set_many({"totalUsers": 100, "serviceName": "auth"})

# Read the store
store = client.stores.global_get()
print(store)  # {"totalUsers": 100, "serviceName": "auth"}

# Delete keys
client.stores.global_delete("totalUsers")

Java

// Set values (uses client's default namespace "sandbox")
client.stores().globalSet("totalUsers", 100);
client.stores().globalSet("serviceName", "auth");

// Read the store
Map<String, Object> store = client.stores().globalGet();
System.out.println(store);

// Delete a key
client.stores().globalDelete("totalUsers");

Chain Store

Method Path Auth Description
GET /api/v1/stores/chain/:id?namespace=default user (read) Get chain store
POST /api/v1/stores/chain/:id user (write) Set a key-value pair: {"key": "...", "value": "...", "namespace": "..."}
DELETE /api/v1/stores/chain/:id/:key?namespace=default user (write) Delete a key (key in URL path)

5. Template API

Upload payload templates for use in mock responses via payloadTemplatePath.

Method Path Auth Description
GET /api/v1/templates user (read) List all templates
GET /api/v1/templates/:fileName user (read) Download template
POST /api/v1/templates/:fileName user (write) Upload template file
DELETE /api/v1/templates/:fileName user (write) Delete template

Temporary File Storage

Temporary file uploads for use in the agent chat interface. Files are automatically deleted after 30 minutes.

Method Path Auth Description
POST /api/v1/temp-files/upload user (write) Upload a temporary file
GET /api/v1/temp-files/get/:fileId user (read) Download a temporary file
DELETE /api/v1/temp-files/delete/:fileId user (write) Delete a temporary file

Legacy OpenAPI Generation

Method Path Auth Description
POST /api/v1/generators/openapi user (write) Generate mocks from an OpenAPI spec

6. CI/CD Integration Guide

Mockarty provides full API coverage for CI/CD automation. All examples use API token authentication.

6.1 Running API Tests from CI

cURL

TOKEN="mk_YOUR_TOKEN"
BASE="http://localhost:5770/ui/api"

# 1. Create a collection
COLLECTION_ID=$(curl -s -X POST "$BASE/api-tester/collections" \
  -H "X-API-Key: $TOKEN" \
  -d '{"name": "CI Tests", "description": "Automated test suite"}' | jq -r '.id')

# 2. Add a request with test script
curl -X POST "$BASE/api-tester/collections/$COLLECTION_ID/requests" \
  -H "X-API-Key: $TOKEN" \
  -d '{
    "name": "Get Users",
    "method": "GET",
    "url": "http://localhost:5770/stubs/sandbox/api/users",
    "testScript": "mk.test(\"Status is 200\", function() { mk.response.to.have.status(200); });"
  }'

# 3. Execute the collection (runs all requests + test scripts)
RUN_ID=$(curl -s -X POST "$BASE/api-tester/collections/$COLLECTION_ID/execute" \
  -H "X-API-Key: $TOKEN" \
  -d '{}' | jq -r '.runId')

# 4. Poll for results
curl -s "$BASE/api-tester/test-runs/$RUN_ID" \
  -H "X-API-Key: $TOKEN" | jq '.status, .summary'

CLI

# Run an existing collection by name or ID
mockarty-cli run collection "CI Tests" --wait --format json

# Run and export JUnit report for CI
mockarty-cli run collection "CI Tests" --wait --junit-report results.xml

Go

// Create a collection and execute it
col, err := client.Collections().Create(context.Background(), &mockarty.Collection{
    Name:        "CI Tests",
    Description: "Automated test suite",
})

// Execute the collection
run, err := client.Collections().Execute(context.Background(), col.ID)
fmt.Printf("Run ID: %s, Status: %s\n", run.ID, run.Status)

Python

# Create a collection and execute it
col = client.collections.create({
    "name": "CI Tests",
    "description": "Automated test suite",
})

# Execute the collection
run = client.collections.execute(col.id)
print(f"Run ID: {run.id}, Status: {run.status}")

Java

// Create a collection and execute it
Map<String, Object> col = client.collections().create(Map.of(
    "name", "CI Tests",
    "description", "Automated test suite"
));

String collectionId = (String) col.get("id");
Map<String, Object> run = client.collections().execute(collectionId, Map.of());
System.out.println("Run ID: " + run.get("runId"));

6.2 Running Performance Tests from CI

cURL

# 1. Create perf config (linked to a collection)
CONFIG_ID=$(curl -s -X POST "$BASE/perf-configs" \
  -H "X-API-Key: $TOKEN" \
  -d '{
    "name": "Load Test",
    "collectionId": "'$COLLECTION_ID'",
    "vus": 10,
    "duration": "30s"
  }' | jq -r '.id')

# 2. Run performance test with inline script
curl -X POST "$BASE/perf/run" \
  -H "X-API-Key: $TOKEN" \
  -d '{
    "script": "import http from \"k6/http\"; export default function() { http.get(\"http://localhost:5770/stubs/sandbox/api/users\"); }",
    "options": {"vus": 10, "duration": "30s"}
  }'

# 3. Check results
curl -s "$BASE/perf-results" -H "X-API-Key: $TOKEN" | jq '.[0]'

CLI

# Run a performance test from an existing config
mockarty-cli perf run --config "Load Test" --wait

# Run with inline options
mockarty-cli perf run --vus 10 --duration 30s \
  --url http://localhost:5770/stubs/sandbox/api/users

Go

// Run a performance test
result, err := client.Perf().Run(context.Background(), &mockarty.PerfRunRequest{
    Script:  `import http from "k6/http"; export default function() { http.get("http://localhost:5770/stubs/sandbox/api/users"); }`,
    Options: map[string]any{"vus": 10, "duration": "30s"},
})

// List results
results, err := client.Perf().ListResults(context.Background())

Python

# Run a performance test
result = client.perf.run({
    "script": 'import http from "k6/http"; export default function() { http.get("http://localhost:5770/stubs/sandbox/api/users"); }',
    "options": {"vus": 10, "duration": "30s"},
})

# List results
results = client.perf.list_results()

Java

// Run a performance test
Map<String, Object> result = client.perf().run(Map.of(
    "script", "import http from \"k6/http\"; export default function() { http.get(\"http://localhost:5770/stubs/sandbox/api/users\"); }",
    "options", Map.of("vus", 10, "duration", "30s")
));

6.3 Running Fuzzing from CI

cURL

# 1. Create fuzz config
CONFIG_ID=$(curl -s -X POST "$BASE/fuzzing/configs" \
  -H "X-API-Key: $TOKEN" \
  -d '{
    "name": "API Fuzz",
    "method": "POST",
    "url": "http://target:8080/api/users",
    "headers": {"Content-Type": "application/json"},
    "body": "{\"name\": \"test\"}",
    "payloadCategories": ["sql_injection", "xss"]
  }' | jq -r '.id')

# 2. Start fuzz run
RUN_ID=$(curl -s -X POST "$BASE/fuzzing/run" \
  -H "X-API-Key: $TOKEN" \
  -d '{"configId": "'$CONFIG_ID'"}' | jq -r '.id')

# 3. Check findings
curl -s "$BASE/fuzzing/findings?runId=$RUN_ID" \
  -H "X-API-Key: $TOKEN" | jq '.findings'

CLI

# Run fuzzing from CLI
mockarty-cli fuzz run --config "API Fuzz" --wait

# Quick fuzz a URL
mockarty-cli fuzz quick \
  --url http://target:8080/api/users \
  --method POST \
  --categories sql_injection,xss

Go

// Create a fuzz config and run it
config, err := client.Fuzzing().CreateConfig(context.Background(), &mockarty.FuzzingConfig{
    Name:              "API Fuzz",
    Method:            "POST",
    URL:               "http://target:8080/api/users",
    PayloadCategories: []string{"sql_injection", "xss"},
})

run, err := client.Fuzzing().Run(context.Background(), config.ID)

// Check findings
findings, err := client.Fuzzing().ListFindings(context.Background(), run.ID)

Python

# Create a fuzz config and run it
config = client.fuzzing.create_config({
    "name": "API Fuzz",
    "method": "POST",
    "url": "http://target:8080/api/users",
    "payloadCategories": ["sql_injection", "xss"],
})

run = client.fuzzing.run(config.id)

# Check findings
findings = client.fuzzing.list_findings(run_id=run.id)

Java

// Create a fuzz config and run it
FuzzingConfig config = client.fuzzing().createConfig(Map.of(
    "name", "API Fuzz",
    "method", "POST",
    "url", "http://target:8080/api/users",
    "payloadCategories", List.of("sql_injection", "xss")
));

FuzzingRun run = client.fuzzing().run(config.getId());

6.4 Importing OpenAPI/Postman/HAR

cURL

# Import OpenAPI spec to generate mocks (namespace "sandbox" is the default)
curl -X POST "$BASE/generators/openapi" \
  -H "X-API-Key: $TOKEN" \
  -F "file=@openapi.yaml" \
  -F "namespace=sandbox"

# Import Postman collection to API Tester
curl -X POST "$BASE/api-tester/import/postman" \
  -H "X-API-Key: $TOKEN" \
  -F "file=@collection.json"

# Import HAR recording
curl -X POST "$BASE/api-tester/import/har" \
  -H "X-API-Key: $TOKEN" \
  -F "file=@recording.har"

# Import WSDL for SOAP mocks
curl -X POST "$BASE/api-tester/import/wsdl" \
  -H "X-API-Key: $TOKEN" \
  -F "file=@service.wsdl"

CLI

# Import OpenAPI spec (namespace defaults to "sandbox")
mockarty-cli generate openapi --file openapi.yaml --namespace sandbox

# Import Postman collection
mockarty-cli import postman --file collection.json

# Import HAR recording
mockarty-cli import har --file recording.har

Go

// Import OpenAPI spec to generate mocks
result, err := client.Generator().OpenAPIGenerate(context.Background(),
    "openapi.yaml", // file path
    "sandbox",       // namespace
)

// Import Postman collection
importResult, err := client.Imports().Postman(context.Background(), "collection.json")

Python

# Import OpenAPI spec to generate mocks
result = client.generator.openapi_generate(
    file_path="openapi.yaml",
    namespace="sandbox",  # optional, "sandbox" is the default
)

# Import Postman collection
import_result = client.imports.postman(file_path="collection.json")

Java

// Import OpenAPI spec to generate mocks
GeneratorResponse result = client.generator().openapiGenerate(
    "openapi.yaml", "sandbox"
);

// Import Postman collection
ImportResult importResult = client.imports().postman("collection.json");

6.5 Setting Up Mocks Before Tests

cURL

# Create mocks for your test environment (namespace "sandbox" is the default)
curl -X POST http://localhost:5770/api/v1/mocks \
  -H "X-API-Key: $TOKEN" \
  -d '{
    "id": "ci-user-service",
    "namespace": "sandbox",
    "http": {"route": "/api/users/list", "httpMethod": "GET"},
    "response": {
      "statusCode": 200,
      "payload": {"id": "$.fake.UUID", "name": "Test User"}
    }
  }'

# Verify mock is active
curl http://localhost:5770/stubs/sandbox/api/users/list
# Returns: {"id": "a1b2c3d4-...", "name": "Test User"}

# Cleanup after tests
curl -X DELETE -H "X-API-Key: $TOKEN" \
  http://localhost:5770/api/v1/mocks/ci-user-service

CLI

# Create a mock from a JSON file
mockarty-cli mock create --file ci-mocks.json

# Verify mock is active
curl http://localhost:5770/stubs/sandbox/api/users/list

# Cleanup after tests
mockarty-cli mock delete ci-user-service

Go

// Create mock for CI
mock := mockarty.NewMockBuilder().
    ID("ci-user-service").
    Namespace("sandbox").
    HTTP(func(h *mockarty.HTTPBuilder) {
        h.Route("/api/users/list").Method("GET")
    }).
    Response(func(r *mockarty.ResponseBuilder) {
        r.Status(200).JSONBody(map[string]any{
            "id":   "$.fake.UUID",
            "name": "Test User",
        })
    }).
    Build()

_, err := client.Mocks().Create(context.Background(), mock)

// ... run tests ...

// Cleanup
err = client.Mocks().Delete(context.Background(), "ci-user-service")

Python

# Create mock for CI
mock = (
    MockBuilder.http("/api/users/list", "GET")
    .id("ci-user-service")
    .namespace("sandbox")
    .respond(200, body={"id": "$.fake.UUID", "name": "Test User"})
    .build()
)
client.mocks.create(mock)

# ... run tests ...

# Cleanup
client.mocks.delete("ci-user-service")

Java

// Create mock for CI
Mock mock = MockBuilder.http("/api/users/list", "GET")
    .id("ci-user-service")
    .namespace("sandbox")
    .respond(200, Map.of("id", "$.fake.UUID", "name", "Test User"))
    .build();

client.mocks().create(mock);

// ... run tests ...

// Cleanup
client.mocks().delete("ci-user-service");

7. API Tester API

Full-featured API testing platform (like Postman). All endpoints are under /api/v1/ and require authentication.

Collections

Method Path Description
POST /api/v1/api-tester/collections Create collection
GET /api/v1/api-tester/collections List collections
GET /api/v1/api-tester/collections/:id Get collection
PUT /api/v1/api-tester/collections/:id Update collection
DELETE /api/v1/api-tester/collections/:id Delete collection
POST /api/v1/api-tester/collections/:id/restore Restore deleted collection
POST /api/v1/api-tester/collections/:id/duplicate Duplicate collection
DELETE /api/v1/api-tester/collections/batch Batch delete
GET /api/v1/api-tester/collections/:id/export Export collection (JSON)

Collection Sharing

Method Path Description
POST /api/v1/api-tester/collections/:id/share-with-users Share with users
POST /api/v1/api-tester/collections/:id/share-with-spaces Share with namespaces
GET /api/v1/api-tester/collections/:id/users List collection users
PUT /api/v1/api-tester/collections/:id/users/:userId/role Set user role
DELETE /api/v1/api-tester/collections/:id/users/:userId Remove user
GET /api/v1/api-tester/collections/:id/spaces List shared namespaces
DELETE /api/v1/api-tester/collections/:id/spaces/:namespace Remove namespace

Requests

Method Path Description
POST /api/v1/api-tester/collections/:id/requests Create request
GET /api/v1/api-tester/collections/:id/requests List requests in collection
GET /api/v1/api-tester/requests/:id Get request
PUT /api/v1/api-tester/requests/:id Update request
DELETE /api/v1/api-tester/requests/:id Delete request
POST /api/v1/api-tester/requests/execute Execute request (server-side)
POST /api/v1/api-tester/requests/execute-client Execute for client-side mode
GET /api/v1/api-tester/requests/history Request execution history
DELETE /api/v1/api-tester/requests/batch Batch delete requests
PATCH /api/v1/api-tester/requests/batch/move Batch move requests
POST /api/v1/api-tester/collections/:id/requests/reorder Reorder requests in a collection (body: {"ids":["uuid","uuid",...]})

Environments

Method Path Description
POST /api/v1/api-tester/environments Create environment
GET /api/v1/api-tester/environments List environments
GET /api/v1/api-tester/environments/active Get active environment
GET /api/v1/api-tester/environments/:id Get environment
PUT /api/v1/api-tester/environments/:id Update environment
DELETE /api/v1/api-tester/environments/:id Delete environment
POST /api/v1/api-tester/environments/:id/activate Set as active

Test Runs

Method Path Description
GET /api/v1/api-tester/test-runs List test runs (supports ?mode=&referenceId=&limit=&offset= filters)
GET /api/v1/api-tester/test-runs/:id Get test run details
DELETE /api/v1/api-tester/test-runs/:id Delete test run
POST /api/v1/api-tester/test-runs/:id/cancel Cancel running test
GET /api/v1/api-tester/test-runs/:id/export Export test run report
POST /api/v1/api-tester/reports/import Import test run report
GET /api/v1/test-runs/active Active runs across all modes in the namespace

Unified test run modes

Every row returned from /api/v1/api-tester/test-runs includes a mode field
identifying which execution surface produced the run:

Mode Produced by referenceId points to
functional API Tester collection runs (default)
load Performance / load engine Performance config
fuzz Fuzz campaigns Fuzz config
chaos Chaos experiments Chaos experiment
contract Contract verifications Contract registry entry

Filter examples:

# All fuzz campaigns in the namespace
curl -H "Authorization: Bearer $TOKEN" \
  "$MOCKARTY_URL/api/v1/api-tester/test-runs?mode=fuzz"

# Every run for a specific chaos experiment
curl -H "Authorization: Bearer $TOKEN" \
  "$MOCKARTY_URL/api/v1/api-tester/test-runs?mode=chaos&referenceId=$EXPERIMENT_ID"

# Paginated functional runs
curl -H "Authorization: Bearer $TOKEN" \
  "$MOCKARTY_URL/api/v1/api-tester/test-runs?mode=functional&limit=50&offset=100"

SDK equivalents:

// Go
runs, err := client.TestRuns.ListWithOptions(ctx, mockarty.ListTestRunsOptions{
    Mode:        "fuzz",
    ReferenceID: fuzzConfigID,
    Limit:       50,
})
# Python
runs = client.test_runs.list(mode="chaos", reference_id=experiment_id, limit=50)
// Java
List<TestRun> runs = client.testRuns().listByMode("fuzz", fuzzConfigId, 50, 0);
# CLI
mockarty-cli test-runs list --mode chaos --reference-id "$EXPERIMENT_ID" --limit 50

Scripts and Execution

Method Path Description
POST /api/v1/api-tester/requests/execute-with-scripts Execute with pre/post scripts
POST /api/v1/api-tester/requests/run-script Run script standalone
POST /api/v1/api-tester/collections/:id/execute Execute entire collection
POST /api/v1/api-tester/collections/execute-multiple Execute multiple collections
GET /api/v1/api-tester/test-reports/:id Get test report

Standalone Tests

Method Path Description
GET /api/v1/api-tester/tests List tests
POST /api/v1/api-tester/tests Create test
GET /api/v1/api-tester/tests/:id Get test
PUT /api/v1/api-tester/tests/:id Update test
DELETE /api/v1/api-tester/tests/:id Delete test
POST /api/v1/api-tester/tests/:id/run Run test
POST /api/v1/api-tester/tests/run Run test inline

Schedules (Cron-based)

Method Path Description
GET /api/v1/api-tester/schedules List schedules
POST /api/v1/api-tester/schedules Create schedule
GET /api/v1/api-tester/schedules/:id Get schedule
PUT /api/v1/api-tester/schedules/:id Update schedule
DELETE /api/v1/api-tester/schedules/:id Delete schedule
POST /api/v1/api-tester/schedules/:id/run Trigger schedule now

Import/Export

Method Path Description
POST /api/v1/api-tester/import/postman Import Postman collection
POST /api/v1/api-tester/import/openapi Import from OpenAPI spec
POST /api/v1/api-tester/import/wsdl Import from WSDL
POST /api/v1/api-tester/import/grpc Import gRPC from .proto
POST /api/v1/api-tester/import/graphql Import GraphQL schema
POST /api/v1/api-tester/import/mcp Import MCP server tools
POST /api/v1/api-tester/import/har Import HAR recording
POST /api/v1/api-tester/import/soapui Import SoapUI project
POST /api/v1/api-tester/import/mockarty Import Mockarty collection
POST /api/v1/api-tester/generate-mock Generate mock from response
POST /api/v1/api-tester/generate-mocks-from-collection Generate mocks from collection

Protocol Helpers

Method Path Description
POST /api/v1/proxy/http Proxy HTTP request
POST /api/v1/proxy/soap Proxy SOAP request
POST /api/v1/proxy/grpc Proxy gRPC request
POST /api/v1/api-tester/mcp/connect Connect to MCP server
POST /api/v1/api-tester/mcp/tools/list List MCP tools
POST /api/v1/api-tester/mcp/tools/call Call MCP tool
POST /api/v1/api-tester/graphql/introspect Introspect GraphQL endpoint
POST /api/v1/api-tester/grpc/discover Discover gRPC services
POST /api/v1/api-tester/soap/operations List SOAP operations from WSDL

Kafka Admin

Method Path Description
POST /api/v1/api-tester/kafka/metadata Get cluster metadata
POST /api/v1/api-tester/kafka/topics List topics
POST /api/v1/api-tester/kafka/topics/create Create topic
POST /api/v1/api-tester/kafka/topics/delete Delete topic
POST /api/v1/api-tester/kafka/consumer-groups List consumer groups

RabbitMQ Admin

Method Path Description
POST /api/v1/api-tester/rabbitmq/publish Publish message
POST /api/v1/api-tester/rabbitmq/read Read messages from queue
POST /api/v1/api-tester/rabbitmq/metadata Get broker metadata
POST /api/v1/api-tester/rabbitmq/queues List queues
POST /api/v1/api-tester/rabbitmq/queues/create Create queue
POST /api/v1/api-tester/rabbitmq/queues/delete Delete queue
POST /api/v1/api-tester/rabbitmq/queues/purge Purge queue
POST /api/v1/api-tester/rabbitmq/exchanges List exchanges
POST /api/v1/api-tester/rabbitmq/exchanges/create Create exchange
POST /api/v1/api-tester/rabbitmq/exchanges/delete Delete exchange

8. Performance Testing API

Built-in performance testing with k6-compatible scripting. All endpoints under /api/v1/.

Perf Configs

Method Path Description
GET /api/v1/perf-configs List perf configurations
GET /api/v1/perf-configs/:id Get perf config
POST /api/v1/perf-configs Create perf config
PUT /api/v1/perf-configs/:id Update perf config
DELETE /api/v1/perf-configs/:id Delete perf config

Run/Stop Tests

Method Path Description
POST /api/v1/perf/run Run perf test with script
POST /api/v1/perf/run-collection Run perf test from collection
POST /api/v1/perf/stop/:taskId Stop running test
POST /api/v1/perf/scripts Generate k6 script from config
POST /api/v1/perf/scripts/from-request Generate script from API tester request
POST /api/v1/perf/scripts/from-har Convert HAR to perf script
GET /api/v1/perf/snippets List script snippets

Results

Method Path Description
GET /api/v1/perf-results List all results
GET /api/v1/perf-results/:id Get result details
DELETE /api/v1/perf-results/:id Delete result
GET /api/v1/perf-results/compare Compare results side-by-side
GET /api/v1/perf-results/history/:configId Result history for config
GET /api/v1/perf-results/trend/:configId Trend data for config
GET /api/v1/perf-results/group/:runGroupId Results by run group
POST /api/v1/perf-results/:id/ai-analyze AI analysis of results

Schedules

Method Path Description
GET /api/v1/perf-schedules List perf schedules
POST /api/v1/perf-schedules Create schedule
PUT /api/v1/perf-schedules/:id Update schedule
DELETE /api/v1/perf-schedules/:id Delete schedule

Runner Tasks

Method Path Description
POST /api/v1/runner-tasks Submit task to runner
GET /api/v1/runner-tasks List runner tasks
GET /api/v1/runner-tasks/:id Get task status
GET /api/v1/runner-tasks/:id/queue-position Get queue position
DELETE /api/v1/runner-tasks/:id Cancel task
GET /api/v1/runners List available runners

9. Fuzzing API

Security fuzzing with built-in payload categories (SQL injection, XSS, etc.). All endpoints under /api/v1/fuzzing/.

Summary and Payloads

Method Path Description
GET /api/v1/fuzzing/summary Fuzzing dashboard summary
GET /api/v1/fuzzing/payload-categories List payload categories

Configs

Method Path Description
GET /api/v1/fuzzing/configs List fuzz configs
GET /api/v1/fuzzing/configs/:id Get fuzz config
POST /api/v1/fuzzing/configs Create fuzz config
PUT /api/v1/fuzzing/configs/:id Update fuzz config
DELETE /api/v1/fuzzing/configs/:id Delete fuzz config
POST /api/v1/fuzzing/configs/reorder Reorder configs

Import

Method Path Description
POST /api/v1/fuzzing/import/curl Import from cURL command
POST /api/v1/fuzzing/import/openapi Import from OpenAPI spec
POST /api/v1/fuzzing/import/collection Import from API tester collection
POST /api/v1/fuzzing/import/recorder Import from recorder session
POST /api/v1/fuzzing/import/mock Import from mock definition

Protocol Discovery

Method Path Description
POST /api/v1/fuzzing/introspect/graphql Introspect GraphQL for fuzzing
POST /api/v1/fuzzing/discover/grpc Discover gRPC services for fuzzing

Runs and Results

Method Path Description
POST /api/v1/fuzzing/run Start fuzz run
POST /api/v1/fuzzing/run/:id/stop Stop fuzz run
POST /api/v1/fuzzing/quick-fuzz Quick fuzz (create + run)
GET /api/v1/fuzzing/results List fuzz results
GET /api/v1/fuzzing/results/:id Get fuzz result
DELETE /api/v1/fuzzing/results/:id Delete fuzz result

Findings

Method Path Description
GET /api/v1/fuzzing/findings List findings
GET /api/v1/fuzzing/findings/:id Get finding detail
PUT /api/v1/fuzzing/findings/:id/triage Triage finding (set severity, status)
POST /api/v1/fuzzing/findings/:id/replay Replay finding request
POST /api/v1/fuzzing/findings/:id/analyze AI-analyze finding
POST /api/v1/fuzzing/findings/batch-analyze AI-analyze multiple findings
POST /api/v1/fuzzing/findings/batch-triage AI batch triage
POST /api/v1/fuzzing/findings/export Export findings

Schedules

Method Path Description
GET /api/v1/fuzzing/schedules List fuzz schedules
GET /api/v1/fuzzing/schedules/:id Get schedule
POST /api/v1/fuzzing/schedules Create schedule
PUT /api/v1/fuzzing/schedules/:id Update schedule
DELETE /api/v1/fuzzing/schedules/:id Delete schedule

10. Recorder API

HTTP traffic recorder (proxy-based). All endpoints under /api/v1/recorder/.

Sessions

Method Path Description
POST /api/v1/recorder/start Start recording session
GET /api/v1/recorder/sessions List sessions
GET /api/v1/recorder/:id Get session details
POST /api/v1/recorder/:id/stop Stop session
POST /api/v1/recorder/:id/restart Restart session
DELETE /api/v1/recorder/:id Delete session

Start session example:

cURL

curl -X POST "$BASE/recorder/start" \
  -H "X-API-Key: $TOKEN" \
  -d '{
    "targetUrl": "https://api.example.com",
    "port": 8888,
    "name": "API Recording"
  }'

Go

session, err := client.Recorder().StartRecording(context.Background(), &mockarty.RecorderSession{
    TargetURL: "https://api.example.com",
    Port:      8888,
    Name:      "API Recording",
})
if err != nil {
    log.Fatal(err)
}
fmt.Printf("Session started: %s\n", session.ID)

Python

session = client.recorder.create({
    "targetUrl": "https://api.example.com",
    "port": 8888,
    "name": "API Recording",
})
print(f"Session started: {session.id}")

Java

RecorderSession session = client.recorder().start(Map.of(
    "targetUrl", "https://api.example.com",
    "port", 8888,
    "name", "API Recording"
));
System.out.println("Session started: " + session.getId());

Tip: The same operations are available through mockarty-cli recorder ... — see the CLI User Guide for the command reference.

Entries

Method Path Description
GET /api/v1/recorder/:id/entries List recorded entries
PATCH /api/v1/recorder/:id/entries/:entryId Annotate entry
POST /api/v1/recorder/:id/entries/:entryId/replay Replay request

Modifications (Request/Response rewriting)

Method Path Description
GET /api/v1/recorder/:id/modifications Get modification rules
PUT /api/v1/recorder/:id/modifications Update modification rules

Export

Method Path Description
POST /api/v1/recorder/:id/export Export as HAR
POST /api/v1/recorder/:id/export-perf Export as perf script
POST /api/v1/recorder/:id/export-test Export as test script
POST /api/v1/recorder/:id/export-collection Export as API tester collection
POST /api/v1/recorder/:id/mocks Create mocks from entries

AI Analysis

Method Path Description
POST /api/v1/recorder/:id/ai-analyze AI-analyze session traffic
POST /api/v1/recorder/:id/ai-scenarios AI-generate test scenarios

Configuration

Method Path Description
GET /api/v1/recorder/ports List used ports
GET /api/v1/recorder/port-check Check port availability
GET /api/v1/recorder/configs List recorder configs
POST /api/v1/recorder/configs Save config
POST /api/v1/recorder/configs/import Import config
GET /api/v1/recorder/configs/:id/export Export config
DELETE /api/v1/recorder/configs/:id Delete config
GET /api/v1/recorder/ca/status CA certificate status
POST /api/v1/recorder/ca/generate Generate CA certificate
GET /api/v1/recorder/ca/download Download CA certificate

WebSocket

Method Path Description
GET /api/v1/recorder/:id/ws WebSocket for live entry streaming

11. Contract Testing API

Contract testing validates that your mocks stay in sync with real API specifications. It supports OpenAPI schema validation, consumer-driven contracts (Pact-compatible), API drift detection, and an API registry (internal marketplace). All endpoints under /api/v1/contract/.

Mock Validation

Method Path Description
POST /api/v1/contract/validate-mocks Validate mocks against an OpenAPI spec
POST /api/v1/contract/verify-provider Verify provider against consumer contracts
POST /api/v1/contract/check-compatibility Check backward compatibility between API versions
POST /api/v1/contract/validate-payload Validate a single mock payload against a schema
POST /api/v1/contract/detect-drift Detect API drift between mocks and live endpoints

Configs and Scheduled Runs

Method Path Description
GET /api/v1/contract/configs List contract testing configurations
POST /api/v1/contract/configs Create/save a contract testing configuration
DELETE /api/v1/contract/configs/:id Delete a configuration
POST /api/v1/contract/configs/:id/run Run a configuration immediately
Method Path Description
GET /api/v1/contract/results List contract testing results
GET /api/v1/contract/results/:id Get a specific result
GET /api/v1/contract/trends Get trend data for contract testing over time

Findings (AI Analysis)

Method Path Description
POST /api/v1/contract/findings/analyze AI-analyze contract testing findings
POST /api/v1/contract/findings/auto-triage AI-powered auto-triage of findings
POST /api/v1/contract/findings/export Export findings

Consumer Contracts (Pact)

Method Path Description
POST /api/v1/contract/pacts Publish a consumer contract (Pact)
GET /api/v1/contract/pacts List published pacts
GET /api/v1/contract/pacts/:id Get a specific pact
DELETE /api/v1/contract/pacts/:id Delete a pact
POST /api/v1/contract/pacts/verify Verify provider against pact contracts
POST /api/v1/contract/pacts/can-i-deploy Check if a version is safe to deploy (can-i-deploy)
GET /api/v1/contract/pacts/verifications List pact verification results
POST /api/v1/contract/pacts/:id/mocks Generate mocks from a pact contract

API Registry (Internal Marketplace)

Method Path Description
POST /api/v1/contract/registry Publish an API to the registry
GET /api/v1/contract/registry List registered APIs
GET /api/v1/contract/registry/namespaces List registry namespaces
GET /api/v1/contract/registry/:id Get a registered API
PUT /api/v1/contract/registry/:id Update a registered API
DELETE /api/v1/contract/registry/:id Delete a registered API
POST /api/v1/contract/registry/:id/generate-mocks Generate mocks from a registry entry
POST /api/v1/contract/registry/:id/subscribe Subscribe to API changes
GET /api/v1/contract/registry/:id/subscribers List subscribers for an API
POST /api/v1/contract/registry/:id/check-impact Check impact of API changes on subscribers

Subscriptions

Method Path Description
GET /api/v1/contract/subscriptions List your subscriptions
DELETE /api/v1/contract/subscriptions/:id Unsubscribe from an API

12. Chaos Engineering API

Kubernetes-native chaos engineering for fault injection and resilience testing. Create experiments to inject faults (pod kills, network latency, resource stress) into your clusters and observe how services behave. All endpoints under /api/v1/chaos/.

Presets

Method Path Description
GET /api/v1/chaos/presets List available chaos experiment presets

Experiments

Method Path Description
GET /api/v1/chaos/experiments List experiments (filter by ?namespace=, ?status=, ?limit=, ?offset=)
GET /api/v1/chaos/experiments/:id Get experiment details
POST /api/v1/chaos/experiments Create a new chaos experiment
PUT /api/v1/chaos/experiments/:id Update an experiment
DELETE /api/v1/chaos/experiments/:id Delete an experiment
POST /api/v1/chaos/experiments/:id/run Run an experiment
POST /api/v1/chaos/experiments/:id/abort Abort a running experiment
GET /api/v1/chaos/experiments/:id/metrics Get experiment metrics
GET /api/v1/chaos/experiments/:id/events Get experiment events timeline
GET /api/v1/chaos/experiments/:id/report Get experiment report
GET /api/v1/chaos/experiments/:id/report/download Download experiment report (?format=html|json|junit|allure)
GET /api/v1/chaos/experiments/:id/snapshot Get experiment snapshot (cluster state at time of execution)

Experiment Queue

Method Path Description
GET /api/v1/chaos/queue/:clusterId Get queue status for a cluster

Infrastructure Profiles

Method Path Description
GET /api/v1/chaos/profiles List infrastructure profiles (filter by ?namespace=)
POST /api/v1/chaos/profiles Create infrastructure profile (with kubeconfig)
PUT /api/v1/chaos/profiles/:id Update infrastructure profile
DELETE /api/v1/chaos/profiles/:id Delete infrastructure profile
POST /api/v1/chaos/profiles/:id/test Test connection to cluster
POST /api/v1/chaos/profiles/:id/connect Connect to cluster
POST /api/v1/chaos/profiles-test Test inline kubeconfig (no saved profile)

Chaos Operator

Method Path Description
GET /api/v1/chaos/operator/status Get Chaos Operator status on cluster
POST /api/v1/chaos/operator/manifest Generate operator installation manifest
POST /api/v1/chaos/operator/install Install Chaos Operator on cluster

Kubernetes Resources

Method Path Description
GET /api/v1/chaos/clusters/:id/topology Get cluster topology
GET /api/v1/chaos/pods/:namespace/:name Get pod details
GET /api/v1/chaos/pods/:namespace/:name/logs Get pod logs
DELETE /api/v1/chaos/pods/:namespace/:name Kill a pod
GET /api/v1/chaos/deployments/:namespace/:name Get deployment details
POST /api/v1/chaos/deployments/:namespace/:name/scale Scale a deployment
POST /api/v1/chaos/deployments/:namespace/:name/restart Restart a deployment
GET /api/v1/chaos/configmaps/:namespace List ConfigMaps
GET /api/v1/chaos/configmaps/:namespace/:name Get ConfigMap
PUT /api/v1/chaos/configmaps/:namespace/:name Update ConfigMap
GET /api/v1/chaos/services/:namespace List Services
GET /api/v1/chaos/crds List Custom Resource Definitions
GET /api/v1/chaos/crds/:group/:version/:resource List CRD resources
GET /api/v1/chaos/events/:namespace List Kubernetes events

13. Admin API

Admin-only endpoints require the admin role. Prefix: /api/v1/admin/.

User Management

Method Path Description
GET /api/v1/admin/users List users
POST /api/v1/admin/users Create user
PUT /api/v1/admin/users/:id Update user
DELETE /api/v1/admin/users/:id Delete user
POST /api/v1/admin/users/:id/password Set user password
POST /api/v1/admin/users/:id/disable Disable user
POST /api/v1/admin/users/:id/enable Enable user

Namespace Management (Admin)

Method Path Description
GET /api/v1/admin/namespaces List namespaces with metadata
DELETE /api/v1/admin/namespaces/:namespace Delete namespace
PUT /api/v1/admin/namespaces/:namespace/restore Restore namespace
GET /api/v1/admin/namespaces/:namespace/users List namespace users
POST /api/v1/admin/namespaces/:namespace/users Add user to namespace
DELETE /api/v1/admin/namespaces/:namespace/users/:user_id Remove user
PUT /api/v1/admin/namespaces/:namespace/users/:user_id/role Update user role

Cleanup Policies

Method Path Description
GET /api/v1/admin/namespaces/:namespace/cleanup-policy Get cleanup policy
PUT /api/v1/admin/namespaces/:namespace/cleanup-policy Set cleanup policy
GET /api/v1/admin/cleanup-settings/:type Get global cleanup setting
PUT /api/v1/admin/cleanup-settings/:type Update global cleanup setting

LLM/AI Settings

Method Path Description
GET /api/v1/admin/llm-settings Get global LLM config
PUT /api/v1/admin/llm-settings Save global LLM config
GET /api/v1/admin/llm-profiles List LLM profiles
GET /api/v1/admin/llm-profiles/:id Get LLM profile
POST /api/v1/admin/llm-profiles Create LLM profile
PUT /api/v1/admin/llm-profiles/:id Update LLM profile
DELETE /api/v1/admin/llm-profiles/:id Delete LLM profile
GET /api/v1/admin/agent-settings Get AI agent settings
PUT /api/v1/admin/agent-settings Update AI agent settings

Email Configuration

Method Path Description
GET /api/v1/admin/email/config Get email/SMTP config
PUT /api/v1/admin/email/config Update email config
POST /api/v1/admin/email/test Send test email
POST /api/v1/admin/email/ping Ping SMTP server
POST /api/v1/admin/email/broadcast Broadcast email to users
GET /api/v1/admin/email/events List email events
GET /api/v1/admin/email/templates List email templates
PUT /api/v1/admin/email/templates Create/update template
DELETE /api/v1/admin/email/templates/:slug Delete template
POST /api/v1/admin/email/templates/preview Preview template

License Management

Method Path Description
POST /api/v1/admin/licenses/activate Activate license key
POST /api/v1/admin/licenses/import Import license file
GET /api/v1/admin/licenses List licenses
GET /api/v1/admin/licenses/:id Get license details
POST /api/v1/admin/licenses/:id/revoke Revoke license
GET /api/v1/admin/licenses/status License status summary
GET /api/v1/admin/licenses/usage Usage statistics
GET /api/v1/admin/licenses/combined-limits Combined limits

Identity Providers

Method Path Description
GET /api/v1/admin/auth/providers List identity providers
POST /api/v1/admin/auth/providers Create provider (OAuth, LDAP, SAML)
PUT /api/v1/admin/auth/providers/:id Update provider
DELETE /api/v1/admin/auth/providers/:id Delete provider
POST /api/v1/admin/auth/ldap/test-connection Test LDAP connection

Backup Management

Method Path Description
GET /api/v1/admin/backups/configs List backup configs
POST /api/v1/admin/backups/configs Create backup config
PUT /api/v1/admin/backups/configs/:id Update backup config
DELETE /api/v1/admin/backups/configs/:id Delete backup config
GET /api/v1/admin/backups/configs/:id/backups List backups for config
POST /api/v1/admin/backups/create Create backup now
GET /api/v1/admin/backups/download Download backup file
POST /api/v1/admin/backups/restore Restore from backup
DELETE /api/v1/admin/backups/delete Delete backup

Database Monitoring

Method Path Description
GET /api/v1/admin/database/health Database health check
GET /api/v1/admin/database/health-dashboard Full health dashboard
GET /api/v1/admin/database/indexes List indexes
GET /api/v1/admin/database/indexes/unused Find unused indexes
DELETE /api/v1/admin/database/indexes/unused Drop unused indexes
GET /api/v1/admin/database/tables List tables with stats
GET /api/v1/admin/database/maintenance Maintenance recommendations
POST /api/v1/admin/database/maintenance Run auto maintenance

Webhooks

Method Path Description
GET /api/v1/admin/webhooks List admin webhooks
POST /api/v1/admin/webhooks Create webhook
DELETE /api/v1/admin/webhooks/:id Delete webhook

Audit and Jobs

Method Path Description
GET /api/v1/admin/audit/export Export audit logs (csv, json, syslog, cef)
GET /api/v1/admin/jobs/executions List job executions
GET /api/v1/admin/jobs/statistics Job statistics
POST /api/v1/admin/jobs/trigger Trigger job manually
GET /api/v1/admin/ai-audit List AI usage audit
GET /api/v1/admin/ai-audit/export Export AI audit (CSV)

Telemetry

Method Path Description
GET /api/v1/admin/telemetry-settings Get telemetry settings
PUT /api/v1/admin/telemetry-settings Update telemetry settings

MCP Marketplace (Admin)

Method Path Description
GET /api/v1/admin/mcp-servers List MCP servers
POST /api/v1/admin/mcp-servers Add MCP server
GET /api/v1/admin/mcp-servers/:id Get MCP server
PUT /api/v1/admin/mcp-servers/:id Update MCP server
DELETE /api/v1/admin/mcp-servers/:id Delete MCP server
GET /api/v1/admin/mcp-servers/:id/tools List server tools
PUT /api/v1/admin/mcp-servers/:id/tools/:toolName Toggle tool
POST /api/v1/admin/mcp-servers/:id/check Check connection
POST /api/v1/admin/mcp-servers/:id/refresh Refresh tools

Integration Tokens

Method Path Description
GET /api/v1/integrations List integration tokens
POST /api/v1/integrations Create integration token (admin)
DELETE /api/v1/integrations/:id Delete integration
POST /api/v1/integrations/:id/revoke Revoke token
POST /api/v1/integrations/:id/rotate Rotate token
GET /api/v1/integrations/status Runner status
POST /api/v1/integrations/namespace/:ns Create namespace integration
POST /api/v1/runners/register Register runner agent

14. Utility Endpoints

Converters (no auth required)

Method Path Description
POST /api/v1/utils/convert-xml-to-json Convert XML to JSON
POST /api/v1/utils/convert-txt-to-base64 Encode text as Base64
POST /api/v1/utils/extract-jpath Extract values via JsonPath

Mock Generation from Specs

Method Path Description
POST /api/v1/generators/openapi/preview Preview mocks from OpenAPI
POST /api/v1/generators/openapi Generate mocks from OpenAPI
POST /api/v1/generators/soap/preview Preview mocks from WSDL
POST /api/v1/generators/soap Generate mocks from WSDL
POST /api/v1/generators/grpc/preview Preview mocks from .proto
POST /api/v1/generators/grpc Generate mocks from .proto
POST /api/v1/generators/graphql/preview Preview mocks from GraphQL
POST /api/v1/generators/graphql Generate mocks from GraphQL
POST /api/v1/generators/har/preview Preview mocks from HAR
POST /api/v1/generators/har Generate mocks from HAR
POST /api/v1/generators/mcp/preview Preview mocks from MCP
POST /api/v1/generators/mcp Generate mocks from MCP
POST /api/v1/generators/socket Generate Socket mocks

AI Features

Method Path Description
POST /api/v1/ai/generate-test-script Generate test script (AI)
POST /api/v1/ai/generate-perf-script Generate perf script (AI)
POST /api/v1/ai/diagnose-error Diagnose error (AI)
POST /api/v1/ai/generate-mock Generate mock from description (AI)
POST /api/v1/ai/improve-mock Improve existing mock (AI)
POST /api/v1/ai/analyze-test-results Analyze test results (AI)
POST /api/v1/ai/analyze-test-run-report Analyze test run report (AI)
POST /api/v1/ai/analyze-api-diff Analyze API diff (AI)
POST /api/v1/ai/analyze-logs Analyze mock logs (AI)
POST /api/v1/ai/generate-collection Generate collection from description (AI)

Notifications

Method Path Description
GET /api/v1/notifications List notifications
GET /api/v1/notifications/unread-count Unread count
POST /api/v1/notifications/:id/read Mark as read
POST /api/v1/notifications/read-all Mark all read
DELETE /api/v1/notifications/:id Delete notification
GET /api/v1/notifications/preferences Get preferences
PUT /api/v1/notifications/preferences Update preferences

Agent Tasks

Method Path Description
GET /api/v1/agent/tasks List agent tasks
POST /api/v1/agent/tasks Submit agent task
DELETE /api/v1/agent/tasks Clear all agent tasks
GET /api/v1/agent/tasks/:id Get task details
DELETE /api/v1/agent/tasks/:id Delete a specific task
POST /api/v1/agent/tasks/:id/cancel Cancel running task
POST /api/v1/agent/tasks/:id/rerun Rerun a completed task
GET /api/v1/agent/tasks/:id/export Export task result
GET /api/v1/agent/tasks/:id/events SSE stream for task events

Health and Monitoring

Method Path Description
GET /health Full health check (DB, cache status)
GET /health/live Liveness probe (returns 200)
GET /health/ready Readiness probe
GET /metrics Prometheus metrics
GET /swagger/ Swagger UI
GET /swagger/doc.json Swagger spec (JSON)
GET /api/v1/stats Dashboard statistics
GET /api/v1/counts Resource counts
GET /api/v1/status System status
GET /api/v1/system-metrics System metrics
GET /api/v1/features Feature flags
GET /api/v1/features/check Check specific features

Health response example:

{
  "status": "up",
  "releaseId": "1.2.3",
  "checks": {
    "database": {"status": "up"},
    "cache": {"status": "up"}
  }
}

Dashboards

Method Path Description
GET /api/v1/dashboards/mock-stats Mock usage statistics
GET /api/v1/dashboards/comprehensive-stats Full dashboard data
GET /api/v1/dashboards/testing-stats Testing dashboard data

MCP Server Endpoint

Mockarty exposes an MCP (Model Context Protocol) server at GET /mcp/sse. Connect AI tools (Claude Desktop, Cursor) to manage mocks via natural language.

SSE Events

Method Path Description
GET /api/v1/events SSE stream for real-time UI updates

15. Protocol Proxy Endpoints

Internal endpoints used by generated protocol servers to resolve mocks. No auth required.

Method Path Description
POST /mock/findGrpc Resolve gRPC mock
POST /mock/findSocket Resolve WebSocket/TCP/UDP mock
POST /mock/findKafka Resolve Kafka mock
POST /mock/findRabbitMQ Resolve RabbitMQ mock
POST /mock/findSmtp Resolve SMTP mock
ANY /stubs/* HTTP mock resolution (catch-all)

How /stubs/* Routing Works

The /stubs/* endpoint is the main mock resolution route. It matches any HTTP method and resolves the appropriate mock based on route, method, conditions, and priority. No authentication is required to call stubs – this is by design, since your application under test calls these endpoints directly.

Namespace routing: The namespace is extracted from the URL path — include it as the first segment after /stubs/. You can also pass it as a query parameter instead. When neither is present, Mockarty falls back to sandbox.

# Recommended: namespace explicit in path (unambiguous, always works)
curl http://localhost:5770/stubs/sandbox/api/users/123
curl http://localhost:5770/stubs/staging/api/users/123

# Alternative: namespace in query parameter
curl "http://localhost:5770/stubs/sandbox/api/users/123?namespace=staging"

# POST with body (conditions are matched against the body)
curl -X POST http://localhost:5770/stubs/sandbox/api/orders \
  -H "Content-Type: application/json" \
  -d '{"customerId": "cust-1", "items": [{"id": "item-1", "price": 29.99}]}'

Template Prefixes in Responses

When building mock responses, Mockarty supports special prefixes to inject dynamic data:

Prefix Description Example
$.fake.* Faker-generated data $.fake.UUID, $.fake.Email, $.fake.FirstName
$.req.* or $.body.* Request body fields $.req.userId, $.body.order.items[0].id
$.reqHeader.* Request headers $.reqHeader.Authorization[0]
$.queryParams.* Query parameters $.queryParams.limit
$.pathParam.* URL path parameters $.pathParam.id (for route /api/users/:id)
$.namespace Current namespace name $.namespace
$.gS.* Global Store values $.gS.totalUsers
$.cS.* Chain Store values $.cS.orderId
$.mS.* Mock Store values $.mS.tempKey

Path parameters example:

cURL

# Create a mock with path parameter extraction (namespace "sandbox" is the default)
curl -X POST http://localhost:5770/api/v1/mocks \
  -H "Content-Type: application/json" \
  -d '{
    "id": "get-user-by-id",
    "namespace": "sandbox",
    "http": {
      "route": "/api/users/:id",
      "httpMethod": "GET"
    },
    "response": {
      "statusCode": 200,
      "payload": {
        "userId": "$.pathParam.id",
        "name": "$.fake.FirstName",
        "namespace": "$.namespace"
      }
    }
  }'

# Call it — namespace is always the first path segment after /stubs/
curl http://localhost:5770/stubs/sandbox/api/users/42
# Returns: {"userId": "42", "name": "Alice", "namespace": "sandbox"}

CLI

mockarty-cli mock create \
  --id get-user-by-id \
  --route /api/users/:id \
  --method GET \
  --status 200 \
  --body '{"userId": "$.pathParam.id", "name": "$.fake.FirstName", "namespace": "$.namespace"}'

# Call it
curl http://localhost:5770/stubs/sandbox/api/users/42

Go

mock := mockarty.NewMockBuilder().
    ID("get-user-by-id").
    HTTP(func(h *mockarty.HTTPBuilder) {
        h.Route("/api/users/:id").Method("GET")
    }).
    Response(func(r *mockarty.ResponseBuilder) {
        r.Status(200).JSONBody(map[string]any{
            "userId":    "$.pathParam.id",
            "name":      "$.fake.FirstName",
            "namespace": "$.namespace",
        })
    }).
    Build()

_, err := client.Mocks().Create(context.Background(), mock)

Python

mock = (
    MockBuilder.http("/api/users/:id", "GET")
    .id("get-user-by-id")
    .respond(200, body={
        "userId": "$.pathParam.id",
        "name": "$.fake.FirstName",
        "namespace": "$.namespace",
    })
    .build()
)

client.mocks.create(mock)

Java

Mock mock = MockBuilder.http("/api/users/:id", "GET")
    .id("get-user-by-id")
    .respond(200, Map.of(
        "userId", "$.pathParam.id",
        "name", "$.fake.FirstName",
        "namespace", "$.namespace"
    ))
    .build();

client.mocks().create(mock);

Path Parameter Mock Example