> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lambdadb.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Manage collections

> List, describe, and delete LambdaDB collections using the Python, TypeScript, or Go SDKs and the REST API. Includes pagination and code examples.

This page shows you how to manage your existing collections including listing, describing, and deleting operations.

Later snippets reuse the imports and client setup from the first example. For Go, place the snippets inside `main`, import `context`, `log`, and `github.com/lambdadb/go-lambdadb` as `lambdadb`, and initialize `ctx := context.Background()`. See the [Start with an SDK](https://docs.lambdadb.ai/guides/get-started/quickstart.md) for a complete Go setup.

## List collections

Retrieve collections in your project with their configuration and metadata. The endpoint supports optional pagination.

| Parameter | Description | Type | Required | Default |
| :- | :- | :- | :- | :- |
| size | Max number of collections to return in one page. | integer | | |
| pageToken | Token for the next page of results. | string | | |

Treat `pageToken` as opaque. Return it unchanged to the same endpoint.

```python Python theme={null}
from lambdadb import LambdaDB

with LambdaDB(project_api_key="YOUR_API_KEY", base_url="YOUR_BASE_URL", project_name="YOUR_PROJECT_NAME") as client:
    # First page (optional: size, page_token)
    res = client.collections.list(size=20)
    for c in res.collections:
        print(c.collection_name, c.num_docs)
    # Next page (if res.next_page_token is set)
    if res.next_page_token:
        res_next = client.collections.list(size=20, page_token=res.next_page_token)
```

> [!NOTE]
>
> Python: `LambdaDB` supports context manager usage. `__enter__` returns the client, and `__exit__` calls `client.close()` (closing the SDK-owned HTTP client) and makes the client unusable after the `with` block. If you don't use `with`, call `client.close()` when you're done. If you pass a custom `client=`/`async_client=`, you own closing it.

```typescript TypeScript theme={null}
import { LambdaDBClient } from "@functional-systems/lambdadb";

const client = new LambdaDBClient({
  projectApiKey: "YOUR_API_KEY",
  baseUrl: "YOUR_BASE_URL",
  projectName: "YOUR_PROJECT_NAME",
});
// First page (optional: size, pageToken)
const res = await client.listCollections({ size: 20 });
console.log(res.collections);
// Next page (if res.nextPageToken is set)
if (res.nextPageToken) {
  const resNext = await client.listCollections({ size: 20, pageToken: res.nextPageToken });
}
```

```go Go theme={null}
client := lambdadb.New(
  lambdadb.WithBaseURL("YOUR_BASE_URL"),
  lambdadb.WithProjectName("YOUR_PROJECT_NAME"),
  lambdadb.WithAPIKey("YOUR_API_KEY"),
)
// First page (optional: Size, PageToken)
opts := &lambdadb.ListCollectionsOpts{Size: lambdadb.Int64(20)}
res, err := client.Collections.List(ctx, opts)
if err != nil { log.Fatal(err) }
for _, c := range res.Collections { _ = c }
// Next page (if res.NextPageToken != nil)
if res.NextPageToken != nil {
  resNext, _ := client.Collections.List(ctx, &lambdadb.ListCollectionsOpts{Size: lambdadb.Int64(20), PageToken: res.NextPageToken})
  _ = resNext
}
```

```bash cURL theme={null}
# $BASE_URL and $PROJECT_NAME match your LambdaDB Cloud project's region-specific base URL and project name.
LAMBDADB_PROJECT_API_KEY="YOUR_API_KEY"

# First page (optional: size, pageToken)
curl -i -X GET "$BASE_URL/projects/$PROJECT_NAME/collections?size=20" \
  -H "x-api-key: $LAMBDADB_PROJECT_API_KEY"

# Next page (use nextPageToken from previous response)
curl -i -X GET "$BASE_URL/projects/$PROJECT_NAME/collections?size=20&pageToken=YOUR_PAGE_TOKEN" \
  -H "x-api-key: $LAMBDADB_PROJECT_API_KEY"
```

The response includes detailed information about each collection. When there are more results, the response may include `nextPageToken` for fetching the next page:

```json theme={null}
{
  "collections": [
    {
      "projectName": "your-project",
      "collectionName": "example-collection",
      "indexConfigs": {
        "title": {"type": "text"},
        "category": {"type": "keyword"}
      },
      "description": "Product catalog",
      "tags": {"environment": "production"},
      "numDocs": 1250,
      "numPartitions": 1,
      "defaultBranchName": "main",
      "snapshotRetentionInDays": 30,
      "createdAt": 1788336000000,
      "updatedAt": 1788336000000,
      "dataUpdatedAt": 1788336060000
    }
  ],
  "nextPageToken": "eyJ..."
}
```

## Describe a collection

Get detailed information about a specific collection, including its configuration, document count, default branch, and retention period. `numDocs` and `dataUpdatedAt` describe the default `main` branch's committed head. They are not totals across branches or statistics for a selected ref. `dataUpdatedAt` may be absent before the first snapshot commits.

```python Python theme={null}
with LambdaDB(project_api_key="YOUR_API_KEY", base_url="YOUR_BASE_URL", project_name="YOUR_PROJECT_NAME") as client:
    meta = client.collections.get(collection_name="example-collection")
    print(meta.collection)
```

```typescript TypeScript theme={null}
const meta = await client.collection("example-collection").get();
console.log(meta);
```

```go Go theme={null}
meta, err := client.Collection("example-collection").Get(ctx)
if err != nil { log.Fatal(err) }
log.Printf("%+v", meta)
```

```bash cURL theme={null}
curl -i -X GET "$BASE_URL/projects/$PROJECT_NAME/collections/example-collection" \
  -H "x-api-key: $LAMBDADB_PROJECT_API_KEY"
```

The REST response wraps the collection details in `collection`. SDK convenience methods may return the inner object:

```json theme={null}
{
  "collection": {
    "projectName": "your-project",
    "collectionName": "example-collection",
    "indexConfigs": {
      "title": {
        "type": "text",
        "analyzers": ["standard", "korean"],
        "description": "Product title shown in search results"
      },
      "embedding": {
        "type": "vector",
        "dimensions": 768,
        "similarity": "cosine"
      }
    },
    "description": "Product catalog",
    "tags": {"environment": "production"},
    "numDocs": 1250,
    "numPartitions": 1,
    "defaultBranchName": "main",
    "snapshotRetentionInDays": 30,
    "createdAt": 1788336000000,
    "updatedAt": 1788336000000,
    "dataUpdatedAt": 1788336060000
  }
}
```

Collection and ref timestamps, including `source.asOf`, use numeric Unix epoch milliseconds. A field's `description` appears in `indexConfigs` only when one is set; see [Field descriptions](https://docs.lambdadb.ai/guides/collections/index-types.md#field-descriptions).

## Configure a collection

Update one or more of `indexConfigs`, `description`, `tags`, or
`snapshotRetentionInDays`:

```bash theme={null}
curl -i -X PATCH \
  "$BASE_URL/projects/$PROJECT_NAME/collections/example-collection" \
  -H "content-type: application/json" \
  -H "x-api-key: $LAMBDADB_PROJECT_API_KEY" \
  -d '{
    "description": "Validated product catalog",
    "tags": { "environment": "production" },
    "snapshotRetentionInDays": 14
  }'
```

The REST response is `200 OK` with the full `collection` wrapper. Omitted or `null` fields remain unchanged; at least one supported field must be non-null.

| Field | Supplied value |
| :- | :- |
| `description` | Replaces the description; `""` clears it. See [metadata limits](https://docs.lambdadb.ai/guides/get-started/limits.md#collections-and-schema). |
| `tags` | Replaces the entire metadata map, rather than merging keys; `{}` clears it. |
| `snapshotRetentionInDays` | Integer within the [supported retention range](https://docs.lambdadb.ai/guides/get-started/limits.md#collections-and-schema); there is no unlimited-retention value for this setting. Snapshots pinned by an existing tag remain available beyond this period; see [Snapshot retention](https://docs.lambdadb.ai/guides/collections/create-a-collection.md#snapshot-retention). |
| `indexConfigs` | Nonempty full schema, preserving existing fields and their settings while adding top-level or nested fields. A field's `description` is the only existing setting that can change. |

New fields can be added under existing objects at any depth. Include all existing fields in the submitted schema, including nested children, and preserve their types and settings. For example, adding `profile.city` is supported when `profile.name` and its settings are retained. Removing an existing field or changing its type, analyzers, vector settings, or embedding configuration is rejected. `partitionConfig` and `defaultBranchName` cannot be changed with PATCH.

### Field descriptions

Every field in `indexConfigs`, including nested `objectIndexConfigs` children, accepts an optional `description` of up to 255 characters. It is metadata only: it never affects indexing, and changing it does not reindex the field. On create, omitting it, `null`, or `""` means no description. On PATCH, omitting a field's `description` or sending `null` keeps the stored value, `""` clears it, and any other string replaces it. The server-managed `id` field does not accept a description. See [Field descriptions](https://docs.lambdadb.ai/guides/collections/index-types.md#field-descriptions) for examples on every index type.

To change only a description, resend the full schema with the new value and every other setting unchanged:

```bash theme={null}
curl -i -X PATCH \
  "$BASE_URL/projects/$PROJECT_NAME/collections/example-collection" \
  -H "content-type: application/json" \
  -H "x-api-key: $LAMBDADB_PROJECT_API_KEY" \
  -d '{
    "indexConfigs": {
      "title": {
        "type": "text",
        "analyzers": ["standard", "korean"],
        "description": "Localized product title shown in search results"
      },
      "embedding": { "type": "vector", "dimensions": 768, "similarity": "cosine" }
    }
  }'
```

The response returns the updated `collection`, and the `title` field keeps its analyzers and indexed data.

Described and listed collections include the server-managed top-level `id` field as `{"type": "keyword"}`. You can send a described `indexConfigs` back unchanged, with that `id` entry, or omit it; any other `id` configuration, an `id` inside an object field, or another reserved field name is rejected.

Metadata tags must follow the [entry count, key, and value rules](https://docs.lambdadb.ai/guides/get-started/limits.md#collections-and-schema). These metadata tags are separate from data-versioning tags.

## Delete a collection

Permanently delete a collection and all of its associated data and resources. This operation cannot be undone.

The API performs the logical deletion transition before returning `200 OK`. The deleted collection becomes unavailable and its name can be reused immediately.

Physical cleanup may continue after the response. Recreating the name creates a new collection identity; discard cached state for the old collection. Deleting an already absent collection can return `404`.

```python Python theme={null}
with LambdaDB(project_api_key="YOUR_API_KEY", base_url="YOUR_BASE_URL", project_name="YOUR_PROJECT_NAME") as client:
    client.collections.delete(collection_name="collection-to-delete")
```

```typescript TypeScript theme={null}
await client.collection("collection-to-delete").delete();
```

```go Go theme={null}
_, err = client.Collection("collection-to-delete").Delete(ctx)
if err != nil { log.Fatal(err) }
```

```bash cURL theme={null}
curl -i -X DELETE "$BASE_URL/projects/$PROJECT_NAME/collections/collection-to-delete" \
  -H "x-api-key: $LAMBDADB_PROJECT_API_KEY"
```

The REST response is:

```json theme={null}
{
  "message": "Collection deletion requested"
}
```

> [!WARNING]
>
> Deleting a collection is irreversible and will permanently remove all documents and metadata. Make sure you have proper backups if needed before proceeding with this operation.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.