Update file details

files/{file_id}

This call updates the name, the full set metadata, and tags for a specified file.

Files are specified by their IDs, which you can obtain by making the API call to list files in a project .

A full list of metadata fields and their permissible values on the Platform is available on the page Metadata for your private data.

https://api.sb.biodatacatalyst.nhlbi.nih.gov/v2/files/{file_id}

🚧

File names and IDs

Note that the file name is not the same as its ID. The ID is a hexadecimal string, automatically assigned to a file in a project. The file's name is a human-readable string. For information, please see the API overview.

Custom metadata fields

Apart from the standard set of metadata fields that can be seen through the visual interface, you are also able to add custom metadata for your files. Custom metadata fields are user-defined key-value pairs that allow you to provide additional metadata associated to files on the Platform.

Custom metadata can be added via the command line uploader or via the API, but not through the visual interface.

📘

Custom metadata fields will not be visible on the visual interface, but their values can be retrieved by getting file details via the API.

When adding custom metadata fields, you need to pay attention to the following set of rules:

  • Keys and values are case sensitive unless explicitly treated differently by a tool or a part of the Platform.

  • Maximum number of key-value pairs per file is 1000, including null-value keys.

  • Keys and values are UTF-8 encoded strings.

  • Maximum length of a key is 100 bytes (UTF-8 encoding).

  • Maximum length of a value is 300 bytes (UTF-8 encoding).

TAGS

You can use this API request to add or edit previously existing tags for your file. You can tag your files on the Platform with keywords to make it easier to identify and organize files you’ve imported from datasets or copied between projects. Learn more about tagging your files.

In addition to editing tags on your files, you can do the following via the API:

Request

Example request

PATCH /v2/files/567890abc8a5639cc6722063 HTTP/1.1
Host: api.sb.biodatacatalyst.nhlbi.nih.gov
X-SBG-Auth-Token: 1e43fEXampLEa5523dfd14exAMPle3e5
curl --data '{"metadata": {disease_type: "Acute Myeloid Leukemia"}} -s -H "X-SBG-Auth-Token: 6282d5e2121d43e7900e9d52b15845e7" -H "content-type: application/json" -X PATCH "https://api.sb.biodatacatalyst.nhlbi.nih.gov/v2/files/567890abc8a5639cc6722063"

Header Fields

NameDescription
X-SBG-Auth-Token
required
Your Platform authentication token.

Path parameters

NameDescription
file_idThe ID of the file whose details you want to update.

Query parameters

NameData typeDescription
fieldsstringSelector specifying a subset of fields to include in the response.

Request body

You should enter the body as key-value pairs, with the following format:

KeyDatatype of valueDescription of value
namestringThe new name of the file.
metadatadictionary of key-value pairs. The keys and values are strings.The metadata fields and their values that you want to update.
tagsarrayThe tags you want to update.

Example request body

In the example below, I have submitted a request to add the metadata field disease_type with value "Acute Myeloid Leukemia". This request also adds the tags test 1b and big sample.

{
  "name": "1_1000Genomes_phase1.snps.high_confidence.b37.vcf",
  "metadata": {
    disease_type: "Acute Myeloid Leukemia"
    },
  "tags": ["test 1b", "big sample"]
}

Response

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

Example response body

{
  "href": "https://api.sb.biodatacatalyst.nhlbi.nih.gov/v2/files/567890abc8a5639cc6722063",
  "id": "567890abc8a5639cc6722063",
  "name": "1_1000G_phase1.snps.high_confidence.b37.vcf",
  "size": 363,
  "project": "RFranklin/my-project",
  "created_on": "2015-12-11T11:01:49Z",
  "modified_on": "2016-01-07T12:22:12Z",
  "origin": {},
  "metadata": {
    "file_type": "vcf",
    "disease_type": "Acute Myeloid Leukemia",
    "file_extension": "VCF"
  },
  "tags":[
    "test 1b",
    "big sample"
  ]
}

Interpreting the response body:

  • The object origin denotes the task that produced the file, if it was created by a task on the Platform.
  • The dictionary object metadata lists the metadata fields and values for the file.
  • The object tags lists the tags for the file. Learn more about tagging your files.