---
title: "Create or Upsert Group or Groups"
method: POST
path: "/api/chunk_group"
tags: ["Chunk Group"]
---

# Create or Upsert Group or Groups

`POST /api/chunk_group`

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.

## Headers

- `TR-Dataset` string, uuid, required

## Request body

- union
  - CreateSingleChunkGroupReqPayload
    - `description` string, nullable — Description to assign to the chunk_group. Convenience field for you to avoid having to remember what the group is for.
    - `metadata` unknown
    - `name` string, nullable — Name to assign to the chunk_group. Does not need to be unique.
    - `tag_set` string[], nullable — 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.
    - `tracking_id` string, nullable — Optional tracking id to assign to the chunk_group. This is a unique identifier for the chunk_group.
    - `upsert_by_tracking_id` boolean, nullable — 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.
  - CreateSingleChunkGroupReqPayload[]
    - `description` string, nullable — Description to assign to the chunk_group. Convenience field for you to avoid having to remember what the group is for.
    - `metadata` unknown
    - `name` string, nullable — Name to assign to the chunk_group. Does not need to be unique.
    - `tag_set` string[], nullable — 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.
    - `tracking_id` string, nullable — Optional tracking id to assign to the chunk_group. This is a unique identifier for the chunk_group.
    - `upsert_by_tracking_id` boolean, nullable — 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.

## Response `200`

Returns the created chunk_group if a single chunk_group was specified or an array of all chunk_groups which were created

- union
  - ChunkGroup
    - `created_at` string, date-time, required
    - `dataset_id` string, uuid, required
    - `description` string, required
    - `id` string, uuid, required
    - `metadata` unknown
    - `name` string, required
    - `tag_set` string[], nullable
    - `tracking_id` string, nullable
    - `updated_at` string, date-time, required
  - ChunkGroup[]
    - `created_at` string, date-time, required
    - `dataset_id` string, uuid, required
    - `description` string, required
    - `id` string, uuid, required
    - `metadata` unknown
    - `name` string, required
    - `tag_set` string[], nullable
    - `tracking_id` string, nullable
    - `updated_at` string, date-time, required

## Other responses

- `400` — Service error relating to creating the chunk_group(s)
- `413` — Service error indicating more 1000 chunk groups are trying to be created at once

---

[API](https://skmtc.net/devflowinc/apis/trieve-api.md) · [All operations](https://skmtc.net/devflowinc/apis/trieve-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/devflowinc/trieve-api/versions/84583e7c9fc1/schema)
