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

# Import records from a CSV

> Reads an already-uploaded CSV and creates one record per row, in batches. Rows go through the same validation, folder derivation, indexing and events a single create does. A row that fails is reported and the rest continue, so a partial import is visible rather than silent.



## OpenAPI

````yaml /api-reference/endpoint/records/openapi.json post /records/csv-import
openapi: 3.1.0
info:
  title: Records API
  version: 1.1.0
  description: >-
    Record configurations (schemas, views, versions) and the records that
    conform to them. Record IDs are server-generated, config IDs are
    client-supplied (`^[a-zA-Z0-9_-]+$`). Configs and records are updated with
    PUT: a config update applies only the fields sent, a record update merges
    `data`. Editing a config schema does not retroactively re-validate existing
    records. Publish a config version to snapshot the stored config; list and
    read versions to see its history.
servers:
  - url: https://api.quiva.ai
    description: Production API server
security:
  - bearerAuth: []
  - apiKeyAuth: []
tags:
  - name: Record Configs
    description: >-
      Manage record configuration schemas. Each configuration defines the
      structure (fields, types, validation rules) that records must conform to.
  - name: Records
    description: >-
      Manage individual data records. Each record belongs to exactly one
      configuration and its data is validated against that configuration's
      schema.
  - name: Record Config Collections
    description: Groups of record configs.
  - name: Record Config Versions
    description: Published snapshots of a record config.
  - name: Record History
    description: The change history of a record.
  - name: Record Assessment
  - name: Strategy and Simulation
  - name: Record Metrics
paths:
  /records/csv-import:
    post:
      tags:
        - Records
      summary: Import records from a CSV
      description: >-
        Reads an already-uploaded CSV and creates one record per row, in
        batches. Rows go through the same validation, folder derivation,
        indexing and events a single create does. A row that fails is reported
        and the rest continue, so a partial import is visible rather than
        silent.
      operationId: importRecordsFromCsv
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CsvImportRequest'
      responses:
        '200':
          description: >-
            Import outcome. A 200 with a non-zero `failed` is a partial import,
            not a failure.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/Response'
                  - properties:
                      body:
                        $ref: '#/components/schemas/CsvImportResult'
        '400':
          description: >-
            Missing config_id, neither space_id nor folder, a location outside
            the knowledge bucket, an unreadable file, or more rows than one
            import allows
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Record configuration not found, or the object could not be read
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    CsvImportRequest:
      type: object
      required:
        - config_id
        - object_uri
      description: >-
        Turn an already-uploaded CSV into records. The file is named, not
        carried: upload it to the knowledge object bucket first and send its
        location, so a file of any size travels once rather than through this
        request body.
      properties:
        config_id:
          type: string
          description: Configuration the records are created under.
        object_uri:
          type: string
          description: >-
            Location of the uploaded file, as obj://<bucket>/<key>. Only the
            microstrate-agent-knowledge bucket may be read.
          example: >-
            obj://microstrate-agent-knowledge/record-import.customers.aB3xY9.contacts.csv
        bucket:
          type: string
          description: >-
            The same location spelled out, for a caller that has it apart.
            object_uri wins if both are given.
        key:
          type: string
          description: Object key, used with `bucket`.
        column_map:
          type: object
          additionalProperties:
            type: string
          description: >-
            CSV heading to record field name. A heading absent from the map is
            ignored, which is how a column is dropped. An empty map falls back
            to the sanitised heading.
        types:
          type: object
          additionalProperties:
            type: string
            enum:
              - string
              - number
              - integer
              - boolean
          description: >-
            Record field name to column type, so values are coerced exactly as
            the caller's preview showed them. A field missing here is written as
            text.
        space_id:
          type: string
          description: Space every created record is filed under.
        folder:
          type: string
          description: >-
            Folder every created record is filed under. Omitted, each record's
            folder is derived from its identity, exactly as a single create
            does.
        parent_folder:
          type: string
          description: Parent folder every created record hangs off.
        batch_size:
          type: integer
          minimum: 1
          maximum: 100
          default: 25
          description: Records written concurrently. Clamped to the service maximum.
        completed:
          type: boolean
          default: false
          description: >-
            Mark each record complete, which fires its record trigger. Off by
            default: an import is a bulk load, and firing a workflow per row is
            a deliberate choice.
        validate:
          type: boolean
          default: true
          description: >-
            Hold each imported row to the configuration schema, as a typed
            record is. False lets partial rows through.
      example:
        config_id: customers
        object_uri: >-
          obj://microstrate-agent-knowledge/record-import.customers.aB3xY9.contacts.csv
        space_id: spc_9fJk2
        folder: customers/2026
        column_map:
          First Name: first_name
          Email: email
        types:
          first_name: string
          email: string
    Response:
      type: object
      properties:
        status_code:
          type: integer
          description: HTTP status code echoed in the response body.
        body:
          type: object
          description: Response payload.
    CsvImportResult:
      type: object
      description: >-
        created + failed always equals total. `errors` is capped; `failed` is
        exact.
      properties:
        config_id:
          type: string
        total:
          type: integer
          description: Data rows read from the file, excluding the header.
        created:
          type: integer
        failed:
          type: integer
        errors:
          type: array
          description: >-
            The first failures only, so a wholly invalid file does not reply
            with one entry per row.
          items:
            type: object
            properties:
              row:
                type: integer
                description: >-
                  1-based, counting data rows only — the spreadsheet line number
                  minus one.
              error:
                type: string
        history_failed:
          type: integer
          description: >-
            Rows created (and counted in `created`) whose history event was not
            written. Omitted when 0.
        history_warning:
          type: string
          description: Present when `history_failed` > 0.
    ErrorResponse:
      type: object
      properties:
        status_code:
          type: integer
        body:
          type: object
          properties:
            error:
              type: string
              description: Human-readable error message.
      example:
        status_code: 400
        body:
          error: field 'rating' is required
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.