Search an IMAP mailbox's threads (internal)

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 /email-data/{caseId}/search-remote-imap-email-threads

Inbox-connect plumbing: searches the threads in a linked IMAP mailbox and marks which ones are already imported into the case. An extraction-code user may only name a mailbox linked to their own code (404 otherwise).

Path parameters

  • caseId string Required
application/json

Body Required

  • anyEmail array[string]
  • to array[string]
  • bcc array[string]
  • cc array[string]
  • from array[string]
  • hasAttachment boolean
  • receivedAfter string
  • receivedBefore string
  • keywords array[string]
  • subject string
  • contactNames array[string]
  • folders array[string]

    Restrict the search to these folders (folder id/path as returned by fetch-folders). Optional; when omitted, all non-system folders are searched.

  • providerId string Required
  • pageToken string
  • limit number

Responses

  • 200 application/json
    Hide response attributes Show response attributes object
    • data object Required
      Hide data attributes Show data attributes object
      • data array[object] Required
        Hide data attributes Show data attributes object
        • grantId string Required
        • id string Required
        • object string Required
        • latestDraftOrMessage object Required
          Hide latestDraftOrMessage attributes Show latestDraftOrMessage attributes object
          • starred boolean Required
          • unread boolean Required
          • folders array[string] Required
          • subject string Required
          • threadId string Required
          • body string Required
          • grantId string Required
          • id string Required
          • object string Required
          • snippet string Required
          • bcc array[object] Required
          • cc array[string] Required
          • attachments array[object] Required
          • from array[string] Required
          • to array[string] Required
          • replyTo array[string] Required
          • date string(date-time) Required
          • trackingOptions object Required
          • hasAttachment boolean Required
          • isDraft boolean Required
        • hasAttachments boolean Required
        • hasDrafts boolean Required
        • earliestMessageDate string(date-time) Required
        • latestMessageReceivedDate string(date-time) Required
        • latestMessageSentDate string(date-time) Required
        • folders array[string] Required
        • participants array[string] Required
        • snippet string Required
        • subject string Required
        • lastImportedAt string(date-time) | null

          When this thread (any of its messages) was first imported into the case. Null when none of the thread messages have been imported.

        • importedMessageIds array[string] Required

          Subset of the thread message ids that have already been imported.

        • isDraft boolean Required
        • importedMessageCount number Required
        • isImported boolean Required
      • nextPageToken string Required
    • statusCode number Required
    • timestamp string(date-time) Required
POST /email-data/{caseId}/search-remote-imap-email-threads
curl \
 --request POST 'http://api.example.com/email-data/{caseId}/search-remote-imap-email-threads' \
 --header "Authorization: Bearer $ACCESS_TOKEN" \
 --header "Content-Type: application/json" \
 --data '{
  "anyEmail": [
    "string"
  ],
  "to": [
    "string"
  ],
  "bcc": [
    "string"
  ],
  "cc": [
    "string"
  ],
  "from": [
    "string"
  ],
  "hasAttachment": true,
  "receivedAfter": "string",
  "receivedBefore": "string",
  "keywords": [
    "string"
  ],
  "subject": "string",
  "contactNames": [
    "string"
  ],
  "folders": [
    "string"
  ],
  "providerId": "string",
  "pageToken": "string",
  "limit": 42.0
}'
Request examples
{
  "anyEmail": [
    "string"
  ],
  "to": [
    "string"
  ],
  "bcc": [
    "string"
  ],
  "cc": [
    "string"
  ],
  "from": [
    "string"
  ],
  "hasAttachment": true,
  "receivedAfter": "string",
  "receivedBefore": "string",
  "keywords": [
    "string"
  ],
  "subject": "string",
  "contactNames": [
    "string"
  ],
  "folders": [
    "string"
  ],
  "providerId": "string",
  "pageToken": "string",
  "limit": 42.0
}
Response examples (200)
{
  "data": {
    "data": [
      {
        "grantId": "string",
        "id": "string",
        "object": "string",
        "latestDraftOrMessage": {
          "starred": true,
          "unread": true,
          "folders": [
            "string"
          ],
          "subject": "string",
          "threadId": "string",
          "body": "string",
          "grantId": "string",
          "id": "string",
          "object": "string",
          "snippet": "string",
          "bcc": [
            {}
          ],
          "cc": [
            "string"
          ],
          "attachments": [
            {}
          ],
          "from": [
            "string"
          ],
          "to": [
            "string"
          ],
          "replyTo": [
            "string"
          ],
          "date": "2026-05-04T09:42:00Z",
          "trackingOptions": {},
          "hasAttachment": true,
          "isDraft": true
        },
        "hasAttachments": true,
        "hasDrafts": true,
        "earliestMessageDate": "2026-05-04T09:42:00Z",
        "latestMessageReceivedDate": "2026-05-04T09:42:00Z",
        "latestMessageSentDate": "2026-05-04T09:42:00Z",
        "folders": [
          "string"
        ],
        "participants": [
          "string"
        ],
        "snippet": "string",
        "subject": "string",
        "lastImportedAt": "2026-05-04T09:42:00Z",
        "importedMessageIds": [
          "string"
        ],
        "isDraft": true,
        "importedMessageCount": 42.0,
        "isImported": true
      }
    ],
    "nextPageToken": "string"
  },
  "statusCode": 200,
  "timestamp": "2026-01-15T10:15:00.000Z"
}