Skip to main content

Request Upload Lease

First step in uploading a file to the data center. Returns an OSS presigned URL and a lease ID.

POST
/api/v1/connector/dash/applyFileUploadLease
cURL
curl -X POST "https://{workspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/connector/dash/applyFileUploadLease" \
  -H "Authorization: Bearer $DASHSCOPE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "category": "cate_abc123",
    "fileName": "product-guide.pdf",
    "sizeBytes": "1048576",
    "contentMd5": "d41d8cd98f00b204e9800998ecf8427e"
  }'
{
  "code": "Success",
  "message": "",
  "messageUnmodified": false,
  "requestId": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "data": {
    "type": "OSS.PreSignedUrl",
    "param": {
      "url": "https://oss-example.aliyuncs.com/...",
      "method": "PUT",
      "headers": {
        "x-bailian-extra": "MTkxMDA3MzE0NjA0NDgzNA==",
        "Content-Type": "text/plain"
      }
    },
    "leaseId": "82845f78ab0343ada293c9595ed93dbf.1782191906659"
  },
  "status": 200
}
File upload is a three-step flow:
  1. Request a lease (this endpoint) — get the OSS presigned URL and leaseId.
  2. PUT to OSS — upload the file binary via HTTP PUT using the returned param.url and param.headers.
  3. Register the file (addFile) — register the uploaded file with the data center using leaseId.
sizeBytes must be passed as a string (for example "1048576"), not a number.

Authorizations

string
header
required

DashScope API Key, obtained from the API Key page in the console.

Body

application/json
string
required

Category ID (the field is named category, not categoryId). Returned by listCategory.

string
required

File name, including the extension.

string
required

File size in bytes, passed as a string.

x >= 1
string
required

MD5 of the file content, Base64-encoded.

length: 1–64
enum<string>
default"UNSTRUCTURED"

Category type. Defaults to UNSTRUCTURED. UNSTRUCTURED: a category used to build Knowledge Bases. SESSION_FILE: files used for agent session interactions. When using SESSION_FILE, addFile must also receive SESSION_FILE as categoryType; such files are valid only for the current session and expire once it closes (at most 7 days). They cannot be stored long term.

UNSTRUCTURED,SESSION_FILE
boolean
defaultfalse

Whether to upload through the internal endpoint of the secure storage space. Defaults to false.

Response

200-application/json
string

Response code. Success on success.

string

Error or informational message; an empty string on success.

string

Unique request identifier. Include this ID when reporting an issue.

object
integer

Business status code. 200 on success, 400 for failures such as invalid parameters. Note that the HTTP status code remains 200 even on failure, so rely on this field and code to determine the result.