Create Download Task CreateDownloadTask
Last Updated:2025-11-14
Description
Create download tasks to retrieve log data from logstores.
Request
- Request syntax
POST /v2/logstore/download HTTP/1.1
Host: <Endpoint>
Authorization: <Authorization String>
Content-Type: application/json; charset=utf-8
{
"name": <ProjectName>,
"description": <Description>
}- Request headers
No additional headers are required beyond the standard request headers.
- Request parameters
| Parameter name | Types | Required or not | Parameter location | Description |
|---|---|---|---|---|
| name | String | No | RequestBody | Download task name |
| project | String | No | RequestBody | Project name, default |
| logStoreName | String | Yes | RequestBody | Logstore name |
| logStreamName | String | No | RequestBody | Logstream name; by default, download data in all logstreams |
| query | String | No | RequestBody | Search statement; by default, download all data |
| queryStartTime | String | Yes | RequestBody | Log start time, in UTC ISO8601 format, for example: 2020-01-10T13:23:34Z |
| queryEndTime | String | Yes | RequestBody | Log end time, in UTC ISO8601 format, for example: 2020-01-10T13:23:34Z |
| format | String | No | RequestBody | Downloaded file format, default json, supporting json, csv |
| limit | Int | No | RequestBody | Downloaded log lines, default: 1000000, maximum: 1000000 |
| order | String | No | RequestBody | Sorting method: desc by default, sorted in reverse chronological order, and supporting desc and asc |
| fileDir | String | No | RequestBody | The BOS directory for downloaded files will by default be saved in the download directory of the BLS resource account and will not be visible to users. If a specific directory is specified, ensure the corresponding BOS bucket exists. The directory itself does not need to exist, as it will be created automatically if necessary. |
Response
- Response headers
No additional headers are required beyond the standard response headers.
- Response parameters
| Field | Types | Description |
|---|---|---|
| success | Boolean | Whether the request succeeded |
| code | String | Request code, OK for success, or a specific error code for failure |
| message | String | Empty for request success, or a specific error message for request failure |
| result | Object | Empty for request success, or a specific error message for request failure |
The element structure of result object in the above table is as follows:
| Field | Types | Description |
|---|---|---|
| uuid | string | Unique ID of download task |
Error code
Apart from standard error codes, the following codes may be returned:
| Error code | Error message | Description | HTTP status code |
|---|---|---|---|
| InvalidParameter | Request param invalid: [msg] | Invalid parameter exception | 400 |
Example
- Request example
POST /v2/logstore/download HTTP/1.1
Host: bls-log.bj.baidubce.com
Authorization:bce-auth-v1/18717522d39411e9b721df098b0b908c/2019-09-10T07:00:20Z/1800/content-type;host;x-bce-date;x-bce-request-id/6a7cb6c9ac7ec156c805e55e7d0bcfc443b47feee97cf099c1c0d93a0b4c8304
Content-Type: application/json; charset=utf-8
{
"name": "test",
"project": "default",
"logStoreName": "test",
"logStreamName": "",
"query": "match *",
"format": "json",
"limit": 100,
"order": "desc",
"queryStartTime": "2024-11-04T06:00:00Z",
"queryEndTime": "2024-11-04T06:05:00Z",
"fileDir": "bls-test/test"
}- Response example
HTTP/1.1 201
Content-Type: application/json; charset=utf-8
X-Bce-Request-Id: 2eeba101-4cc7-4cfe-b5ac-a3be8d060e33
Date: Fri, 10 Apr 2020 04:42:37 GMT
{
"code": "OK",
"success": true,
"result": {
"uuid": "96b92fe6-3f40-5fe8-3a7f-3fe168b38cc5"
}
}