All Products
Search
Document Center

Drive and Photo Service:CopyFile

Last Updated:May 26, 2026

Copies a file or directory.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

No authorization for this operation. If you encounter issues with this operation, contact technical support.

Request syntax

POST /v2/file/copy HTTP/1.1

Request parameters

Parameter

Type

Required

Description

Example

domain_id

string

Yes

The domain ID.

body

object

No

The request body.

share_id

string

No

The share ID. If you access a file through a share, include the x-share-token header for authentication and specify this parameter. In this case, the drive_id parameter is ignored. Alternatively, authenticate with an AccessKey pair or an access token and specify the drive_id parameter. You must specify either the share_id or drive_id parameter.

7JQX1FswpQ8

drive_id

string

No

The drive ID.

1

file_id

string

Yes

The file ID or folder ID.

4221bf6e6ab43c255edc4463bf3a6f5f5d317406

to_drive_id

string

No

The ID of the destination drive. By default, this parameter is set to the value of drive_id.

1

to_parent_file_id

string

Yes

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

6520943DC261

auto_rename

boolean

No

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

true

Response elements

Element

Type

Description

Example

object

domain_id

string

The domain ID.

bj1

drive_id

string

The drive ID.

1

file_id

string

The ID of the new file or folder.

4221bf6e6ab43a255edc4463bffa6f5f5d317401

async_task_id

string

The asynchronous task ID.

This parameter is returned only for folder copy operations. Copying a folder is an asynchronous task. Use this ID with the GetAsyncTask operation to query the task status.

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

Examples

Success response

JSON format

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

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.