Copy a file between projects

This call copies the specified file to a new project. Files retain their metadata when copied, but may be assigned new names in their target project.

To make this call, you should have copy permission within the project you are copying from.

If you want to copy multiple files, the recommended way is to do it in bulk considering the API rate limit (learn more).

Request

https://api.sbgenomics.com/v2/files/{file_id}/actions/copy
https://eu-api.sbgenomics.com/v2/files/{file_id}/actions/copy

👍

file_ids

Recall from the API Overview that the file_id is a hexadecimal string.

You can get the file_id for a file by making the call to list files within a specified project (primary method).

Example request

POST v2/files/568e69ade4b0307bc0464164/actions/copy HTTP/1.1
Host: api.sbgenomics.com
X-SBG-Auth-Token: 3259c50e1ac5426ea8f1273259740f74
curl --data '{"project": "RFranklin/my-project", "name": "new-file"}'  -s -H "X-SBG-Auth-Token: 7942f56901534434a054dafc3813bc96" -H "content-type: application/json" -X POST "https://api.sbgenomics.com/v2/files/568e69ade4b0307bc0464164/actions/copy"
from sevenbridges import Api

api = Api(url='https://api.sbgenomics.com/v2',
          token='3259c50e1ac5426ea8f1273259740f74')

file = api.files.get(id='568e69ade4b0307bc0464164')

# send POST request to SB API
new_file = file.copy(
    project='RFranklin/my-project',
    name='new-file'
)

print(new_file.name, new_file.id)

Header Fields

Name

Description

X-SBG-Auth-Token
required

Your Seven Bridges Platform authentication token.

Path parameters

Name

Description

file_id

The ID for the file you are querying. It can be obtained by making the call to list your files (primary method).

Query parameters

Name

Data type

Description

fields

string

Selector specifying a subset of fields to include in the response.

Request body

The body should contain the following key-value pairs:

Key

Datatype of value

Description of value

"project"
required

string

The name of the project you want to copy the file to

"name"

string

The new name the file will have in the target project.
If its name will not change, omit this key.

Example request body

{
  "project": "RFranklin/my-project", 
  "name": "new-file"
}

Response

See a list of Seven Bridges Platform-specific response codes that may be contained in the body of the response.

Example response body

The response gives the full specification of the file, and its metadata.

{
  "href": "https://api.sbgenomics.com/v2/files/569637cce4b0b65fcb306ae5",
  "id": "569637cce4b0b65fcb306ae5",
  "name": "new-file",
  "size": 68425,
  "project": "RFranklin/my-project",
  "created_on": "2016-01-13T11:41:00Z",
  "modified_on": "2016-01-13T11:41:00Z",
  "origin": {},
  "metadata": {
      "sample_id": "E16201_pool35_L1756",
      "library_id": "hg19",
      "platform_unit_id": "C18_99",
      "platform": "IonTorrent",
      "quality_scale": "sanger"
    }
}