# Upload files

Upload a local file and get a temporary file ID that can be previewed, downloaded, or used for subsequent imports. Uploading only saves temporary files and does not start the import task.

```text
POST $CLOUDSIGMA_API_BASE/connectors/file/upload
```

## Before you call this API

Configure the [regional API endpoint and authentication](https://omnifabric.cloudsigma.com/docs/developer/endpoints-and-authentication.html.md), and select the target workspace.

Use `multipart/form-data` request. The current public contract does not define a maximum file size limit for a single upload.

## Request example

```bash
curl -X POST "$CLOUDSIGMA_API_BASE/connectors/file/upload" \
  -H "X-API-Key: $CLOUDSIGMA_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -F 'files=@./data.csv'
```

## Form fields

| Field | Type | Is it required | Description |
| --- | --- | --- | --- |
| `files` | file[] | No | One or more files to upload. It is recommended to use `files`; the service will read all file fields in the multipart form. To get available temporary file IDs, pass in at least one file. |

`[]` after a type denotes an array. `[]` in a field path denotes each item in an array.

## Successful response

Returns `200` on success.

```json
{
  "code": "OK",
  "msg": "OK",
  "data": {
    "conn_file_ids": ["conn_file_01"],
    "file_ids": ["file_01"]
  }
}
```

The response fields are as follows.

| Field | Type | Description |
| --- | --- | --- |
| `code` | string | `OK` on success. |
| `msg` | string | `OK` on success. |
| `data.conn_file_ids` | string[] or null | Temporary connector file IDs, returned in the order of uploaded files. `null` if no file is passed in. |
| `data.file_ids` | string[] | Stores file IDs, corresponding to `data.conn_file_ids` in the same order. May be omitted if no file is passed in. |

In field paths, `[]` means each item in an array. For example, `items[].name` is the `name` field of each item in `items`.

## Error response

```json
{
  "code": "ErrParamInvalid",
  "msg": "invalid multipart form",
  "data": null
}
```

### Common HTTP errors

```{list-table}
:header-rows: 1
:widths: 12 22 32 34

* - HTTP status code
  - error code
  - Common causes
  - Recommended actions
* - `400`
  - `ErrParamInvalid`
  - Invalid multipart request.
  - Check the form format and file content and try again.
* - `401`
  - `ErrUnauthorized`
  - The access token is invalid or has expired.
  - Try again after updating the access token.
* - `403`
  - `ErrForbidden`
  - The caller does not have permission to upload files in this workspace.
  - Check workspace ID and access permissions.
* - `503`
  - `ErrServiceUnavailable`
  - The service is temporarily unable to store temporary files.
  - Keep the desensitization error message and try again.
```

## Follow-up operations

Save the returned `data.conn_file_ids`. When you need to view the content, [preview file](https://omnifabric.cloudsigma.com/docs/reference/api/ai-studio/data-connections/connector-files/preview-file.html.md); when you need to take out the file, [download file](https://omnifabric.cloudsigma.com/docs/reference/api/ai-studio/data-connections/connector-files/download-file.html.md). After confirming that it is useless, [delete the file](https://omnifabric.cloudsigma.com/docs/reference/api/ai-studio/data-connections/connector-files/delete-file.html.md).
