Import a CSV
POST /projects/:projectid/databases/:dbid/tables/:tblid/import-csv
Bulk load a library CSV into a table.
Starts an asynchronous COPY import from a file already in the library, and returns an import id to poll. This is the path to use for bulk loading — Insert rows is for small batches.
Authentication
- Project API key: The credential for everything external. Created in Project Settings, bound to one project, and limited to the scopes it was granted. Format:
proj.<keyId>.<secret>. - Required permission:
databases.writeon :dbid.
Path parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
projectid | string | Yes | - | The project id. |
dbid | string | Yes | - | The database id. |
tblid | string | Yes | - | The table to load into. |
Request body
Content type: application/json
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
docid | string | Yes | - | The library file id of the CSV. |
columnMapping | object | No | null | How CSV columns map onto table columns. Omit to match on name. |
Example
{
"docid": "FILE_ID"
}
Example request
curl -X POST \
-H "Authorization: proj.KEY_ID.SECRET" \
-H "Content-Type: application/json" \
-d '{"docid":"FILE_ID"}' \
{{BASE_URL}}/projects/{{PROJECT_ID}}/databases/DATABASE_ID/tables/orders/import-csv
Responses
202
The import was queued.
{
"importId": "imp_5kQ2",
"status": "queued"
}
400
The CSV header is invalid, or the file is too large.
403
The key lacks database write or library read.
Notes
- This one endpoint needs two permissions: database write on the target database, and library read. The import reads the contents of a library file, so a key that could start one on database write alone would be able to read any file in the library by importing it and selecting it back out.