MockServer has the following internal state:

  • recorded requests
  • active expectations
  • recorded expectations
  • logs

State can be cleared from MockServer selectively:

  • use type to select which type of state to clear, supported values are: all, log, expectations
  • use a request matcher to clear matching items
  • use an expectation id to clear matching items

What each type affects: the type parameter is important for memory management. expectations clears only the configured expectations — it does not clear the recorded request / event log. On a long-running instance the request log grows with every request, so clearing expectations alone will not free that memory. To free memory held by accumulated log entries, use log or all, or perform a full reset with PUT /mockserver/reset.

Operation Expectations Request / event log
clear?type=expectations cleared kept
clear?type=log kept cleared
clear?type=all (the default when type is omitted) cleared cleared
PUT /mockserver/reset cleared cleared

Note: a request matcher or expectation id narrows clearing to matching items; reset always clears everything and ignores any matcher. An empty request matcher (request() or {}) narrows nothing: it clears everything of the chosen type, including DNS, binary and not(...) expectations, just like an empty body.

How clearing works: when logLevel is INFO or lower (the default), cleared log entries are soft-deleted rather than physically removed. This means:

  • Verification works correctly — the verify endpoint ignores cleared entries, so verifying a request after clearing will behave as if the logs were fully removed
  • Retrieve works correctly — the retrieve endpoint for requests, recorded expectations, and log messages filters out cleared entries
  • UI may still show cleared entries — the UI can display soft-deleted entries (marked as deleted) to help debug issues

If you want cleared log entries to be physically removed from memory, set the log level to WARN or higher.

new MockServerClient("localhost", 1080).clear(
    request(),
    ClearType.LOG
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080)
  .clear({}, 'LOG')
  .then(
    function () {
      console.log("cleared recorded requests and logs that matches request matcher");
    },
    function (error) {
      console.log(error);
    }
  );

See REST API for full JSON specification

from mockserver.client import MockServerClient

client = MockServerClient("localhost", 1080)
client.clear(clear_type="LOG")
require 'mockserver-client'

client = MockServer::Client.new('localhost', 1080)
client.clear(type: 'LOG')
import mockserver "github.com/mock-server/mockserver-monorepo/mockserver-client-go/v9"

client := mockserver.New("localhost", 1080)
client.Clear(nil, mockserver.ClearLog)
using MockServer.Client;

using var client = new MockServerClient("localhost", 1080);
client.Clear(type: "LOG");
use mockserver_client::{ClientBuilder, ClearType};

let client = ClientBuilder::new("localhost", 1080).build().unwrap();
client.clear(None, Some(ClearType::Log)).unwrap();
use MockServer\MockServerClient;

$client = new MockServerClient('localhost', 1080);
$client->clear(null, 'LOG');
curl -v -X PUT "http://localhost:1080/mockserver/clear?type=log"

See REST API for full JSON specification

new MockServerClient("localhost", 1080).clear(
    request()
        .withPath("/some/path")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080)
  .clear({
    'path': '/some/path'
  })
  .then(
    function () {
      console.log("cleared state that matches request matcher");
    },
    function (error) {
      console.log(error);
    }
  );

See REST API for full JSON specification

from mockserver.client import MockServerClient
from mockserver.models import HttpRequest

client = MockServerClient("localhost", 1080)
client.clear(
    HttpRequest.request("/some/path")
)
require 'mockserver-client'

client = MockServer::Client.new('localhost', 1080)
client.clear(
    MockServer::HttpRequest.new(path: '/some/path')
)
import mockserver "github.com/mock-server/mockserver-monorepo/mockserver-client-go/v9"

client := mockserver.New("localhost", 1080)
client.Clear(
    mockserver.Request().Path("/some/path"),
    mockserver.ClearAll,
)
using MockServer.Client;
using MockServer.Client.Models;

using var client = new MockServerClient("localhost", 1080);
client.Clear(
    HttpRequest.Request().WithPath("/some/path")
);
use mockserver_client::{ClientBuilder, HttpRequest};

let client = ClientBuilder::new("localhost", 1080).build().unwrap();
client.clear(
    Some(&HttpRequest::new().path("/some/path")),
    None,
).unwrap();
use MockServer\MockServerClient;
use MockServer\HttpRequest;

$client = new MockServerClient('localhost', 1080);
$client->clear(
    HttpRequest::request()
        ->path('/some/path')
);
curl -v -X PUT "http://localhost:1080/mockserver/clear" -d '{
    "path": "/some/path"
}'

See REST API for full JSON specification

new MockServerClient("localhost", 1080).clear(
    openAPI(
        "https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json",
        "showPetById"
    )
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080)
    .clear({
        "specUrlOrPayload": "https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json",
        "operationId": "showPetById"
    })
    .then(
        function () {
            console.log("cleared state that matches request matcher");
        },
        function (error) {
            console.log(error);
        }
    );

See REST API for full JSON specification

The typed clear method takes a request matcher; to clear by an OpenAPI matcher send the JSON body to the control-plane endpoint directly.

import json
import urllib.request

body = json.dumps({
    "specUrlOrPayload": "https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json",
    "operationId": "showPetById"
})
req = urllib.request.Request(
    "http://localhost:1080/mockserver/clear",
    data=body.encode("utf-8"),
    method="PUT",
    headers={"Content-Type": "application/json"},
)
urllib.request.urlopen(req)

The typed clear method takes a request matcher; to clear by an OpenAPI matcher send the JSON body to the control-plane endpoint directly.

require 'net/http'
require 'json'

uri = URI('http://localhost:1080/mockserver/clear')
body = JSON.generate({
    'specUrlOrPayload' => 'https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json',
    'operationId' => 'showPetById'
})
request = Net::HTTP::Put.new(uri, 'Content-Type' => 'application/json')
request.body = body
Net::HTTP.start(uri.host, uri.port) { |http| http.request(request) }

The typed Clear method takes a request matcher; to clear by an OpenAPI matcher send the JSON body to the control-plane endpoint directly.

import (
    "net/http"
    "strings"
)

body := `{
    "specUrlOrPayload": "https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json",
    "operationId": "showPetById"
}`
req, _ := http.NewRequest("PUT",
    "http://localhost:1080/mockserver/clear",
    strings.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)

The typed Clear method takes a request matcher; to clear by an OpenAPI matcher send the JSON body to the control-plane endpoint directly.

using System.Net.Http;
using System.Text;

using var httpClient = new HttpClient();
var json = @"{
    ""specUrlOrPayload"": ""https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json"",
    ""operationId"": ""showPetById""
}";
await httpClient.PutAsync(
    "http://localhost:1080/mockserver/clear",
    new StringContent(json, Encoding.UTF8, "application/json")
);

The typed clear method takes a request matcher; to clear by an OpenAPI matcher send the JSON body to the control-plane endpoint directly.

use reqwest::blocking::Client;

let client = Client::new();
let body = r#"{
    "specUrlOrPayload": "https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json",
    "operationId": "showPetById"
}"#;
client.put("http://localhost:1080/mockserver/clear")
    .header("Content-Type", "application/json")
    .body(body.to_string())
    .send()
    .unwrap();

The typed clear method takes a request matcher; to clear by an OpenAPI matcher send the JSON body to the control-plane endpoint directly.

$json = <<<'JSON'
{
    "specUrlOrPayload": "https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json",
    "operationId": "showPetById"
}
JSON;

$ch = curl_init('http://localhost:1080/mockserver/clear');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST  => 'PUT',
    CURLOPT_POSTFIELDS     => $json,
    CURLOPT_HTTPHEADER     => ['Content-Type: application/json; charset=utf-8'],
    CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/clear" -d '{
        "specUrlOrPayload": "https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json",
        "operationId": "showPetById"
    }'

See REST API for full JSON specification

new MockServerClient("localhost", 1080)
    .clear("31e4ca35-66c6-4645-afeb-6e66c4ca0559");
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080)
    .clearById("31e4ca35-66c6-4645-afeb-6e66c4ca0559")
    .then(
        function () {
            console.log("cleared state that matches expectation id");
        },
        function (error) {
            console.log(error);
        }
    );

See REST API for full JSON specification

from mockserver.client import MockServerClient

client = MockServerClient("localhost", 1080)
client.clear_by_id("31e4ca35-66c6-4645-afeb-6e66c4ca0559")
require 'mockserver-client'

client = MockServer::Client.new('localhost', 1080)
client.clear_by_id('31e4ca35-66c6-4645-afeb-6e66c4ca0559')
import mockserver "github.com/mock-server/mockserver-monorepo/mockserver-client-go/v9"

client := mockserver.New("localhost", 1080)
client.ClearByID("31e4ca35-66c6-4645-afeb-6e66c4ca0559", mockserver.ClearAll)
using MockServer.Client;

using var client = new MockServerClient("localhost", 1080);
client.ClearById("31e4ca35-66c6-4645-afeb-6e66c4ca0559");
use mockserver_client::ClientBuilder;

let client = ClientBuilder::new("localhost", 1080).build().unwrap();
client.clear_by_id("31e4ca35-66c6-4645-afeb-6e66c4ca0559", None).unwrap();
use MockServer\MockServerClient;

$client = new MockServerClient('localhost', 1080);
$client->clearById('31e4ca35-66c6-4645-afeb-6e66c4ca0559');
curl -X PUT "http://localhost:1080/mockserver/clear" -d '{
    "id": "31e4ca35-66c6-4645-afeb-6e66c4ca0559"
}'

See REST API for full JSON specification

new MockServerClient("localhost", 1080).clear(
    request()
        .withPath("/some/path"),
    ClearType.LOG
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080)
  .clear({
    'path': '/some/path'
  }, 'LOG')
  .then(
    function () {
      console.log("cleared recorded requests and logs that matches request matcher");
    },
    function (error) {
      console.log(error);
    }
  );

See REST API for full JSON specification

from mockserver.client import MockServerClient
from mockserver.models import HttpRequest

client = MockServerClient("localhost", 1080)
client.clear(
    HttpRequest.request("/some/path"),
    clear_type="LOG"
)
require 'mockserver-client'

client = MockServer::Client.new('localhost', 1080)
client.clear(
    MockServer::HttpRequest.new(path: '/some/path'),
    type: 'LOG'
)
import mockserver "github.com/mock-server/mockserver-monorepo/mockserver-client-go/v9"

client := mockserver.New("localhost", 1080)
client.Clear(
    mockserver.Request().Path("/some/path"),
    mockserver.ClearLog,
)
using MockServer.Client;
using MockServer.Client.Models;

using var client = new MockServerClient("localhost", 1080);
client.Clear(
    HttpRequest.Request().WithPath("/some/path"),
    "LOG"
);
use mockserver_client::{ClientBuilder, HttpRequest, ClearType};

let client = ClientBuilder::new("localhost", 1080).build().unwrap();
client.clear(
    Some(&HttpRequest::new().path("/some/path")),
    Some(ClearType::Log),
).unwrap();
use MockServer\MockServerClient;
use MockServer\HttpRequest;

$client = new MockServerClient('localhost', 1080);
$client->clear(
    HttpRequest::request()
        ->path('/some/path'),
    'LOG'
);
curl -v -X PUT "http://localhost:1080/mockserver/clear?type=log" -d '{
    "path": "/some/path"
}'

See REST API for full JSON specification

new MockServerClient("localhost", 1080).clear(
    openAPI(
        "https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json",
        "showPetById"
    ),
    ClearType.LOG
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080)
    .clear({
        "specUrlOrPayload": "https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json",
        "operationId": "showPetById"
    }, 'LOG')
    .then(
        function () {
            console.log("cleared state that matches request matcher");
        },
        function (error) {
            console.log(error);
        }
    );

See REST API for full JSON specification

The typed clear method takes a request matcher; to clear by an OpenAPI matcher send the JSON body to the control-plane endpoint directly.

import json
import urllib.request

body = json.dumps({
    "specUrlOrPayload": "https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json",
    "operationId": "showPetById"
})
req = urllib.request.Request(
    "http://localhost:1080/mockserver/clear?type=log",
    data=body.encode("utf-8"),
    method="PUT",
    headers={"Content-Type": "application/json"},
)
urllib.request.urlopen(req)

The typed clear method takes a request matcher; to clear by an OpenAPI matcher send the JSON body to the control-plane endpoint directly.

require 'net/http'
require 'json'

uri = URI('http://localhost:1080/mockserver/clear?type=log')
body = JSON.generate({
    'specUrlOrPayload' => 'https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json',
    'operationId' => 'showPetById'
})
request = Net::HTTP::Put.new(uri, 'Content-Type' => 'application/json')
request.body = body
Net::HTTP.start(uri.host, uri.port) { |http| http.request(request) }

The typed Clear method takes a request matcher; to clear by an OpenAPI matcher send the JSON body to the control-plane endpoint directly.

import (
    "net/http"
    "strings"
)

body := `{
    "specUrlOrPayload": "https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json",
    "operationId": "showPetById"
}`
req, _ := http.NewRequest("PUT",
    "http://localhost:1080/mockserver/clear?type=log",
    strings.NewReader(body))
req.Header.Set("Content-Type", "application/json")
http.DefaultClient.Do(req)

The typed Clear method takes a request matcher; to clear by an OpenAPI matcher send the JSON body to the control-plane endpoint directly.

using System.Net.Http;
using System.Text;

using var httpClient = new HttpClient();
var json = @"{
    ""specUrlOrPayload"": ""https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json"",
    ""operationId"": ""showPetById""
}";
await httpClient.PutAsync(
    "http://localhost:1080/mockserver/clear?type=log",
    new StringContent(json, Encoding.UTF8, "application/json")
);

The typed clear method takes a request matcher; to clear by an OpenAPI matcher send the JSON body to the control-plane endpoint directly.

use reqwest::blocking::Client;

let client = Client::new();
let body = r#"{
    "specUrlOrPayload": "https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json",
    "operationId": "showPetById"
}"#;
client.put("http://localhost:1080/mockserver/clear?type=log")
    .header("Content-Type", "application/json")
    .body(body.to_string())
    .send()
    .unwrap();

The typed clear method takes a request matcher; to clear by an OpenAPI matcher send the JSON body to the control-plane endpoint directly.

$json = <<<'JSON'
{
    "specUrlOrPayload": "https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json",
    "operationId": "showPetById"
}
JSON;

$ch = curl_init('http://localhost:1080/mockserver/clear?type=log');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST  => 'PUT',
    CURLOPT_POSTFIELDS     => $json,
    CURLOPT_HTTPHEADER     => ['Content-Type: application/json; charset=utf-8'],
    CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
curl -v -X PUT "http://localhost:1080/mockserver/clear?type=log" -d '{
        "specUrlOrPayload": "https://raw.githubusercontent.com/mock-server/mockserver-monorepo/master/mockserver/mockserver-integration-testing/src/main/resources/org/mockserver/openapi/openapi_petstore_example.json",
        "operationId": "showPetById"
    }'

See REST API for full JSON specification

new MockServerClient("localhost", 1080).clear(
    request()
        .withPath("/some/path"),
    ClearType.EXPECTATIONS
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080)
  .clear({
    'path': '/some/path'
  }, 'EXPECTATIONS')
  .then(
    function () {
      console.log("cleared expectations that matches request matcher");
    },
    function (error) {
      console.log(error);
    }
  );

See REST API for full JSON specification

from mockserver.client import MockServerClient
from mockserver.models import HttpRequest

client = MockServerClient("localhost", 1080)
client.clear(
    HttpRequest.request("/some/path"),
    clear_type="EXPECTATIONS"
)
require 'mockserver-client'

client = MockServer::Client.new('localhost', 1080)
client.clear(
    MockServer::HttpRequest.new(path: '/some/path'),
    type: 'EXPECTATIONS'
)
import mockserver "github.com/mock-server/mockserver-monorepo/mockserver-client-go/v9"

client := mockserver.New("localhost", 1080)
client.Clear(
    mockserver.Request().Path("/some/path"),
    mockserver.ClearExpectations,
)
using MockServer.Client;
using MockServer.Client.Models;

using var client = new MockServerClient("localhost", 1080);
client.Clear(
    HttpRequest.Request().WithPath("/some/path"),
    "EXPECTATIONS"
);
use mockserver_client::{ClientBuilder, HttpRequest, ClearType};

let client = ClientBuilder::new("localhost", 1080).build().unwrap();
client.clear(
    Some(&HttpRequest::new().path("/some/path")),
    Some(ClearType::Expectations),
).unwrap();
use MockServer\MockServerClient;
use MockServer\HttpRequest;

$client = new MockServerClient('localhost', 1080);
$client->clear(
    HttpRequest::request()
        ->path('/some/path'),
    'EXPECTATIONS'
);
curl -v -X PUT "http://localhost:1080/mockserver/clear?type=expectations" -d '{
    "path": "/some/path"
}'

See REST API for full JSON specification

MockServer can be reset completely, as follows:

new MockServerClient("localhost", 1080).reset();
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080)
  .reset()
  .then(
    function () {
      console.log("reset all state");
    },
    function (error) {
      console.log(error);
    }
  );

See REST API for full JSON specification

from mockserver.client import MockServerClient

client = MockServerClient("localhost", 1080)
client.reset()
require 'mockserver-client'

client = MockServer::Client.new('localhost', 1080)
client.reset
import mockserver "github.com/mock-server/mockserver-monorepo/mockserver-client-go/v9"

client := mockserver.New("localhost", 1080)
client.Reset()
using MockServer.Client;

using var client = new MockServerClient("localhost", 1080);
client.Reset();
use mockserver_client::ClientBuilder;

let client = ClientBuilder::new("localhost", 1080).build().unwrap();
client.reset().unwrap();
use MockServer\MockServerClient;

$client = new MockServerClient('localhost', 1080);
$client->reset();
curl -v -X PUT "http://localhost:1080/mockserver/reset"

See REST API for full JSON specification

 

Clearing by namespace (multi-tenancy)

When multiple teams or test suites share one MockServer instance, expectations can be scoped to a namespace (tenant) so each owner can clean up only its own expectations without disturbing anyone else's. An expectation with no namespace (the default) is global and is matched regardless of any request namespace.

Add ?namespace=<name> to PUT /mockserver/clear to clear only that namespace's expectations (the event log is not namespaced, so it is left untouched even with type=all). The namespace can also be supplied as a header instead of the query parameter — see matchNamespaceHeader — the query parameter takes precedence when both are present.

new MockServerClient("localhost", 1080).clearByNamespace("team-checkout");
curl -v -X PUT "http://localhost:1080/mockserver/clear?type=expectations&namespace=team-checkout"

Or with the configured namespace header instead of the query parameter:

curl -v -X PUT "http://localhost:1080/mockserver/clear?type=expectations" \
  -H "X-MockServer-Namespace: team-checkout"

To create an expectation scoped to a namespace in the first place, see withNamespace(...) on the Java client.

 

Clearing by metadata or unused expectations

You can clear only the expectations whose metadata matches, or only the expectations that have never matched a request, for example to remove mocks a test suite no longer uses. Like a namespace clear, these remove expectations only and leave the event log untouched, even with type=all.

Add these query parameters to PUT /mockserver/clear:

  • metadataKey=<key>: the expectation's metadata has this key. Add metadataValue=<value> to also require the value. The value matches a stored text equal to it, or a stored JSON value equal to it read as JSON: metadataValue=42 matches both the number 42 and the text "42", and metadataValue=%22team-a%22 also matches the text team-a.
  • metadataJsonPath=<JSONPath>: the JSONPath, applied to the metadata object, selects something, for example $.tags[?(@ == 'smoke')].
  • unmatched=true: the expectation has not matched any request since it was created or last changed. Each MockServer instance keeps its own count.

When you combine these with each other, with namespace, or with a request matcher or expectation id in the body, an expectation is cleared only if it matches all of them.

To protect you from clearing everything by mistake, an empty value (for example metadataKey= when a script variable is unset), or unmatched=false on its own, is rejected with 400 Bad Request and nothing is cleared. Parameter names are not case-sensitive. A parameter given twice, or one whose name starts with metadata or unmatched but is not one of the parameters above (such as metadata_key), is also rejected. Any other unknown parameter is ignored, as on every MockServer endpoint, so check the spelling before you clear: a misspelling such as metaKey=owner is ignored and the clear is not filtered. Values are used exactly as given, so a value starting with ! or ? is not treated as a "not" or "optional" matcher.

URL-encode every value: send % as %25, + as %2B (a plain + means a space), & as %26 and # as %23 (HTTP clients drop everything from a plain #, so metadataKey=env#prod would be sent as metadataKey=env). With curl, -G --data-urlencode does this for you. A query string that cannot be decoded, such as metadataValue=100%, is rejected with 400 and nothing is cleared. So is an empty namespace= on clear.

new MockServerClient("localhost", 1080).clearByMetadata("owner", "team-checkout");

To clear every expectation that has a key, whatever its value, use clearByMetadataKey("owner"). A null value is refused rather than read as "any value".

Or with a JSONPath on the metadata:

new MockServerClient("localhost", 1080).clear(
    null,
    ExpectationFilter.expectationFilter().withMetadataJsonPath("$.tags[?(@ == 'smoke')]")
);
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).clearByMetadata("owner", "team-checkout");
// any value for the key: clearByMetadataKey("owner")
from mockserver.client import MockServerClient

client = MockServerClient("localhost", 1080)
client.clear_by_metadata("owner", "team-checkout")
# any value for the key: client.clear_by_metadata_key("owner")
require 'mockserver-client'

client = MockServer::Client.new('localhost', 1080)
client.clear_by_metadata('owner', 'team-checkout')
# any value for the key: client.clear_by_metadata_key('owner')
import mockserver "github.com/mock-server/mockserver-monorepo/mockserver-client-go/v9"

client := mockserver.New("localhost", 1080)
err := client.ClearByMetadata("owner", "team-checkout")
// any value for the key: client.ClearByMetadataKey("owner")
using MockServer.Client;

using var client = new MockServerClient("localhost", 1080);
client.ClearByMetadata("owner", "team-checkout");
// any value for the key: client.ClearByMetadataKey("owner");
use mockserver_client::ClientBuilder;

let client = ClientBuilder::new("localhost", 1080).build().unwrap();
client.clear_by_metadata("owner", "team-checkout").unwrap();
// any value for the key: client.clear_by_metadata_key("owner")
use MockServer\MockServerClient;

$client = new MockServerClient('localhost', 1080);
$client->clearByMetadata('owner', 'team-checkout');
// any value for the key: $client->clearByMetadataKey('owner');
curl -v -X PUT "http://localhost:1080/mockserver/clear?type=expectations&metadataKey=owner&metadataValue=team-checkout"

With a JSONPath, let curl encode it:

curl -v -X PUT -G "http://localhost:1080/mockserver/clear" \
  --data-urlencode "type=expectations" \
  --data-urlencode "metadataJsonPath=$.tags[?(@ == 'smoke')]"
new MockServerClient("localhost", 1080).clearUnmatchedExpectations();
var mockServerClient = require('mockserver-client').mockServerClient;
mockServerClient("localhost", 1080).clearUnmatchedExpectations();
from mockserver.client import MockServerClient

MockServerClient("localhost", 1080).clear_unmatched_expectations()
require 'mockserver-client'

MockServer::Client.new('localhost', 1080).clear_unmatched_expectations
import mockserver "github.com/mock-server/mockserver-monorepo/mockserver-client-go/v9"

err := mockserver.New("localhost", 1080).ClearUnmatchedExpectations()
using MockServer.Client;

using var client = new MockServerClient("localhost", 1080);
client.ClearUnmatchedExpectations();
use mockserver_client::ClientBuilder;

let client = ClientBuilder::new("localhost", 1080).build().unwrap();
client.clear_unmatched_expectations().unwrap();
use MockServer\MockServerClient;

(new MockServerClient('localhost', 1080))->clearUnmatchedExpectations();
curl -v -X PUT "http://localhost:1080/mockserver/clear?type=expectations&unmatched=true"