---
title: "Import CSV"
method: POST
path: "/data/projects/{projectId}/table/{tableName}/import"
tags: ["Data -- Internal Tables"]
---

# Import CSV

`POST /data/projects/{projectId}/table/{tableName}/import`

## Request

- Base URL: `https://partner.peaka.studio/api/v1`
- URL: `https://partner.peaka.studio/api/v1/data/projects/{projectId}/table/{tableName}/import`
- Auth: HTTP bearer

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}`

## Path parameters

- `projectId` string, required
- `tableName` string, required

## Response `200`

Import job created successfully

---

[API](https://skmtc.dev/peaka/apis/peaka-gateway-api.md) · [All operations](https://skmtc.dev/peaka/apis/peaka-gateway-api/llms.txt) · [OpenAPI document](https://skmtc.dev/peaka/apis/peaka-gateway-api/revisions/e68b033a22d5?raw)
