---
search:
  tags:
    - Embeddings
    - POST
seo:
  description: >-
    Rank the spans most like a seed across the org, as the find_similar_windows
    AI… Reference for the POST /v1/embeddings/similar endpoint in the Roboto
    REST API.
sidebar:
  label: Find similar embeddings
  badge: POST
title: Find similar embeddings
type: openapi-operation
---
Rank the spans most like a seed across the org, as the ``find_similar_windows`` AI tool does
(:py:func:`~roboto_service.domain.embeddings.similar_answer.answer_similar`).

Every hit names the event it lies mostly inside, so the search reads events as well as embeddings and sessions.

Raises:
    RobotoNotFoundException: The seed names another org's session or event.
    RobotoInvalidRequestException: A space, weight, seed, level or ``where`` the search cannot use, each named.
    RobotoUnauthorizedException: The request names a custom field the caller may not read, or a ``scope`` the
        caller may not search.

#### Access control
 - requires_org
 - Restricted tokens need the API scope `api.everything_else`

`POST /v1/embeddings/similar`

**Request body** (`application/json`, required)

- `seed` (EmbeddingSeed, required) — What a similarity search looks for spans like. Exactly one of \`\`row\_key\`\`, \`\`event\_id\`\`, \`\`session\_id\`\` and \`\`vector\`\`; \`\`start\_ns\`\` and \`\`end\_ns\`\` narrow a \`\`session\_id\`\` to a span.
- `spaces` (string | string[])
- `weights` (object | null)
- `level` (string | null)
- `k` (integer)
- `where` (object | null)
- `scope` (EmbeddingSessionScope | null)
- `normalize` (string | null)
- `fusion` (string)
- `idle_activity` (number)
- `exclude_seed_session` (boolean)
- `attributes` (string[] | null)

Request body example:

```json
{
  "seed": {
    "row_key": null,
    "row_level": null,
    "event_id": null,
    "session_id": null,
    "start_ns": null,
    "end_ns": null,
    "vector": null
  },
  "spaces": "all",
  "weights": null,
  "level": null,
  "k": 20,
  "where": null,
  "scope": null,
  "normalize": null,
  "fusion": "cosine",
  "idle_activity": 0,
  "exclude_seed_session": true,
  "attributes": null
}
```

**Responses**

- `200` — OK
- `400` — Thrown when the conversation context (messages, system prompt, tool results) exceeds the model's context window limit. The token estimate and the model's context limit are not carried on the exception, so a caller cannot read usage numbers off it.
- `401` — Thrown when authentication fails
- `403` — Thrown if an operation would exceed a user or org level limit.
- `404` — Thrown if a user is attempting to perform an action unrecognized by the Roboto platform.
- `409` — Thrown if there is a conflict between a resource you're creating and another existing resource
- `410` — Thrown if a resource is missing or expired.
- `500` — An error the platform reported that this SDK release cannot resolve to a specific exception class. Reported for an element of a :py:class:\`\~roboto.http.BatchResponse\` whose error names a code this release defines no class for, or that arrived without a code, without a message, or as text that is not an error envelope at all. It carries whatever code and message the platform sent, so a caller handling the failure still learns what went wrong; when no message could be read, the message is the error's raw text. The error envelope carries no status code, so \`\`http\_status\_code\`\` reports the 500 inherited from :py:class:\`RobotoDomainException\` rather than the status the failure actually had.
- `501` — Thrown by shimmed out APIs which have not yet been implemented
- `503` — Thrown when a service is unavailable, such as when it's under heavy load and can't accept new requests. This is expected to be transient and ought to be retried.
- `504` — Thrown when the service times out while processing a request. This is exepcted to be transient and ought to be retried.
- `507` — Thrown when the server cannot complete the request because the response payload exceeds a storage or transport capacity limit (e.g., Lambda response size). This is NOT expected to be transient and should NOT be retried.

Response example, 200:

```json
{
  "data": {
    "level": "string",
    "fusion": "string",
    "normalize": "string",
    "seed": {
      "description": "string",
      "duration_ns": 0,
      "windows": 0
    },
    "spaces": [
      {
        "space_id": "string",
        "name": "string"
      }
    ],
    "influence": {
      "property1": 0,
      "property2": 0
    },
    "hits": [
      {
        "rank": 0,
        "row_key": "string",
        "session_id": "string",
        "event_id": "string",
        "dataset_id": "string",
        "start_ns": 0,
        "end_ns": 0,
        "distance": 0,
        "percentile": null,
        "member_windows": null,
        "per_space": {
          "property1": {
            "distance": 0,
            "percentile": null
          },
          "property2": {
            "distance": 0,
            "percentile": null
          }
        },
        "attributes": null
      }
    ],
    "coverage": {},
    "truncated": true,
    "attributes": null,
    "filter_pushdown": null,
    "approximations": "string"
  }
}
```
