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

# Create Datastore

> Create a new `Datastore`.

A `Datastore` is a collection of documents. Documents can be ingested into and deleted from a `Datastore`.

A `Datastore` can be linked to one or more `Agents`, and conversely, an `Agent` can be associated with one or more `Datastores` to ground its responses with relevant data. This flexible many-to-many relationship allows `Agents` to draw from multiple sources of information. This linkage of `Datastore` to `Agent` is done through the `Create Agent` or `Edit Agent` APIs.

> Note that self-serve users are currently required to create datastores through our UI. Otherwise, they will receive the following message: "This endpoint is disabled as you need to go through checkout. Please use the UI to make this request."



## OpenAPI

````yaml api-reference/openapi.json post /datastores
openapi: 3.1.0
info:
  title: Endpoints
  version: '1.0'
servers:
  - url: https://api.contextual.ai/v1
security:
  - BearerAuth: []
paths:
  /datastores:
    post:
      tags:
        - /datastores
      summary: Create Datastore
      description: >-
        Create a new `Datastore`.


        A `Datastore` is a collection of documents. Documents can be ingested
        into and deleted from a `Datastore`.


        A `Datastore` can be linked to one or more `Agents`, and conversely, an
        `Agent` can be associated with one or more `Datastores` to ground its
        responses with relevant data. This flexible many-to-many relationship
        allows `Agents` to draw from multiple sources of information. This
        linkage of `Datastore` to `Agent` is done through the `Create Agent` or
        `Edit Agent` APIs.


        > Note that self-serve users are currently required to create datastores
        through our UI. Otherwise, they will receive the following message:
        "This endpoint is disabled as you need to go through checkout. Please
        use the UI to make this request."
      operationId: create_datastore_datastores_post
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/DatastoreInput'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateDatastoreOutput'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    DatastoreInput:
      properties:
        name:
          type: string
          title: Name
          description: Name of the datastore
        configuration:
          $ref: '#/components/schemas/UnstructuredDatastoreConfigModel'
          title: Configuration
          description: >-
            Configuration of the datastore. If not provided, default
            configuration is used.
          default: {}
      type: object
      required:
        - name
      title: DatastoreInput
      description: >-
        DatastoreInput for creating a new datastore. If no type is provided, we
        default to unstructured.
    CreateDatastoreOutput:
      properties:
        id:
          type: string
          format: uuid
          title: Id
          description: ID of the datastore
      type: object
      required:
        - id
      title: CreateDatastoreOutput
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    UnstructuredDatastoreConfigModel:
      properties:
        parsing:
          $ref: '#/components/schemas/DatastoreParseConfiguration'
          description: Configuration for document parsing
        chunking:
          $ref: '#/components/schemas/ChunkingConfiguration'
          description: Configuration for document chunking
        html_config:
          $ref: '#/components/schemas/HtmlConfiguration'
          description: Configuration for HTML Extraction
      additionalProperties: false
      type: object
      title: UnstructuredDatastoreConfigModel
      description: Configuration for unstructured datastores.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    DatastoreParseConfiguration:
      properties:
        figure_captioning_prompt:
          type: string
          title: Figure Captioning Prompt
          description: >-
            Prompt to use for generating image captions. Must be non-empty if
            `figure_caption_mode` is `custom`. Otherwise, must be null.
        figure_caption_mode:
          $ref: '#/components/schemas/DatastoreFigureCaptionMode'
          title: Figure Caption Mode
          description: >-
            Mode for figure captioning. Options are `default`, `custom`, or
            `ignore`. Set to `ignore` to disable figure captioning. Set to
            `default` to use the default figure prompt, which generates a
            detailed caption for each figure. Set to `custom` to use a custom
            prompt.
                    
          default: default
        enable_split_tables:
          type: boolean
          title: Enable Split Tables
          description: >-
            Whether to enable table splitting, which splits large tables into
            smaller tables with at most `max_split_table_cells` cells each. In
            each split table, the table headers are reproduced as the first
            row(s). This is useful for preserving context when tables are too
            large to fit into one chunk.
                    
          default: false
        max_split_table_cells:
          type: integer
          title: Max Split Table Cells
          description: >-
            Maximum number of cells for split tables. Ignored if
            `enable_split_tables` is False.
          default: 100
        ingestion_tier:
          anyOf:
            - $ref: '#/components/schemas/IngestionTier'
            - type: 'null'
          description: >-
            Ingestion tier for preset extraction configurations. Options:
            STANDARD, ADVANCED, PREMIUM, or None. When None (default), uses
            explicit config values or system defaults. When set, applies
            tier-based presets that can be overridden by explicit config.
      type: object
      title: DatastoreParseConfiguration
      description: >-
        Configuration for data extraction settings from documents at datastore
        level. Controls settings for document parsing. Includes those from
        `/parse` API along with some extra ingestion-only ones.
    ChunkingConfiguration:
      properties:
        chunking_mode:
          $ref: '#/components/schemas/ChunkingMode'
          title: Chunking Mode
          description: >-
            Chunking mode to use. Options are: `hierarchy_depth`,
            `hierarchy_heading`, `static_length`, `page_level`.
            `hierarchy_depth` groups chunks of the same hierarchy level or
            below, additionally merging or splitting based on length
            constraints. `hierarchy_heading` splits chunks at every heading in
            the document hierarchy, additionally merging or splitting based on
            length constraints. `static_length` creates chunks of a fixed
            length. `page_level` creates chunks that cannot run over page
            boundaries.
          default: hierarchy_depth
        max_chunk_length_tokens:
          type: integer
          maximum: 4096
          minimum: 512
          title: Max Chunk Length Tokens
          description: >-
            Target maximum length of text tokens chunks for chunking. Chunk
            length may exceed this value in some edge cases.
          default: 768
        min_chunk_length_tokens:
          type: integer
          maximum: 3712
          minimum: 128
          title: Min Chunk Length Tokens
          description: >-
            Target minimum length of chunks in tokens. Must be at least 384
            tokens less than `max_chunk_length_tokens`. Chunk length may be
            shorter than this value in some edge cases. Ignored if
            `chunking_mode` is `page_level`.
          default: 384
        enable_hierarchy_based_contextualization:
          type: boolean
          title: Enable Hierarchy Based Contextualization
          description: Whether to enable section-based contextualization for chunking
          default: true
      type: object
      title: ChunkingConfiguration
      description: Configuration for document chunking settings.
    HtmlConfiguration:
      properties:
        max_chunk_length_tokens:
          type: integer
          maximum: 4096
          minimum: 512
          title: Max Chunk Length Tokens
          description: >-
            Target maximum length of text tokens chunks for chunking. Chunk
            length may exceed this value in some edge cases.
          default: 768
      type: object
      title: HtmlConfiguration
      description: Configuration for HTML document ingestion settings.
    DatastoreFigureCaptionMode:
      type: string
      enum:
        - default
        - custom
        - ignore
      title: DatastoreFigureCaptionMode
      description: >-
        Mode for figure captioning.


        - `default`: Use the default figure prompt, which generates a detailed
        caption for each figure.


        - `custom`: Use a custom prompt.


        - `ignore`: Disable figure captioning.
    IngestionTier:
      type: string
      enum:
        - STANDARD
        - ADVANCED
        - PREMIUM
      title: IngestionTier
      description: Ingestion tier levels that determine extraction quality and cost.
    ChunkingMode:
      type: string
      enum:
        - hierarchy_depth
        - hierarchy_heading
        - static_length
        - page_level
      title: ChunkingMode
      description: >-
        Defines available chunking strategies.


        - `hierarchy_depth`: Creates a new chunk whenever a higher-level section
        heading is encountered.


        - `hierarchy_heading`: Creates a new chunk whenever any section heading
        is encountered.


        - `static_length`: Creates chunks of a fixed length.

        - `page_level`: Creates chunks that cannot run over page boundaries.
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key

````