Create Download Task CreateDownloadTask
Updated at:2025-11-03
Description
Create download tasks to retrieve log data from logstores.
Request
- Request syntax
Text
1POST /v2/logstore/download HTTP/1.1
2Host: <Endpoint>
3Authorization: <Authorization String>
4Content-Type: application/json; charset=utf-8
5{
6 "name": <ProjectName>,
7 "description": <Description>
8}
- 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
Text
1POST /v2/logstore/download HTTP/1.1
2Host: bls-log.bj.baidubce.com
3Authorization:bce-auth-v1/18717522d39411e9b721df098b0b908c/2019-09-10T07:00:20Z/1800/content-type;host;x-bce-date;x-bce-request-id/6a7cb6c9ac7ec156c805e55e7d0bcfc443b47feee97cf099c1c0d93a0b4c8304
4Content-Type: application/json; charset=utf-8
5
6{
7 "name": "test",
8 "project": "default",
9 "logStoreName": "test",
10 "logStreamName": "",
11 "query": "match *",
12 "format": "json",
13 "limit": 100,
14 "order": "desc",
15 "queryStartTime": "2024-11-04T06:00:00Z",
16 "queryEndTime": "2024-11-04T06:05:00Z",
17 "fileDir": "bls-test/test"
18}
- Response example
Text
1HTTP/1.1 201
2Content-Type: application/json; charset=utf-8
3X-Bce-Request-Id: 2eeba101-4cc7-4cfe-b5ac-a3be8d060e33
4Date: Fri, 10 Apr 2020 04:42:37 GMT
5{
6 "code": "OK",
7 "success": true,
8 "result": {
9 "uuid": "96b92fe6-3f40-5fe8-3a7f-3fe168b38cc5"
10 }
11}
