# 3.2.1-Upload File in Chatflow

## 1. Overview

* **Interface Name**: Upload file
* **Version number**: v1.0.0

## 2. Information

* **Request method**: POST
* **Request URL**: https\://*DOMAIN*/openapi/v1/chatflow/upload\_file/
* **Domain**: *Refer to "Service address description"*

## 3. Request parameters

Request header http header field:

| Parameter name        | Type   | Required | Description |
| --------------------- | ------ | -------- | ----------- |
| cybertron-robot-key   | string | Yes      | Robot key   |
| cybertron-robot-token | string | Yes      | Robot token |

Request body field:

| Parameter name | Type   | Required | Description                                          |
| -------------- | ------ | -------- | ---------------------------------------------------- |
| username       | string | Yes      | User account                                         |
| flow\_uuid     | string | Yes      | chatflow unique id                                   |
| session\_id    | string | Yes      | Conversation session identifier                      |
| node\_id       | string | Yes      | Node id                                              |
| category       | string | Yes      | The current upload file category (contract, invoice) |
| file           | file   | Yes      | Currently uploaded file                              |
| file\_hash     | string | Yes      | File md5 value                                       |
| file\_name     | string | Yes      | file name                                            |
| category\_id   | string | Yes      | File category identifier                             |

## 4. Response field description

HTTP status code: 200 OK

Response field description:

| Field Name | Type   | Description                                                                                       |
| ---------- | ------ | ------------------------------------------------------------------------------------------------- |
| code       | string | "000000" is normal, other exceptions                                                              |
| message    | string | Status description                                                                                |
| data       | object | message body                                                                                      |
| id         | int    | file id                                                                                           |
| status     | int    | File status; 1:uploading 2:upload finish 3:upload failed 4:parsing 5: parse finish 6:parse failed |

## 5. Example

Request Example:

```bash
curl --location --request POST 'https://_DOMAIN_/openapi/v1/chatflow/upload_file/' \
-H 'cybertron-robot-key: l8ia2IOc************Z724%2BU%3D' \
-H 'cybertron-robot-token: MTc0Mzk5************************************************cGRCUTg9' \
--form 'username=me@host.com' \
--form 'flow_uuid="test"' \
--form 'session_id="test"' \
--form 'node_id="test"' \
--form 'is_parse="true"' \
--form 'file=@"111.html"' \
--form 'file_hash="4a74c1356e86a820ebe65d7c0543108a"' \
--form 'file_name="111.html"' \
--form 'category_id="34"' \
--form 'category="contract"'
```

Response example:

```json
{
    "code": "000000",
    "message": "ok",
    "data": {
        "id": 35,
        "status": 4
    }
}
```
