Upload Files for Messaging
Upload one or more files to the PBX, which can be used when sending messages in either message campaigns or message sessions.
Note:
- The uploaded files are stored under the folder /ysdisk/cache/chat, and these files will be periodically cleaned up along with chat messages.
- The total size of uploaded file(s) can NOT exceed 100 MB.
Request URL
POST {base_url}/{api_path}/message/batchupload?access_token={access_token}
Request parameters
| Parameter | Required | Type | Description |
|---|---|---|---|
| files | Yes | file | List of file resources, uploaded via form-data. Note: Supports to upload multiple files. |
Response parameters
| Parameter | Type | Description |
|---|---|---|
| errcode | Integer | Returned error code.
|
| errmsg | String | Returned message.
|
| list | Array<File_Info> | The list of detailed information for uploaded files. |
File_Info
| Parameter | Type | Description |
|---|---|---|
| id | String | The ID of the file. |
| name | String | The name of the file. |
| uri | String | The URI for accessing the file. |
| type | String | File type. |
| size | Integer | File size (Unit: Byte). |
Example
Request example
POST /openapi/v1.0/message/batchupload?access_token=cIRvlHGgdMSuY0eiWE9JkXLCcHZHRTXm HTTP/1.1 Host: 192.168.5.150:8088 Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW ------WebKitFormBoundary7MA4YWxkTrZu0gW Content-Disposition: form-data; name="files"; filename="/D:/projects/files/demo.wav" Content-Type: audio/wav (binary data) # actual file content here ------WebKitFormBoundary7MA4YWxkTrZu0gW Content-Disposition: form-data; name="files"; filename="/D:/projects/files/demo.jpg" Content-Type: image/jpeg (binary data) # actual file content here ------WebKitFormBoundary7MA4YWxkTrZu0gW Content-Disposition: form-data; name="files"; filename="/D:/projects/files/demo.mp4" Content-Type: video/mp4 (binary data) # actual file content here ------WebKitFormBoundary7MA4YWxkTrZu0gW Content-Disposition: form-data; name="files"; filename="/D:/projects/files/demo.csv" Content-Type: text/csv (binary data) # actual file content here ------WebKitFormBoundary7MA4YWxkTrZu0gW--
Figure: Request example in Postman
Response example
HTTP/1.1 200 OK
{
"errcode": 0,
"errmsg": "SUCCESS",
"list": [
{
"id": "da20742bf760466aa0aac64c07c05353",
"name": "demo.wav",
"uri": "20250728/da20742bf760466aa0aac64c07c05353",
"type": "audio/wave",
"size": 202812
},
{
"id": "98027f003d3d47328f2e5dbeb0f65879",
"name": "demo.jpg",
"uri": "20250728/98027f003d3d47328f2e5dbeb0f65879",
"type": "image/jpeg",
"size": 95896
},
{
"id": "d96bb38dafc447c5b04350df9440f74c",
"name": "demo.mp4",
"uri": "20250728/d96bb38dafc447c5b04350df9440f74c",
"type": "video/mp4",
"size": 309568
},
{
"id": "75866e1ff520418a8bee0f92f6d7b161",
"name": "demo.csv",
"uri": "20250728/75866e1ff520418a8bee0f92f6d7b161",
"type": "text/csv",
"size": 56890
}
]
}