Skip to main content

Clusters API

Group related memories into named clusters for better organization and retrieval.

Overview

Clusters are flexible groupings for organizing related memories. Unlike spaces which provide access isolation, clusters are labels that memories can belong to. A single memory can belong to multiple clusters.

Clusters vs Spaces: Use spaces for access control and tenant isolation. Use clusters for topical organization within a space.

Create Cluster

Endpoint
POST /clusters

Creates a new cluster for organizing memories. Cluster names must be unique within a space.

Body Parameters

FieldTypeDescription
namestring (required)Cluster name (1-255 characters). Unique within the account.
descriptionstringOptional description (max 1000 characters).
space_idstringOptional space UUID to scope this cluster to.
colorstringOptional hex color code (e.g., #4A90D9).
metadataobjectOptional key-value pairs to attach to this cluster.

Response (201)

Example Response
{
  "id": "<uuid>",
  "name": "learning-progress",
  "description": "Track user learning milestones",
  "space_id": "<space-uuid>",
  "color": "#4A90D9",
  "metadata": {
    "category": "education",
    "auto_assign": true
  },
  "memory_count": 0,
  "created_at": "2026-04-10T10:30:00Z"
}

Get Cluster

Endpoint
GET /clusters/:clusterId

Fetches a cluster by its UUID. Returns cluster details including memory count and optionally the memories themselves.

Path Parameters

FieldTypeDescription
clusterIdstring (required)The cluster UUID.

Query Parameters

FieldTypeDescription
include_memoriesbooleanSet to true to include the cluster's memories in the response. Default: false.
includestringComma-separated extras: quality_metrics.
limitintegerMaximum number of memories to include when include_memories=true. Default: 20.
offsetintegerOffset for paginating included memories. Default: 0.
sortstringSort memories by (default: added_at).
orderstringasc or desc. Default: desc.

Response (200)

Example Response
{
  "id": "<uuid>",
  "name": "learning-progress",
  "description": "Track user learning milestones",
  "space_id": "<space-uuid>",
  "color": "#4A90D9",
  "cluster_type": "manual",
  "memory_count": 47,
  "silhouette_score": null,
  "dbcv_score": null,
  "cohesion_score": null,
  "centroid_available": false,
  "created_at": "2026-04-10T10:30:00Z",
  "updated_at": "2026-04-12T14:22:00Z",
  "memories": [
    {
      "id": "<uuid>",
      "content": "Completed React tutorial",
      "created_at": "2026-04-12T14:22:00Z"
    }
  ],
  "memories_pagination": {
    "limit": 5,
    "offset": 0,
    "has_more": true
  }
}

List Clusters

Endpoint
GET /clusters

Returns a list of all clusters, optionally filtered by space and scale.

Query Parameters

FieldTypeDescription
qstringSearch clusters by name or description.
space_idstringFilter clusters by space UUID. Pass null to match clusters not scoped to any space.
cluster_typestringFilter by type: manual, hdbscan, bertopic, community.
has_memoriesbooleanFilter clusters that have (or lack) memories.
colorstringFilter by color (comma-separated for multiple).
includestringComma-separated extras: quality_metrics, topic_info.
sortstringSort by name (default), created_at, updated_at, memory_count, silhouette_score.
orderstringasc (default) or desc.
limitintegerMaximum number of clusters to return. Default: 50, Max: 100.
offsetintegerOffset-based pagination. Default: 0.
cursorstringCursor for keyset pagination (base64 encoded).

Response (200)

Example Response
{
  "data": [
    {
      "id": "<uuid>",
      "name": "learning-progress",
      "description": "Track user learning milestones",
      "cluster_type": "manual",
      "memory_count": 47,
      "created_at": "2026-04-10T10:30:00Z"
    }
  ],
  "has_more": false
}

Update Cluster

Endpoint
PATCH /clusters/:clusterId

Updates an existing cluster. Only the fields you provide will be updated.

Path Parameters

FieldTypeDescription
clusterIdstring (required)The cluster UUID.

Body Parameters

FieldTypeDescription
namestringNew name for the cluster.
descriptionstringNew description (nullable).
colorstringNew hex color (nullable).
metadataobjectReplacement metadata object.

Response (200)

Example Response
{
  "id": "<uuid>",
  "name": "learning-progress",
  "description": "Track learning milestones and achievements",
  "color": "#22C55E",
  "memory_count": 47,
  "created_at": "2026-04-10T10:30:00Z",
  "updated_at": "2026-04-14T09:15:00Z"
}

Delete Cluster

Endpoint
DELETE /clusters/:clusterId

Deletes a cluster. Memories previously associated with the cluster are unlinked; the underlying memories are not deleted.

Path Parameters

FieldTypeDescription
clusterIdstring (required)The cluster UUID.

Response (204)

Returns no content on successful deletion.

Note: Deleting a cluster only removes the cluster and its memory associations. The memories themselves remain in the account and are still searchable.

Manage Memory-Cluster Associations

Cluster membership is managed from the memory side, via the Memories API. The endpoints below are documented here for discoverability.

Add a memory to one or more clusters

Endpoint
POST /memories/:id/clusters

Associates a memory with the given clusters.

Body Parameters

FieldTypeDescription
cluster_idsstring[] (required)Array of cluster UUIDs.
confidencenumberAssociation confidence (0-1). Default: 1.0.

Remove a memory from a cluster

Endpoint
DELETE /memories/:id/clusters/:clusterId

Dissociates a memory from a single cluster. Returns no content on success.

List a memory's clusters

Endpoint
GET /memories/:id/clusters

Returns all clusters the memory belongs to.

List Cluster Memories

Endpoint
GET /clusters/:clusterId/memories

Returns a paginated list of memories belonging to a cluster.

Path Parameters

FieldTypeDescription
clusterIdstring (required)The cluster UUID.

Query Parameters

FieldTypeDescription
limitintegerMaximum memories to return. Default: 50.
offsetintegerOffset for pagination. Default: 0.
sortstringSort field (default: added_at).
orderstringasc or desc. Default: desc.

Response (200)

Example Response
{
  "cluster_id": "<uuid>",
  "cluster_name": "learning-progress",
  "memories": [
    {
      "id": "<uuid>",
      "content": "Completed React tutorial",
      "created_at": "2026-04-12T14:22:00Z"
    }
  ],
  "pagination": {
    "limit": 5,
    "offset": 0,
    "count": 2,
    "has_more": true
  }
}

Account Cluster Statistics

Endpoint
GET /clusters/stats

Returns account-wide cluster statistics.

Query Parameters

FieldTypeDescription
includestringComma-separated extras. Supported: color_distribution.

Cluster Quality & Topics

Per-cluster quality and topic endpoints:

Get quality metrics for a cluster

Endpoint
GET /clusters/:id/quality

Returns silhouette, DBCV and cohesion scores if available.

Get topic information for a cluster

Endpoint
GET /clusters/:id/topics

Returns topic label, keywords and representation extracted by topic modelling.

Queue a quality metric refresh

Endpoint
POST /clusters/:id/refresh-metrics

Enqueues a background job to recompute quality metrics for the cluster.

Queue a centroid recomputation

Endpoint
POST /clusters/:id/recompute-centroid

Enqueues a background job to recompute the cluster centroid.

Trigger Clustering Jobs

Trigger incremental clustering

Endpoint
POST /clusters/incremental

Queues an incremental clustering job that assigns new or selected memories to existing clusters.

Body Parameters

FieldTypeDescription
space_idstringPersonal space UUID to scope the job.
team_space_idstringTeam space UUID (multi-agent collaboration).
memory_idsstring[]Optional array of memory UUIDs to include.

Response (202)

Example Response
{
  "status": "queued",
  "job_id": "<job-id>",
  "message": "Incremental clustering job queued",
  "params": { "space_id": "<space-uuid>", "memory_count": "all_new" }
}

Trigger full HDBSCAN clustering

Endpoint
POST /clusters/full

Queues a full HDBSCAN clustering job that creates new clusters from all unclustered memories.

Get clustering run status

Endpoint
GET /clusters/status

Returns the most recent clustering run, plus aggregate counts.

List recent clustering runs

Endpoint
GET /clusters/runs

Returns a list of clustering runs (filterable by status).

Get clustering configuration

Endpoint
GET /clusters/config

Returns the account's clustering configuration (algorithm, min_cluster_size, auto_enabled).

Update clustering configuration

Endpoint
POST /clusters/config

Updates the account's clustering configuration.

Body Parameters

FieldTypeDescription
min_cluster_sizeintegerMinimum cluster size.
algorithmstringClustering algorithm (e.g. hdbscan).
auto_enabledbooleanEnable background auto-clustering.

When to use: Trigger clustering jobs after bulk imports or significant content changes. Clustering otherwise runs automatically in the background when enabled via /clusters/config.

Cluster Object

The cluster object contains the following fields:

FieldTypeDescription
idstringUUID identifier for the cluster.
namestringCluster name (unique within the account).
descriptionstring | nullOptional description of the cluster's purpose.
space_idstring | nullThe space this cluster is scoped to, or null for account-wide clusters.
cluster_typestringOne of manual, hdbscan, bertopic, community.
colorstring | nullOptional hex color code for UI display.
metadataobjectCustom key-value pairs attached to this cluster.
memory_countintegerNumber of memories currently associated with this cluster.
silhouette_scorenumber | nullClustering quality metric (null for manual clusters).
dbcv_scorenumber | nullDensity-Based Cluster Validity score (null for manual clusters).
cohesion_scorenumber | nullCohesion score (null for manual clusters).
topic_labelstring | nullTopic label if topic modelling has been applied.
topic_keywordsstring[] | nullTopic keywords if topic modelling has been applied.
created_atstringISO 8601 timestamp of when the cluster was created.
updated_atstringISO 8601 timestamp of when the cluster was last updated.