Skip to Content

Messages similar to one message.

'More like this': the message's own embedding is the query. The message must already be embedded (semantic search on, and the backfill has reached it) — otherwise 409 not_embedded with the current floor, which is the prompt to lower it (PATCH /identities/:id { semanticFloor }). The read path never embeds inline.

openemail.search.similar(
  mailboxId: string,
  messageId: string,
  options?: SearchSimilarOptions,
): ApiPromise<SimilarMessagesResult>

It calls GET /mailboxes/{mailboxId}/messages/{messageId}/similar: Messages similar to one message in the API reference.

Example

const similarMessagesResult = await openemail.search.similar(mailboxId, messageId)

Arguments

ArgumentTypeDescription
mailboxIdstringMailbox ULID identifier. The path's {mailboxId}.
messageIdstringMessage ULID. The path's {messageId}.

Options

The last argument, options, a SearchSimilarOptions, takes:

OptionTypeSent asDescription
limitnumberquery limitMaximum messages to return (default 10, max 50)
sincenumberquery sinceOnly mail received at or after this epoch second
beforenumberquery beforeOnly mail received before this epoch second

Every call also takes signal, timeout, retry and headers, which say how that one call is sent (call options).

Answer

Awaited, it is the API's JSON, SimilarMessagesResult. It is an ApiPromise: .withResponse() gives the same with the Response it came in, for its headers.

Errors

StatusWhat it means
400validation_failed — a malformed limit, since or before
401unauthorized: the bearer credential is missing, malformed, expired, or revoked. Carries a WWW-Authenticate: Bearer challenge
404Mailbox or message not found, or not accessible to this principal
409semantic_not_enabled — the mailbox has not opted in, or its account lacks the plan gate; or not_embedded — the index holds no vector for the message (below the floor, the backfill has not reached it, or its upsert has not landed); the body carries semanticFloor
429rate_limited
503semantic_unavailable (transient, with Retry-After) or semantic_misconfigured (permanent, without). Or temporary_failure: the platform's storage could not answer just now; retry after the Retry-After window. Any operation can answer this. A write that got it may have been applied, so retry it with the same idempotency key where it takes one, or read the state back first (see Transient failures in the API description)

A failed call rejects with a RequestError: its status, and its code, the API's error. Decide on the code: one status covers several.

Types

It names these types of the API, each on a page of its own: SimilarMessagesResult.