> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getmcp.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Delete Call Logs by Filter

> Delete every call log matching the supplied filter set.

Deletes call-log rows that match the same filter shape used by [`GET /analytics/calls`](/api-reference/analytics/calls). The endpoint reuses the read-side filter builder, so anything you can list you can delete.

Typical use cases:

* Clear errors from a misbehaving tool while keeping success logs intact.
* Wipe a date window after running a load test against a production server.
* Drop the noisy `admin_test` client logs after a debugging session.

<Note>
  The endpoint **requires at least one real filter**. A `DELETE` with no filters returns `400` so you can't accidentally wipe the entire table — use the Settings page if that's actually the intent.
</Note>

<Note>
  Permission is gated on the WordPress core capability `manage_options`. Users with the lighter `getmcp_view_analytics` capability can read call logs but cannot delete them.
</Note>

## Query/Body Parameters

Filters can be passed either as query string params or in a JSON body — pick whichever is convenient. The filter set matches `GET /analytics/calls`.

<ParamField body="search" type="string">
  Substring matched against `server.name`, `tool.name`, `method`, `client_type`, `client_ip`, `error_message`.
</ParamField>

<ParamField body="server_id" type="string">
  Filter by server UUID. Anything that doesn't resolve to a known server is ignored.
</ParamField>

<ParamField body="status" type="string">
  Filter by `response_status`. One of: `success`, `error`.
</ParamField>

<ParamField body="from" type="string">
  Lower bound on `created_at` (`YYYY-MM-DD`, WP timezone, inclusive of start-of-day).
</ParamField>

<ParamField body="to" type="string">
  Upper bound on `created_at` (`YYYY-MM-DD`, WP timezone, inclusive of end-of-day).
</ParamField>

<ParamField body="method_group" type="string">
  Filter by JSON-RPC method family. One of: `tools`, `prompts`, `resources`.
</ParamField>

<ParamField body="min_response_time_ms" type="integer">
  Only delete rows where `response_time_ms >= N`. Useful for purging slow outliers.
</ParamField>

<RequestExample>
  ```bash cURL — clear all errors from a tool over a date window theme={null}
  curl --request DELETE \
       --url https://yoursite.com/wp-json/getmcp/v1/analytics/calls/filter \
       --header 'Authorization: Bearer gmcp_your_api_key' \
       --header 'content-type: application/json' \
       --data '{
         "server_id": "836995ae-1cff-41ec-823e-a4f07ccca3a0",
         "status": "error",
         "from": "2025-03-01",
         "to": "2025-03-15"
       }'
  ```

  ```python Python theme={null}
  import requests

  response = requests.delete(
      "https://yoursite.com/wp-json/getmcp/v1/analytics/calls/filter",
      headers={
          "Authorization": "Bearer gmcp_your_api_key",
          "Content-Type": "application/json",
      },
      json={
          "server_id": "836995ae-1cff-41ec-823e-a4f07ccca3a0",
          "status": "error",
          "from": "2025-03-01",
          "to": "2025-03-15",
      },
  )
  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    "https://yoursite.com/wp-json/getmcp/v1/analytics/calls/filter",
    {
      method: "DELETE",
      headers: {
        "Authorization": "Bearer gmcp_your_api_key",
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        server_id: "836995ae-1cff-41ec-823e-a4f07ccca3a0",
        status: "error",
        from: "2025-03-01",
        to: "2025-03-15",
      }),
    }
  );
  const data = await response.json();
  ```

  ```php PHP theme={null}
  $response = wp_remote_request(
      "https://yoursite.com/wp-json/getmcp/v1/analytics/calls/filter",
      [
          "method"  => "DELETE",
          "headers" => [
              "Authorization" => "Bearer gmcp_your_api_key",
              "Content-Type"  => "application/json",
          ],
          "body" => wp_json_encode([
              "server_id" => "836995ae-1cff-41ec-823e-a4f07ccca3a0",
              "status"    => "error",
              "from"      => "2025-03-01",
              "to"        => "2025-03-15",
          ]),
      ]
  );
  $data = json_decode( wp_remote_retrieve_body( $response ), true );
  ```
</RequestExample>

<ResponseExample>
  ```json 200 OK theme={null}
  {
    "deleted": 487
  }
  ```

  ```json 400 Bad Request — no filters theme={null}
  {
    "code": "rest_invalid_param",
    "message": "At least one filter is required to delete by filter. Use the Settings page to clear all logs.",
    "data": { "status": 400 }
  }
  ```

  ```json 403 Forbidden theme={null}
  {
    "code": "rest_forbidden",
    "message": "Permission denied.",
    "data": { "status": 403 }
  }
  ```
</ResponseExample>

## Response Fields

<ResponseField name="deleted" type="integer">
  Number of rows removed by the `DELETE` query. `0` is a valid response when the filter matched nothing.
</ResponseField>
