Count matches for several searches

Add MCP server to your AI tool

Allow AI tools and LLMs to interact with the API documentation portal through MCP.

MCP server URL

https://docs.usehearsay.com/mcp

Standard setup for AI tools providing an mcp.json file

mcp.json
{
  "integrations MCP server": {
    "url": "https://docs.usehearsay.com/mcp"
  }
}

Close
POST /local-emails/{caseId}/search-counts

For each boolean search query, and each email address, returns how many emails in the case match (only in one mailbox when providerId is given; on a case shared with opposing counsel, only in threads the caller may see). A malformed query gets an error on its own row instead of failing the whole request.

Path parameters

  • caseId string Required
application/json

Body Required

  • queries array[string]

    Boolean query strings. Each is counted independently against the indexed email fields (subject, body, snippet, from/to/cc/bcc). Supports the same AND / OR / NOT / -prefix, parentheses, "quoted phrases" and wildcards as the boolean query parser.

  • emails array[string]

    Email addresses. Each is counted as the number of emails where the address appears as any participant (from/to/cc/bcc), case-insensitive.

  • providerId string

    Optional: narrow the counts to a single email provider (mailbox) within the case. When omitted, counts span the whole case.

Responses

  • 200 application/json
    Hide response attributes Show response attributes object
    • data object Required
      Hide data attributes Show data attributes object
      • queries array[object] Required
        Hide queries attributes Show queries attributes object
        • query string Required

          The query string, echoed back.

        • count number Required

          Number of emails matching the query.

        • error string

          Set when the query could not be counted (parse error or search failure). When present, count is 0 and is not meaningful.

      • emails array[object] Required
        Hide emails attributes Show emails attributes object
        • email string Required

          The email address, echoed back.

        • count number Required

          Number of emails where this address is a participant (from/to/cc/bcc).

    • statusCode number Required
    • timestamp string(date-time) Required
POST /local-emails/{caseId}/search-counts
curl \
 --request POST 'http://api.example.com/local-emails/{caseId}/search-counts' \
 --header "Authorization: Bearer $ACCESS_TOKEN" \
 --header "Content-Type: application/json" \
 --data '{
  "queries": [
    "\"confidentiality agreement\"",
    "(Nigeria OR Cyprus) AND NDA"
  ],
  "emails": [
    "string"
  ],
  "providerId": "string"
}'
Request examples
{
  "queries": [
    "\"confidentiality agreement\"",
    "(Nigeria OR Cyprus) AND NDA"
  ],
  "emails": [
    "string"
  ],
  "providerId": "string"
}
Response examples (200)
{
  "data": {
    "queries": [
      {
        "query": "agreement AND signed",
        "count": 17,
        "error": "search_failed"
      }
    ],
    "emails": [
      {
        "email": "john.roe@example.org",
        "count": 42
      }
    ]
  },
  "statusCode": 200,
  "timestamp": "2026-01-15T10:15:00.000Z"
}