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

# Import CSV

> Imports data from a CSV file into a specified internal table in a given project.

This endpoint accepts a `multipart/form-data` request with two parts:

- **file**: The CSV file to be imported.
- **request**: A JSON string describing how the CSV columns map to the table's columns.

CSV file format can be get from `/projects/{projectId}/table/{tableName}/sample`.


#### Request JSON syntax
The `request` part must contain:
- `mappings`: A list of objects, each with:
  - `name`: The name of the target column in the internal table.
  - Either `csvColumnName` or `csvColumnIndex` to define the corresponding column in the CSV.
- `containsHeader`: A boolean indicating whether the CSV includes a header row.

#### Examples
With column names:
```
{
  "mappings": [
    { "name": "numcol", "csvColumnName": "numcol" },
    { "name": "text", "csvColumnName": "text" },
    { "name": "decimalcol", "csvColumnName": "decimalcol" }
  ],
  "containsHeader": true
}
```

With column indexes:
```
{
  "mappings": [
    { "name": "numcol", "csvColumnIndex": 0 },
    { "name": "text", "csvColumnIndex": 1 },
    { "name": "decimalcol", "csvColumnIndex": 2 }
  ],
  "containsHeader": false
}
```

- When the CSV contains a header row (`containsHeader: true`), you can use either `csvColumnName` or `csvColumnIndex`.
- When the CSV does **not** contain a header row (`containsHeader: false`), you **must** use `csvColumnIndex`.

#### Response
The endpoint currently runs synchronously and returns an `ImportJob` object with the job status and number of processed rows.

In future versions, this endpoint will return only the `jobId`, and the progress/result will be tracked via a separate job status endpoint:
`GET /jobs/{id}`


<span style={{display: "flex", gap: "10px", flexDirection: "row", alignItems: "center"}}>
  <img src="https://cdn.peaka.com/badges/partner-api-key-badge.png" />

  <img src="https://cdn.peaka.com/badges/project-api-key-badge.png" />
</span>


## OpenAPI

````yaml post /data/projects/{projectId}/table/{tableName}/import
openapi: 3.0.1
info:
  title: Peaka Gateway API
  description: Peaka Gateway API Documentation
  version: '1.0'
servers:
  - url: https://partner.peaka.studio/api/v1
    description: Default Server URL (US Zone)
  - url: https://partner.eu.peaka.studio/api/v1
    description: EU Zone
security:
  - bearerAuth: []
paths:
  /data/projects/{projectId}/table/{tableName}/import:
    post:
      tags:
        - Data -- Internal Tables
      summary: Import CSV
      description: >
        Imports data from a CSV file into a specified internal table in a given
        project.


        This endpoint accepts a `multipart/form-data` request with two parts:


        - **file**: The CSV file to be imported.

        - **request**: A JSON string describing how the CSV columns map to the
        table's columns.


        CSV file format can be get from
        `/projects/{projectId}/table/{tableName}/sample`.



        #### Request JSON syntax

        The `request` part must contain:

        - `mappings`: A list of objects, each with:
          - `name`: The name of the target column in the internal table.
          - Either `csvColumnName` or `csvColumnIndex` to define the corresponding column in the CSV.
        - `containsHeader`: A boolean indicating whether the CSV includes a
        header row.


        #### Examples

        With column names:

        ```

        {
          "mappings": [
            { "name": "numcol", "csvColumnName": "numcol" },
            { "name": "text", "csvColumnName": "text" },
            { "name": "decimalcol", "csvColumnName": "decimalcol" }
          ],
          "containsHeader": true
        }

        ```


        With column indexes:

        ```

        {
          "mappings": [
            { "name": "numcol", "csvColumnIndex": 0 },
            { "name": "text", "csvColumnIndex": 1 },
            { "name": "decimalcol", "csvColumnIndex": 2 }
          ],
          "containsHeader": false
        }

        ```


        - When the CSV contains a header row (`containsHeader: true`), you can
        use either `csvColumnName` or `csvColumnIndex`.

        - When the CSV does **not** contain a header row (`containsHeader:
        false`), you **must** use `csvColumnIndex`.


        #### Response

        The endpoint currently runs synchronously and returns an `ImportJob`
        object with the job status and number of processed rows.


        In future versions, this endpoint will return only the `jobId`, and the
        progress/result will be tracked via a separate job status endpoint:

        `GET /jobs/{id}`
      operationId: importCsv
      parameters:
        - name: projectId
          in: path
          description: ID of the Project
          required: true
          schema:
            type: string
          example: mtKDhe1U
        - name: tableName
          in: path
          description: Name of the table to import into
          required: true
          schema:
            type: string
          example: customers
      requestBody:
        content:
          multipart/form-data:
            schema:
              required:
                - file
                - request
              type: object
              properties:
                file:
                  type: string
                  description: CSV file
                  format: binary
                request:
                  type: string
                  description: JSON string with import config
                  format: json
      responses:
        '200':
          description: Import job created successfully
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/ImportJob'
components:
  schemas:
    ImportJob:
      type: object
      properties:
        id:
          type: string
        status:
          type: string
        startTime:
          type: integer
          format: int64
        endTime:
          type: integer
          format: int64
        progress:
          type: integer
          format: int32
        result:
          type: object
          additionalProperties: true
  securitySchemes:
    bearerAuth:
      type: http
      description: >-
        Use the Authorization header with the value 'Bearer <apiKey>' to
        authenticate. Partner API Keys have full access; Project API Keys are
        limited to their project scope. Learn more:
        https://docs.peaka.com/api-reference/authentication
      scheme: bearer
      bearerFormat: Api Key

````