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

# Add records

> Adds records to a collection.



## OpenAPI

````yaml https://api.trychroma.com/openapi.json post /api/v2/tenants/{tenant}/databases/{database}/collections/{collection_id}/add
openapi: 3.1.0
info:
  title: chroma-frontend
  description: ''
  license:
    name: ''
  version: 1.0.0
servers: []
security: []
paths:
  /api/v2/tenants/{tenant}/databases/{database}/collections/{collection_id}/add:
    post:
      tags:
        - Record
      summary: Add records
      description: Adds records to a collection.
      operationId: collection_add
      parameters:
        - name: tenant
          in: path
          description: Tenant UUID
          required: true
          schema:
            type: string
          example: 1e30d217-3d78-4f8c-b244-79381dc6a254
        - name: database
          in: path
          description: Database name
          required: true
          schema:
            type: string
        - name: collection_id
          in: path
          description: Collection UUID
          required: true
          schema:
            type: string
          example: 1e30d217-3d78-4f8c-b244-79381dc6a254
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AddCollectionRecordsPayload'
        required: true
      responses:
        '201':
          description: Collection added successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AddCollectionRecordsResponse'
        '400':
          description: Invalid data for collection addition
      security:
        - ApiKeyAuth: []
      x-codeSamples:
        - label: Add records
          lang: typescript
          source: >-
            await collection.add({ ids: ['id1', 'id2'], embeddings: [[0.1, 0.2],
            [0.3, 0.4]], documents: ['doc1', 'doc2'] });
        - label: Add records
          lang: python
          source: >-
            collection.add(ids=['id1', 'id2'], embeddings=[[0.1, 0.2], [0.3,
            0.4]], documents=['doc1', 'doc2'])
        - label: Add records
          lang: rust
          source: |-
            collection.add(
                vec!["id1".to_string(), "id2".to_string()],
                vec![vec![0.1, 0.2], vec![0.3, 0.4]],
                Some(vec![Some("doc1".to_string()), Some("doc2".to_string())]),
                None,
                None
            ).await?;
components:
  schemas:
    AddCollectionRecordsPayload:
      type: object
      description: >-
        Payload for adding records to a collection.


        Records are added in batches. All arrays must have the same length, with
        each index

        representing a single record. For example, `ids[0]`, `embeddings[0]`,
        `documents[0]`, etc.

        all belong to the same record.
      required:
        - ids
        - embeddings
      properties:
        documents:
          type:
            - array
            - 'null'
          items:
            type:
              - string
              - 'null'
        embeddings:
          $ref: '#/components/schemas/EmbeddingsPayload'
          description: >-
            Embeddings for each record. Can contain the raw f32 arrays or base64
            encoded strings.
        ids:
          type: array
          items:
            type: string
          description: Unique identifiers for each record.
        metadatas:
          type:
            - array
            - 'null'
          items:
            oneOf:
              - type: 'null'
              - $ref: '#/components/schemas/HashMap'
        uris:
          type:
            - array
            - 'null'
          items:
            type:
              - string
              - 'null'
    AddCollectionRecordsResponse:
      type: object
    EmbeddingsPayload:
      oneOf:
        - type: array
          items:
            type: array
            items:
              type: number
              format: float
        - type: array
          items:
            type: string
    HashMap:
      type: object
      additionalProperties:
        oneOf:
          - type: boolean
          - type: integer
            format: int64
          - type: number
            format: double
          - type: string
          - $ref: '#/components/schemas/SparseVector'
          - type: array
            items:
              type: boolean
          - type: array
            items:
              type: integer
              format: int64
          - type: array
            items:
              type: number
              format: double
          - type: array
            items:
              type: string
      propertyNames:
        type: string
    SparseVector:
      type: object
      description: >-
        Represents a sparse vector using parallel arrays for indices and values.


        On deserialization: accepts both old format `{"indices": [...],
        "values": [...]}`

        and new format `{"#type": "sparse_vector", "indices": [...], "values":
        [...]}`.


        On serialization: always includes `#type` field with value
        `"sparse_vector"`.
      required:
        - indices
        - values
      properties:
        indices:
          type: array
          items:
            type: integer
            format: int32
            minimum: 0
          description: Dimension indices
        tokens:
          type:
            - array
            - 'null'
          items:
            type: string
          description: Tokens corresponding to each index
        values:
          type: array
          items:
            type: number
            format: float
          description: Values corresponding to each index
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-chroma-token

````