All Products
Search
Document Center

Drive and Photo Service:CopyFile

Last Updated:Aug 04, 2025

Copies a file or folder.

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

Authorization information

There is currently no authorization information disclosed in the API.

Request syntax

POST /v2/file/copy HTTP/1.1

Request parameters

ParameterTypeRequiredDescriptionExample
bodyobjectNo

The request parameters.

share_idstringNo

The share ID. If you want to manage a file by using a share link, carry the x-share-token header for authentication in the request and specify share_id. In this case, drive_id is invalid. Otherwise, use an AccessKey pair or access token for authentication and specify drive_id. You must specify one of share_id and drive_id.

7JQX1FswpQ8
drive_idstringNo

The drive ID.

1
file_idstringYes

The file ID or folder ID.

4221bf6e6ab43c255edc4463bf3a6f5f5d317406
to_drive_idstringNo

The ID of the drive to which you want to copy the file or folder. Default value: the value of drive_id.

1
to_parent_file_idstringYes

The ID of the destination parent folder. If you want to copy the file or folder to a root directory, set this parameter to root.

6520943DC261
auto_renamebooleanNo

Specifies whether to automatically rename the file if the file name already exists in the destination folder. Default value: false.

true

Response parameters

ParameterTypeDescriptionExample
object
domain_idstring

The domain ID.

bj1
drive_idstring

The drive ID.

1
file_idstring

The ID of the copied file or folder.

4221bf6e6ab43a255edc4463bffa6f5f5d317401
async_task_idstring

The ID of the asynchronous task.

If a file is copied, this parameter is not returned. If a folder is copied, the folder is asynchronously copied in the background and this parameter is returned. You can call the GetAsyncTask operation to query the information about the asynchronous task based on the task ID.

000e89fb-cf8f-11e9-8ab4-b6e980803a3b

Examples

Sample success responses

JSONformat

{
  "domain_id": "bj1",
  "drive_id": 1,
  "file_id": "4221bf6e6ab43a255edc4463bffa6f5f5d317401",
  "async_task_id": "000e89fb-cf8f-11e9-8ab4-b6e980803a3b"
}

Error codes

For a list of error codes, visit the Service error codes.