AddFile

Updated at:

Imports a file from the temporary storage space of Alibaba Cloud Model Studio into a data connection (formerly known as application data).

Operation description

  • To call this API, a RAM user (sub-account) must first obtain the API permissions for Alibaba Cloud Model Studio (the AliyunBailianDataFullAccess policy, which includes the sfm:AddFile permission) and join a business space. An Alibaba Cloud account (primary account) can call this API directly without authorization. We recommend using the latest Alibaba Cloud Model Studio SDK to call this API.
  • This API is not idempotent.

Throttling: Frequent calls to this API are subject to throttling. Do not exceed a rate of 10 calls per second. If your request is throttled, try again later.

Try it now

You can run this API directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After the API runs successfully, OpenAPI Explorer can automatically generate SDK code examples.

RAM authorization

The following table lists the authorization information for this API. You can use it in the Action element of a RAM policy statement to grant RAM users or RAM roles the permission to call this API. Details:

  • Action: the specific permission point.

  • Access level: the access level of each operation. Valid values: Write, Read, or List.

  • Resource type: the resource types that support authorization for the operation. Details:

    • Required resource types are marked with a preceding asterisk (*).
    • For operations that do not support resource-level authorization, All Resources is shown.
  • Condition key: the condition keys defined by the cloud service itself.

  • Dependent action: other permissions required for the operation to succeed. The caller must have the permissions of all dependent actions before the operation can succeed.

Action

Access level

Resource type

Condition key

Dependent action

sfm:AddFile

create

*All Resource

*

NoneNone

Request syntax

PUT /{WorkspaceId}/datacenter/file HTTP/1.1

Path parameters

Parameter

Type

Required

Description

Example

WorkspaceId

string

Yes

The ID of the workspace to which the file will be uploaded. For information about how to obtain the workspace ID, see How to use workspaces.

llm-3shx2gu255oqxxxx

Request parameters

Parameter

Type

Required

Description

Example

LeaseId

string

Yes

The upload lease ID. This value maps to the FileUploadLeaseId returned by the ApplyFileUploadLease API.

68abd1dea7b6404d8f7d7b9f7fbd332d.17166xxxxxxxx

Parser

string

Yes

The type of parser. Valid values:

  • DOCMIND: Intelligent Document Parsing

  • DOCMIND_DIGITAL: Digital Document Parsing

  • DOCMIND_LLM_VERSION: Large Language Model-based Document Parsing

  • DASH_QWEN_VL_PARSER: Qwen-VL Parsing

  • DOCMIND_LLM_VERSION_MEDIA: Audio and Video Parsing

  • AUTO_SELECT: Automatic Parser Selection

If CategoryType is set to UNSTRUCTURED, the parser parses your uploaded file based on the category’s data parsing settings.
If CategoryType is set to SESSION_FILE, the system uses a default parsing method that cannot be changed.

AUTO_SELECT

CategoryId

string

Yes

  • If CategoryType is set to UNSTRUCTURED, you must specify the ID of the category to which the uploaded file belongs. This is the CategoryId returned by the AddCategory API. You can also go to the Application data - Files tab and click the ID icon next to the category name to obtain the category ID. You can also enter default to use the system-created default category.

  • If CategoryType is set to SESSION_FILE, enter default.

cate_cdd11b1b79a74e8bbd675c356a91ee35xxxxxxxx

Tags

array

No

  • A list of tags for the file. You can specify up to 100 tags. The total length of all tags cannot exceed 700 characters.

  • If this parameter is not specified, no tags are added.

string

No

A tag for the file. Each tag can be up to 32 characters long and can contain Unicode letters (including English letters, Chinese characters, and digits), underscores (_), and hyphens (-).

Product introduction

CategoryType

string

No

The type of category. This parameter is optional. Default value: UNSTRUCTURED. Valid values:

  • UNSTRUCTURED: A category used for building a knowledge base.

  • SESSION_FILE: A file used for interactions within an agent session.

    If you set this parameter to SESSION_FILE, you must also set the CategoryType parameter to SESSION_FILE when you call the ApplyFileUploadLease API.
    Files of this type are valid only for the current session and expire after the session is closed, with a maximum validity of 7 days. These files are not intended for long-term storage.

UNSTRUCTURED

OriginalFileUrl

string

No

The URL of the file. The system records this link when building a document retrieval-based knowledge base. When you interact with an agent in the Alibaba Cloud Model Studio console, this URL is returned with the retrieval results for the file in the docUrl field.

For this parameter to take effect, the knowledge base feature must be enabled for the agent, and the display the source of the answer option must be enabled.

www.test.com/111.docx

ParserConfig

object

No

The parser configuration. This parameter is required only when the parser type is set to Qwen-VL parsing.

ModelName

string

No

The model name.

qwen3-vl-plus

ModelPrompt

string

No

The prompt to use when calling the Qwen-VL parser.

# Role You are a professional image content annotator, skilled at recognizing and describing the content of images. # Task Based on the input image, describe its content in detail.

Response elements

Element

Type

Description

Example

object

Schema of Response

Code

string

The error code.

DataCenter.FileTooLarge

Data

object

The data returned for the request.

FileId

string

The ID of the file. Save this ID for use in subsequent API calls involving this file.

file_9a65732555b54d5ea10796ca5742ba22_xxxxxxxx

Parser

string

The type of parser used to parse the file. Possible values:

  • DASHSCOPE_DOCMIND: Alibaba Cloud Document Intelligence

DASHSCOPE_DOCMIND

Message

string

The error message.

User not authorized to operate on the specified resource.

RequestId

string

The request ID.

778C0B3B-xxxx-5FC1-A947-36EDD13606AB

Status

string

The status code of the request.

200

Success

string

Indicates whether the API call was successful. Valid values:

  • true: The call was successful.

  • false: The call failed.

true

Examples

Success response

JSON format

{
  "Code": "DataCenter.FileTooLarge",
  "Data": {
    "FileId": "file_9a65732555b54d5ea10796ca5742ba22_xxxxxxxx",
    "Parser": "DASHSCOPE_DOCMIND"
  },
  "Message": "User not authorized to operate on the specified resource.",
  "RequestId": "778C0B3B-xxxx-5FC1-A947-36EDD13606AB",
  "Status": "200",
  "Success": "true"
}

Error codes

For more error codes, visit the Error Center.

Release notes

For more information, see Change details.