> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.twelvelabs.io/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.twelvelabs.io/_mcp/server.

# Knowledge stores

> Create and manage knowledge stores with the Node.js SDK.

A knowledge store contains your videos plus the understanding the platform derives from them: spatiotemporal context, a typed ontology, and embeddings for semantic retrieval. The `KnowledgeStores` class provides methods to create and manage knowledge stores.

# Methods

## Create a knowledge store

**Description**: This method creates a knowledge store.

Provide a name. Optionally include a description, a metadata map, and an `ingestionConfig` object that controls how content added to the store is processed. The `ingestionConfig` object is immutable after creation.

**Function signature and example**:

**`Function signature`**

```javascript Function signature
create(
  request: TwelvelabsApi.KnowledgeStoresCreateRequest,
  requestOptions?: KnowledgeStores.RequestOptions
): Promise<TwelvelabsApi.KnowledgeStore>
```

**`Node.js example`**

```javascript Node.js example
import { TwelveLabs } from "twelvelabs-js";

const client = new TwelveLabs({ apiKey: "<YOUR_API_KEY>" });

const knowledgeStore = await client.knowledgeStores.create({
    name: "Product Demo Analysis",
    // description: "An optional description of the knowledge store.",
    // metadata: { team: "qa", purpose: "demo" },
    // ingestionConfig: {
    //     enrichmentConfig: {
    //         type: "description",
    //         description: "Extract the main subject, setting, and mood of each shot.",
    //     },
    // },
});
console.log(`ID: ${knowledgeStore.id}`);
```

### Parameters

| Name              | Type                                            | Required | Description                                                                                                                                                               |
| :---------------- | :---------------------------------------------- | :------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `name`            | `string`                                        | Yes      | The name of the knowledge store.                                                                                                                                          |
| `ingestionConfig` | `IngestionConfig`                               | No       | Configuration that controls how content added to the knowledge store is processed. Immutable after creation.                                                              |
| `description`     | `string`                                        | No       | An optional description of the knowledge store.                                                                                                                           |
| `metadata`        | `Record<string,` `KnowledgeStoreMetadataValue>` | No       | Custom metadata for the knowledge store. Keys are strings; values can be a string, a number, a boolean, or an array of strings. You can provide up to 10 key-value pairs. |
| `requestOptions`  | `KnowledgeStores.` `RequestOptions`             | No       | Per-call SDK settings such as timeout, retries, and headers. For all fields, see [Request options](/v1.3/sdk-reference/node-js/the-twelve-labs-class#request-options).    |

The `IngestionConfig` object contains the following property:

| Name               | Type               | Required | Description                                                                                                                                                                                                                               |
| :----------------- | :----------------- | :------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `enrichmentConfig` | `EnrichmentConfig` | Yes      | Metadata enrichment configuration. Set `type` to `description` for natural-language instructions that the platform converts into a schema internally, or to `json_schema` for structured extraction conforming to a provided JSON Schema. |

### Return value

Returns a `KnowledgeStore` object. The `KnowledgeStore` object contains the following properties:

| Name              | Type                                            | Description                                                                                                                     |
| :---------------- | :---------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------ |
| `id`              | `string`                                        | The unique identifier of the knowledge store.                                                                                   |
| `name`            | `string`                                        | The name of the knowledge store.                                                                                                |
| `description`     | `string`                                        | An optional description of the knowledge store.                                                                                 |
| `ingestionConfig` | `IngestionConfig`                               | The ingestion configuration set when this knowledge store was created. Immutable.                                               |
| `itemCount`       | `number`                                        | The number of items in the knowledge store.                                                                                     |
| `createdAt`       | `string`                                        | The date and time when the knowledge store was created, in the RFC 3339 format.                                                 |
| `updatedAt`       | `string`                                        | The date and time when the knowledge store was last updated, in the RFC 3339 format.                                            |
| `metadata`        | `Record<string,` `KnowledgeStoreMetadataValue>` | Custom metadata for the knowledge store. Keys are strings; each value is a string, a number, a boolean, or an array of strings. |

### API Reference

[Create a knowledge store](/v1.3/api-reference/knowledge-stores/create).

### Related guide

[Create a knowledge store](/v1.3/agents/guides/create-a-knowledge-store).

## List knowledge stores

**Description**: This method returns a list of the knowledge stores in your account.

**Function signature and example**:

**`Function signature`**

```javascript Function signature
list(
  request?: TwelvelabsApi.KnowledgeStoresListRequest,
  requestOptions?: KnowledgeStores.RequestOptions
): Promise<core.Page<TwelvelabsApi.KnowledgeStore>>
```

**`Node.js example`**

```javascript Node.js example
import { TwelveLabs } from "twelvelabs-js";

const client = new TwelveLabs({ apiKey: "<YOUR_API_KEY>" });

const knowledgeStores = await client.knowledgeStores.list({
    // page: 1,
    // pageLimit: 10,
    // sortBy: "created_at",
    // sortOption: "desc",
});
for await (const knowledgeStore of knowledgeStores) {
    console.log(`ID: ${knowledgeStore.id} Name: ${knowledgeStore.name}`);
}
```

### Parameters

| Name             | Type                                  | Required | Description                                                                                                                                                                                                                                                                                                                               |
| :--------------- | :------------------------------------ | :------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `page`           | `number`                              | No       | A number that identifies the page to retrieve. **Default**: `1`.                                                                                                                                                                                                                                                                          |
| `pageLimit`      | `number`                              | No       | The number of items to return on each page. **Default**: `10`. **Max**: `50`.                                                                                                                                                                                                                                                             |
| `sortBy`         | `KnowledgeStores` `ListRequestSortBy` | No       | The field to sort on. The following options are available: - `created_at`: Sorts by the time, in the RFC 3339 format ("YYYY-MM-DDTHH:mm:ssZ"), when the knowledge store was created. - `updated_at`: Sorts by the time, in the RFC 3339 format ("YYYY-MM-DDTHH:mm:ssZ"), when the knowledge store was updated. **Default**: `created_at`. |
| `sortOption`     | `string`                              | No       | The sorting direction. The following options are available: - `asc` - `desc` **Default**: `desc`.                                                                                                                                                                                                                                         |
| `requestOptions` | `KnowledgeStores.` `RequestOptions`   | No       | Per-call SDK settings such as timeout, retries, and headers. For all fields, see [Request options](/v1.3/sdk-reference/node-js/the-twelve-labs-class#request-options).                                                                                                                                                                    |

### Return value

Returns a `Page<KnowledgeStore>` object that allows you to iterate through the paginated list of knowledge stores. For the properties of each `KnowledgeStore` object, see [Create a knowledge store](#create-a-knowledge-store).

### API Reference

[List knowledge stores](/v1.3/api-reference/knowledge-stores/list).

## Retrieve a knowledge store

**Description**: This method retrieves the details of a specific knowledge store.

**Function signature and example**:

**`Function signature`**

```javascript Function signature
retrieve(
  knowledgeStoreId: string,
  requestOptions?: KnowledgeStores.RequestOptions
): Promise<TwelvelabsApi.KnowledgeStore>
```

**`Node.js example`**

```javascript Node.js example
import { TwelveLabs } from "twelvelabs-js";

const client = new TwelveLabs({ apiKey: "<YOUR_API_KEY>" });

const knowledgeStore = await client.knowledgeStores.retrieve("<YOUR_KNOWLEDGE_STORE_ID>");
console.log(`Name: ${knowledgeStore.name} Items: ${knowledgeStore.itemCount}`);
```

### Parameters

| Name               | Type                                | Required | Description                                                                                                                                                            |
| :----------------- | :---------------------------------- | :------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `knowledgeStoreId` | `string`                            | Yes      | The unique identifier of the knowledge store.                                                                                                                          |
| `requestOptions`   | `KnowledgeStores.` `RequestOptions` | No       | Per-call SDK settings such as timeout, retries, and headers. For all fields, see [Request options](/v1.3/sdk-reference/node-js/the-twelve-labs-class#request-options). |

### Return value

Returns a `KnowledgeStore` object. For its properties, see [Create a knowledge store](#create-a-knowledge-store).

### API Reference

[Retrieve a knowledge store](/v1.3/api-reference/knowledge-stores/retrieve).

## Update a knowledge store

**Description**: This method updates the specified knowledge store. Only the `name`, `description`, and `metadata` fields can be updated.

**Function signature and example**:

**`Function signature`**

```javascript Function signature
update(
  knowledgeStoreId: string,
  request?: TwelvelabsApi.KnowledgeStoresUpdateRequest,
  requestOptions?: KnowledgeStores.RequestOptions
): Promise<TwelvelabsApi.KnowledgeStore>
```

**`Node.js example`**

```javascript Node.js example
import { TwelveLabs } from "twelvelabs-js";

const client = new TwelveLabs({ apiKey: "<YOUR_API_KEY>" });

const knowledgeStore = await client.knowledgeStores.update("<YOUR_KNOWLEDGE_STORE_ID>", {
    // name: "Updated name",
    // description: "Updated description",
    // metadata: { stage: "updated" },
});
console.log(`Name: ${knowledgeStore.name}`);
```

### Parameters

| Name               | Type                                            | Required | Description                                                                                                                                                                                                                                                                                                                                                                        |
| :----------------- | :---------------------------------------------- | :------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `knowledgeStoreId` | `string`                                        | Yes      | The unique identifier of the knowledge store.                                                                                                                                                                                                                                                                                                                                      |
| `name`             | `string`                                        | No       | The name of the knowledge store.                                                                                                                                                                                                                                                                                                                                                   |
| `description`      | `string`                                        | No       | An optional description of the knowledge store.                                                                                                                                                                                                                                                                                                                                    |
| `metadata`         | `Record<string,` `KnowledgeStoreMetadataValue>` | No       | Custom metadata for the knowledge store. Keys are strings; values can be a string, a number, a boolean, or an array of strings. You can provide up to 10 key-value pairs. The provided object replaces the existing metadata in full, so include every key you want to keep and omit the ones you want to remove. To clear all metadata, set this field to an empty object (`{}`). |
| `requestOptions`   | `KnowledgeStores.` `RequestOptions`             | No       | Per-call SDK settings such as timeout, retries, and headers. For all fields, see [Request options](/v1.3/sdk-reference/node-js/the-twelve-labs-class#request-options).                                                                                                                                                                                                             |

### Return value

Returns a `KnowledgeStore` object. For its properties, see [Create a knowledge store](#create-a-knowledge-store).

### API Reference

[Update a knowledge store](/v1.3/api-reference/knowledge-stores/update).

## Delete a knowledge store

**Description**: This method deletes the specified knowledge store and all its items.

**Function signature and example**:

**`Function signature`**

```javascript Function signature
delete(
  knowledgeStoreId: string,
  requestOptions?: KnowledgeStores.RequestOptions
): Promise<void>
```

**`Node.js example`**

```javascript Node.js example
import { TwelveLabs } from "twelvelabs-js";

const client = new TwelveLabs({ apiKey: "<YOUR_API_KEY>" });

await client.knowledgeStores.delete("<YOUR_KNOWLEDGE_STORE_ID>");
```

### Parameters

| Name               | Type                                | Required | Description                                                                                                                                                            |
| :----------------- | :---------------------------------- | :------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `knowledgeStoreId` | `string`                            | Yes      | The unique identifier of the knowledge store.                                                                                                                          |
| `requestOptions`   | `KnowledgeStores.` `RequestOptions` | No       | Per-call SDK settings such as timeout, retries, and headers. For all fields, see [Request options](/v1.3/sdk-reference/node-js/the-twelve-labs-class#request-options). |

### Return value

This method does not return a value.

### API Reference

[Delete a knowledge store](/v1.3/api-reference/knowledge-stores/delete).