Copy files between projects


This call allows you to copy files between projects. Unlike the call Copy a file, this call lets you batch the copy operation, to copy a list of files at a time.

Note that this call can be used in conjunction with the Datasets API as well as SPARQL to access data from datasets.


File IDs

Note that a file's ID is dependent on the project it is contained in. So, when you copy files from one project to another, their IDs will be different in the target project.

The file names, however, do not change by copying, except where copying would yield non-unique file names in a project. For details of this use case, see the tipbox at the bottom of the page.

Files are specified by their IDs, which you can obtain by making the API call to list all files accessible to you.


Example request

POST /v2/action/files/copy HTTP/1.1
X-SBG-Auth-Token: 7942f56901534434a054dafc3813bc96
curl --data '{"project": "RFranklin/my-project", "file_ids": ["567890abc3d8130ea4047731"]}' -s -H "X-SBG-Auth-Token: 7942f56901534434a054dafc3813bc96" -H "content-type: application/json" -X POST ""

Request body

In the body, you should enter a list of key-value pairs. The keys, and the values they take, are described in the following table.

KeyData type of valueContent of value
projectstringThe name of the project you want to copy into.
file_idsa list of stringsThe IDs of the files you want to copy.

Example request body

	"project": "RFranklin/my-project",
	"file_ids": ["567890abc3d8130ea4047731", "567890abc8a5136ec6127063"]


Header Fields

Your authentication token.


See a list of response codes that may be contained in the body of the response.

Example response body

  "567890abc8a5136ec6127063": {
    "status": "OK",
    "new_file_id": "567890abc9b0307bc0414164",
    "new_file_name": "sorted.bam"


Interpreting the request body

The request returns an object "new_file_name" for every file copied.

The "new_file_name" will be the same as the file's old name in all cases except for the case in which you already have a file with that name in the target project. If an identically-named file exists in the project, then the copied file will be automatically renamed by prefixing it with an increment of 1. For instance, if I copy the file named file.ext to my project, and there already exists a file.ext there, then my incoming file will be renamed 1_file.ext.

It is not possible to re-name files other than by this automatic procedure with this call. If you want to copy and rename a file, use the alternative (non-batch) call to copy a file. This restriction optimizes the batch request: it adds 100ms per file to rename it during copying, so if copying 100 files, it would take 10s longer to rename all of them.