file URL and file ID for further action on the file.
We support the following file extensions:
- M4a
- Mp3
- Webm
- Mp4
- Mpga
- Wav
- Mpeg
- PNG (.png)
- JPEG (.jpeg and .jpg)
- WEBP (.webp)
- GIF (.gif)
- Mode 1 - Upload a single file as is: Use this mode if your file is smaller than 25 MB.
- Mode 2 - Upload a file in chunks: Use this mode if your file is larger than 25 MB. Ensure you start the session for chunk uploads before proceeding.
Mode 1: Upload a Single File As Is
This method directly calls the endpoint and returns thefileId and fileURL in the response.
| Method | POST |
|---|---|
| Endpoint | https://{host}/api/public/files |
| Content Type | application/json |
| Authorization | X-api-key - The API key used for authentication. |
Path Parameters
| PARAMETER | DESCRIPTION | TYPE | REQUIRED/OPTIONAL |
|---|---|---|---|
| host | The environment URL. For example, https://agent-platform.domain.ai/. | String | Required |
Sample Request
Body Parameters
| PARAMETER | DESCRIPTION | TYPE | REQUIRED/OPTIONAL |
|---|---|---|---|
| file | The file being uploaded. | File | Required |
| fileContext | The context of the file (for example, bulkImport). | String | Required |
Sample Response
Response Parameters
| PARAMETER | DESCRIPTION | TYPE |
|---|---|---|
| url | The URL to access the uploaded file. | String |
| fileId | Unique identifier for the uploaded file | String |
Mode 2: Upload a File in Chunks
This method requires the following three APIs to upload a large file:Start Session API
This API starts the upload process, returning asession ID. The file is split into chunks linked to this ID, which are then merged and uploaded through other APIs.
| Method | POST |
|---|---|
| Endpoint | http://{host}/api/public/files/session/start |
| Content Type | application/json |
| Authorization | X-api-key - The API key used for authentication. |
Path Parameters
| PARAMETER | DESCRIPTION | TYPE | REQUIRED/OPTIONAL |
|---|---|---|---|
| host | The environment URL. For example, https://agent-platform.domain.ai | String | Required |
Sample Request
Body Parameters
| PARAMETER | DESCRIPTION | TYPE | REQUIRED/OPTIONAL |
|---|---|---|---|
| fileContext | The context of the file (for example, bulkImport). | String | Required |
| totalChunks | The total number of chunks created for the file upload. | Number | Required |
| fileExtension | The file extension based on the file type. | String | Required |
| fileName | The file name. | String | Required |
| fileSize | The size of the file. | Number | Required |
Sample Response
Response Parameters
| PARAMETER | DESCRIPTION | TYPE |
|---|---|---|
| sessionId | The file upload session id. | String |
| expirationDate | The date and time of the session expiration. | Date |
Chunk Upload API
The API uploads the file in multiple chunks. Thesession ID from the Start Session API must be used in this step.
| Method | POST |
|---|---|
| Endpoint | https://{host}/api/public/files/session/{sessionId} |
| Content Type | application/json |
| Authorization | X-api-key - The API key used for authentication. |
Path Parameters
| PARAMETER | DESCRIPTION | TYPE | REQUIRED/OPTIONAL |
|---|---|---|---|
| host | The environment URL. For example, https://agent-platform.domain.ai | String | Required |
| sessionId | The file upload session id fetched from the Start Session API. | String | Required |
Sample Request
Body Parameters
| PARAMETER | DESCRIPTION | TYPE | REQUIRED/OPTIONAL |
|---|---|---|---|
| file | The file being uploaded. | File | Required |
| chunkNumber | The uploaded chunk number. | Number | Required |
Sample Response
Response Parameters
| PARAMETER | DESCRIPTION | TYPE |
|---|---|---|
| chunkNumber | The uploaded chunk number. | Number |
| sessionId | The file upload session id. | String |
Complete The Process
This API merges the uploaded chunks and finalizes the process using thesession Id from the Start Session API. It returns the file URL and file ID. Missing chunk numbers are identified after the merge.
| Method | POST |
|---|---|
| Endpoint | https://{host}/api/public/files/session/{sessionid}/complete |
| Content Type | application/json |
| Authorization | X-api-key - The API key used for authentication. |
Path Parameters
| PARAMETER | DESCRIPTION | TYPE | REQUIRED/OPTIONAL |
|---|---|---|---|
| host | The environment URL. For example, https://agent-pxxxxxxxm.kxxe.ai | String | Required |
| sessionID | The file upload session ID. | String | Required |
Sample Request
Body Parameters
No parameters are passed.Sample Response
Response Parameters
| PARAMETER | DESCRIPTION | TYPE |
|---|---|---|
| url | The uploaded file’s URL. | String |
| fileId | The file ID of the uploaded file. | String |