> ## 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.

# Create a new collection

> Create LambdaDB collections with index configurations, partitioning, and point-in-time restore using Python, TypeScript, Go, or the REST API.

This page shows you how to create a collection with various configurations.

## Parameters

| Parameter            | Type   | Required | Description                                                                                       |
| :------------------- | :----- | :------- | :------------------------------------------------------------------------------------------------ |
| collectionName       | string | ✓        | Collection name must be unique within a project and the supported maximum length is 52 characters |
| indexConfigs         | object |          | Field configuration for indexing. Required when creating from scratch                             |
| sourceProjectName    | string |          | Source project name for PITR or branching operations                                              |
| sourceCollectionName | string |          | Source collection name for PITR or branching operations                                           |
| sourceDatetime       | string |          | ISO 8601 formatted datetime for PITR (e.g., "2024-01-15T10:30:00Z")                               |
| sourceProjectApiKey  | string |          | API key for the source project                                                                    |
| partitionConfig      | object |          | Partition configuration                                                                           |

## Create a collection from scratch

The simplest way to create a collection is to provide the collection name and the field [index configurations](/guides/collections/index-types).

<CodeGroup>
  ```python Python theme={null}
  from lambdadb import LambdaDB, models

  with LambdaDB(
      project_api_key="YOUR_API_KEY",
      base_url="YOUR_BASE_URL",
      project_name="YOUR_PROJECT_NAME",
  ) as client:
      basic_config = {
          "url": {"type": "keyword"},
          "author": {"type": "keyword"},
          "content": {
              "type": "text",
              "analyzers": ["japanese", "korean", "english"],
          },
      }
      client.collections.create(collection_name="example-collection", index_configs=basic_config)
  ```

  <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.
  </Note>

  ```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",
  });
  await client.createCollection({
    collectionName: "example-collection",
    indexConfigs: {
      url: { type: "keyword" },
      author: { type: "keyword" },
      content: { type: "text", analyzers: ["japanese", "korean", "english"] },
    },
  });
  ```

  ```go Go theme={null}
  client := lambdadb.New(
    lambdadb.WithBaseURL("YOUR_BASE_URL"),
    lambdadb.WithProjectName("YOUR_PROJECT_NAME"),
    lambdadb.WithAPIKey("YOUR_API_KEY"),
  )
  _, err := client.Collections.Create(ctx, lambdadb.CreateCollectionOptions{
    CollectionName: "example-collection",
    IndexConfigs: map[string]interface{}{
      "url":     map[string]interface{}{"type": "keyword"},
      "author":  map[string]interface{}{"type": "keyword"},
      "content": map[string]interface{}{"type": "text", "analyzers": []string{"japanese", "korean", "english"}},
    },
  })
  ```

  ```bash cURL theme={null}
  LAMBDADB_PROJECT_API_KEY="YOUR_API_KEY"

  curl -i -X POST "$BASE_URL/projects/$PROJECT_NAME/collections" \
    -H "content-type: application/json" \
    -H "x-api-key: $LAMBDADB_PROJECT_API_KEY" \
    -d '{
          "collectionName": "example-collection",
          "indexConfigs": {
            "url": { "type": "keyword" },
            "author": { "type": "keyword" },
            "content": { "type": "text", "analyzers": ["japanese", "korean", "english"] }
          }
        }'
  ```
</CodeGroup>

## Create a collection with managed embeddings

Managed embeddings let LambdaDB derive vector values from a source text field. Define the vector field with `managedEmbedding: true` and an `embedding` block. The source field must be a `text` field in the same collection.

For the current provider and model matrix, see [Managed embeddings](/guides/collections/managed-embeddings).

<CodeGroup>
  ```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:
      client.collections.create(
          collection_name="semantic-docs",
          index_configs={
              "body": {
                  "type": "text",
                  "analyzers": ["english"],
              },
              "bodyEmbedding": {
                  "type": "vector",
                  "managedEmbedding": True,
                  "embedding": {
                      "provider": "openai",
                      "model": "text-embedding-3-small",
                      "sourceField": "body",
                  },
              },
          },
      )
  ```

  ```typescript TypeScript theme={null}
  await client.createCollection({
    collectionName: "semantic-docs",
    indexConfigs: {
      body: {
        type: "text",
        analyzers: ["english"],
      },
      bodyEmbedding: {
        type: "vector",
        managedEmbedding: true,
        embedding: {
          provider: "openai",
          model: "text-embedding-3-small",
          sourceField: "body",
        },
      },
    },
  });
  ```

  ```bash cURL theme={null}
  curl -i -X POST "$BASE_URL/projects/$PROJECT_NAME/collections" \
    -H "content-type: application/json" \
    -H "x-api-key: $LAMBDADB_PROJECT_API_KEY" \
    -d '{
          "collectionName": "semantic-docs",
          "indexConfigs": {
            "body": {
              "type": "text",
              "analyzers": ["english"]
            },
            "bodyEmbedding": {
              "type": "vector",
              "managedEmbedding": true,
              "embedding": {
                "provider": "openai",
                "model": "text-embedding-3-small",
                "sourceField": "body"
              }
            }
          }
        }'
  ```
</CodeGroup>

<Note>
  For managed embedding vector fields, do not send top-level `dimensions` or `similarity` in the field config. LambdaDB resolves and stores those values under `embedding`.
</Note>

## Create a partitioned collection

LambdaDB supports hash-based partitioning for a specified field.

<CodeGroup>
  ```python Python theme={null}
  from lambdadb import LambdaDB, models

  with LambdaDB(project_api_key="YOUR_API_KEY", base_url="YOUR_BASE_URL", project_name="YOUR_PROJECT_NAME") as client:
      basic_config = {
          "url": {"type": "keyword"},
          "author": {"type": "keyword"},
          "content": {"type": "text", "analyzers": ["japanese", "korean", "english"]},
      }
      client.collections.create(
          collection_name="example-collection",
          index_configs=basic_config,
          partition_config={"field_name": "url", "data_type": "keyword", "num_partitions": 4},
      )
  ```

  ```typescript TypeScript theme={null}
  await client.createCollection({
    collectionName: "example-collection",
    indexConfigs: { url: { type: "keyword" }, author: { type: "keyword" }, content: { type: "text", analyzers: ["japanese", "korean", "english"] } },
    partitionConfig: { fieldName: "url", dataType: "keyword", numPartitions: 4 },
  });
  ```

  ```bash cURL theme={null}
  curl -i -X POST "$BASE_URL/projects/$PROJECT_NAME/collections" \
    -H "content-type: application/json" \
    -H "x-api-key: $LAMBDADB_PROJECT_API_KEY" \
    -d '{
          "collectionName": "example-collection",
          "indexConfigs": { "url": {"type": "keyword"}, "author": {"type": "keyword"}, "content": {"type": "text", "analyzers": ["japanese", "korean", "english"]} },
          "partitionConfig": { "fieldName": "url", "dataType": "keyword", "numPartitions": 4 }
        }'
  ```
</CodeGroup>

<Note>
  Currently, only `keyword` type is supported for partitioning.
</Note>

## Point-in-time recovery (PITR)

LambdaDB automatically maintains continuous backups at the collection level with a default retention period of 30 days.
You can create a collection from a specific point in time using PITR functionality.

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

  with LambdaDB(project_api_key="YOUR_TARGET_API_KEY", base_url="YOUR_BASE_URL", project_name="YOUR_PROJECT_NAME") as client:
      restored_collection = client.collections.create(
          collection_name="restored-collection",
          source_project_name="source-project-name",
          source_project_api_key="YOUR_SOURCE_API_KEY",
          source_collection_name="source-collection-name",
          source_datetime="2024-01-15T10:30:00Z",
      )
  ```

  ```bash cURL theme={null}
  LAMBDADB_TARGET_PROJECT_API_KEY="YOUR_TARGET_API_KEY"
  LAMBDADB_SOURCE_PROJECT_API_KEY="YOUR_SOURCE_API_KEY"

  curl -i -X POST "$BASE_URL/projects/$PROJECT_NAME/collections" \
    -H "content-type: application/json" \
    -H "x-api-key: $LAMBDADB_TARGET_PROJECT_API_KEY" \
    -d '{
          "collectionName": "restored-collection",
          "sourceProjectName": "source-project-name",
          "sourceProjectApiKey": "'$LAMBDADB_SOURCE_PROJECT_API_KEY'",
          "sourceCollectionName": "source-collection-name",
          "sourceDatetime": "2024-01-15T10:30:00Z"
        }'
  ```
</CodeGroup>

<Note>
  PITR allows you to restore collections to any point within the configured retention period.
  The `sourceDatetime` parameter must be in ISO 8601 format (UTC timezone). If `sourceDatetime` is not specified, the collection will be restored from the most recent data available.
</Note>

## Fork a collection with additional index configs

You can fork a collection based on an existing collection and extend it with additional indexConfigs. The original collection's configuration will be preserved, and you can only add new fields.

<CodeGroup>
  ```python Python theme={null}
  from lambdadb import LambdaDB, models

  with LambdaDB(project_api_key="YOUR_TARGET_API_KEY", base_url="YOUR_BASE_URL", project_name="YOUR_PROJECT_NAME") as client:
      forked = client.collections.create(
          collection_name="forked-collection",
          source_project_name="source-project-name",
          source_project_api_key="YOUR_SOURCE_API_KEY",
          source_collection_name="example-source-collection-name",
          source_datetime="2025-08-08T10:00:00Z",
          index_configs={
              "newText": {"type": "text", "analyzers": ["japanese", "korean", "english"]},
          },
      )
  ```

  ```bash cURL theme={null}
  LAMBDADB_TARGET_PROJECT_API_KEY="YOUR_TARGET_API_KEY"
  LAMBDADB_SOURCE_PROJECT_API_KEY="YOUR_SOURCE_API_KEY"

  curl -i -X POST "$BASE_URL/projects/$PROJECT_NAME/collections" \
    -H "content-type: application/json" \
    -H "x-api-key: $LAMBDADB_TARGET_PROJECT_API_KEY" \
    -d '{
          "collectionName": "forked-collection",
          "sourceProjectId": "example-source-project-id",
          "sourceProjectApiKey": "'$LAMBDADB_SOURCE_PROJECT_API_KEY'",
          "sourceCollectionName": "example-source-collection-name",
          "sourceDatetime": "2025-08-08T10:00:00Z"
        }'
  ```
</CodeGroup>

<Note>
  When forking a collection, specifying `indexConfigs` is optional.
  You can pass additional `indexConfigs` to extend the original collection's configuration,
  but deleting or modifying the original collection's indexConfigs is not allowed.
</Note>

## Collection limits

| Metric                             | Limit     |
| :--------------------------------- | :-------- |
| Max number of collections          | unlimited |
| Max forked children per collection | 30        |
