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

# Create or Upsert Group or Groups

> Create new chunk_group(s). This is a way to group chunks together. If you try to create a chunk_group with the same tracking_id as an existing chunk_group, this operation will fail. Only 1000 chunk groups can be created at a time. Auth'ed user or api key must have an admin or owner role for the specified dataset's organization.



## OpenAPI

````yaml post /api/chunk_group
openapi: 3.0.3
info:
  title: Trieve API
  description: >-
    Trieve OpenAPI Specification. This document describes all of the operations
    available through the Trieve API.
  contact:
    name: Trieve Team
    url: https://trieve.ai
    email: developers@trieve.ai
  license:
    name: BSL
    url: https://github.com/devflowinc/trieve/blob/main/LICENSE.txt
  version: 0.13.0
servers:
  - url: https://api.trieve.ai
    description: Production server
  - url: http://localhost:8090
    description: Local development server
security: []
tags:
  - name: Invitation
    description: Invitation endpoint. Exists to invite users to an organization.
  - name: Auth
    description: Authentication endpoint. Serves to register and authenticate users.
  - name: User
    description: User endpoint. Enables you to modify user roles and information.
  - name: Organization
    description: >-
      Organization endpoint. Enables you to modify organization roles and
      information.
  - name: Dataset
    description: >-
      Dataset endpoint. Datasets belong to organizations and hold configuration
      information for both client and server. Datasets contain chunks and chunk
      groups.
  - name: Chunk
    description: >-
      Chunk endpoint. Think of chunks as individual searchable units of
      information. The majority of your integration will likely be with the
      Chunk endpoint.
  - name: Chunk Group
    description: >-
      Chunk groups endpoint. Think of a chunk_group as a bookmark folder within
      the dataset.
  - name: Crawl
    description: Crawl endpoint. Used to create and manage crawls for datasets.
  - name: File
    description: >-
      File endpoint. When files are uploaded, they are stored in S3 and broken
      up into chunks with text extraction from Apache Tika. You can upload files
      of pretty much any type up to 1GB in size. See chunking algorithm details
      at `docs.trieve.ai` for more information on how chunking works. Improved
      default chunking is on our roadmap.
  - name: Events
    description: >-
      Notifications endpoint. Files are uploaded asynchronously and events are
      sent to the user when the upload is complete.
  - name: Topic
    description: >-
      Topic chat endpoint. Think of topics as the storage system for gen-ai chat
      memory. Gen AI messages belong to topics.
  - name: Message
    description: >-
      Message chat endpoint. Messages are units belonging to a topic in the
      context of a chat with a LLM. There are system, user, and assistant
      messages.
  - name: Stripe
    description: >-
      Stripe endpoint. Used for the managed SaaS version of this app. Eventually
      this will become a micro-service. Reach out to the team using contact info
      found at `docs.trieve.ai` for more information.
  - name: Health
    description: Health check endpoint. Used to check if the server is up and running.
  - name: Metrics
    description: Metrics endpoint. Used to get information for monitoring
  - name: Analytics
    description: Analytics endpoint. Used to get information for search and RAG analytics
  - name: Experiment
    description: Experiment endpoint. Used to create and manage experiments
paths:
  /api/chunk_group:
    post:
      tags:
        - Chunk Group
      summary: Create or Upsert Group or Groups
      description: >-
        Create new chunk_group(s). This is a way to group chunks together. If
        you try to create a chunk_group with the same tracking_id as an existing
        chunk_group, this operation will fail. Only 1000 chunk groups can be
        created at a time. Auth'ed user or api key must have an admin or owner
        role for the specified dataset's organization.
      operationId: create_chunk_group
      parameters:
        - name: TR-Dataset
          in: header
          description: >-
            The dataset id or tracking_id to use for the request. We assume you
            intend to use an id if the value is a valid uuid.
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        description: JSON request payload to cretea a chunk_group(s)
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateChunkGroupReqPayloadEnum'
        required: true
      responses:
        '200':
          description: >-
            Returns the created chunk_group if a single chunk_group was
            specified or an array of all chunk_groups which were created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateChunkGroupResponseEnum'
        '400':
          description: Service error relating to creating the chunk_group(s)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
        '413':
          description: >-
            Service error indicating more 1000 chunk groups are trying to be
            created at once
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseBody'
      security:
        - ApiKey:
            - admin
components:
  schemas:
    CreateChunkGroupReqPayloadEnum:
      oneOf:
        - $ref: '#/components/schemas/CreateSingleChunkGroupReqPayload'
        - $ref: '#/components/schemas/CreateBatchChunkGroupReqPayload'
    CreateChunkGroupResponseEnum:
      oneOf:
        - $ref: '#/components/schemas/ChunkGroup'
        - $ref: '#/components/schemas/ChunkGroups'
    ErrorResponseBody:
      type: object
      required:
        - message
      properties:
        message:
          type: string
      example:
        message: Bad Request
    CreateSingleChunkGroupReqPayload:
      type: object
      title: single
      properties:
        description:
          type: string
          description: >-
            Description to assign to the chunk_group. Convenience field for you
            to avoid having to remember what the group is for.
          nullable: true
        metadata:
          description: >-
            Optional metadata to assign to the chunk_group. This is a JSON
            object that can store any additional information you want to
            associate with the chunks inside of the chunk_group.
          nullable: true
        name:
          type: string
          description: Name to assign to the chunk_group. Does not need to be unique.
          nullable: true
        tag_set:
          type: array
          items:
            type: string
          description: >-
            Optional tags to assign to the chunk_group. This is a list of
            strings that can be used to categorize the chunks inside the
            chunk_group.
          nullable: true
        tracking_id:
          type: string
          description: >-
            Optional tracking id to assign to the chunk_group. This is a unique
            identifier for the chunk_group.
          nullable: true
        upsert_by_tracking_id:
          type: boolean
          description: >-
            Upsert when a chunk_group with the same tracking_id exists. By
            default this is false, and the request will fail if a chunk_group
            with the same tracking_id exists. If this is true, the chunk_group
            will be updated if a chunk_group with the same tracking_id exists.
          nullable: true
      example:
        description: All versions and colorways of the oversized t-shirt
        metadata:
          color: black
          size: large
        name: Versions of Oversized T-Shirt
        tag_set:
          - tshirt
          - oversized
          - clothing
        tracking_id: SNOVERSIZEDTSHIRT
        upsert_by_tracking_id: false
    CreateBatchChunkGroupReqPayload:
      type: array
      items:
        $ref: '#/components/schemas/CreateSingleChunkGroupReqPayload'
      example:
        - description: All versions and colorways of the oversized t-shirt
          metadata:
            foo: bar
          name: Versions of Oversized T-Shirt
          tag_set:
            - tshirt
            - oversized
            - clothing
          tracking_id: SNOVERSIZEDTSHIRT
          upsert_by_tracking_id: false
        - description: All versions and colorways of the slim-fit t-shirt
          metadata:
            foo: bar
          name: Versions of Slim-Fit T-Shirt
          tag_set:
            - tshirt
            - slim
            - clothing
          tracking_id: SNSLIMFITTSHIRT
          upsert_by_tracking_id: false
    ChunkGroup:
      type: object
      required:
        - id
        - name
        - description
        - created_at
        - updated_at
        - dataset_id
      properties:
        created_at:
          type: string
          format: date-time
        dataset_id:
          type: string
          format: uuid
        description:
          type: string
        id:
          type: string
          format: uuid
        metadata:
          nullable: true
        name:
          type: string
        tag_set:
          type: array
          items:
            type: string
            nullable: true
          nullable: true
        tracking_id:
          type: string
          nullable: true
        updated_at:
          type: string
          format: date-time
      example:
        created_at: '2021-01-01 00:00:00.000'
        dataset_id: e3e3e3e3-e3e3-e3e3-e3e3-e3e3e3e3e3e3
        description: All versions and colorways of the oversized t-shirt
        metadata:
          foo: bar
        name: Versions of Oversized T-Shirt
        tag_set:
          - tshirt
          - oversized
          - clothing
        tracking_id: SNOVERSIZEDTSHIRT
        updated_at: '2021-01-01 00:00:00.000'
    ChunkGroups:
      type: array
      items:
        $ref: '#/components/schemas/ChunkGroup'
      example:
        - created_at: '2021-01-01 00:00:00.000'
          dataset_id: e3e3e3e3-e3e3-e3e3-e3e3-e3e3e3e3e3e3
          description: All versions and colorways of the oversized t-shirt
          metadata:
            foo: bar
          name: Versions of Oversized T-Shirt
          tag_set:
            - tshirt
            - oversized
            - clothing
          tracking_id: SNOVERSIZEDTSHIRT
          updated_at: '2021-01-01 00:00:00.000'
        - created_at: '2021-01-01 00:00:00.000'
          dataset_id: e3e3e3e3-e3e3-e3e3-e3e3-e3e3e3e3e3e3
          description: All versions and colorways of the slim-fit t-shirt
          metadata:
            foo: bar
          name: Versions of Slim-Fit T-Shirt
          tag_set:
            - tshirt
            - slim
            - clothing
          tracking_id: SNSLIMFITTSHIRT
          updated_at: '2021-01-01 00:00:00.000'
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: Authorization

````