/files/{file_id}/metadata
This call modifies the metadata values for the specified file.
Metadata
Learn more about metadata fields and their values for your uploaded, private files on the CGC.
Files are specified by their IDs, which you can obtain by making the API call to list files in a project .
https://cgc-api.sbgenomics.com/v2/files/{file_id}/metadata
PUT and PATCH
The CGC API has two method to modify file metadata. This method uses the HTTP verb
PATCH
, and the other uses the HTTP verbPUT
.The difference between the two concerns the way that they update the information stored about the user.
PATCH
allows you to update just one metadata field. On the other hand, aPUT
request will fully overwrite the values for all metadata fields. This means that when issuing aPUT
request you must enter values for every key required to specify the metadata, even if the values for some keys are unchanged. If you don't specify a value for a given metadata field when making thePUT
request, then any existing value for that field will be reset.
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 CGC. 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 CGC.
- Maximum number of key-value pairs per file is 1000.
- 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).
- Null values and keys are ignored and not counted towards the 1000 key-value pair limit.
Request
Example request
PATCH /v2/files/568e69abe9b0307bc0414164/metadata HTTP/1.1
Host: cgc-api.sbgenomics.com
X-SBG-Auth-Token: 3210a98c1db9318fa9d9273156740f74
curl --data '{"foo": "bar"}' -s -H "X-SBG-Auth-Token: 3210a98c1db9318fa9d9273156740f74" -H "content-type: application/json" -X PATCH "https://cgc-api.sbgenomics.com/v2/files/568e69abe9b0307bc0414164/metadata"
Header Fields
Name | Description |
---|---|
X-SBG-Auth-Token required | Your CGC authentication token. |
Path parameters
Name | Description |
---|---|
file_id | The ID of the file whose metadata you want to update. |
Query parameters
Name | Data type | Description |
---|---|---|
fields | string | Selector specifying a subset of fields to include in the response. |
Request body
Enter a dictionary of key-value pairs to the request body.
Key | Datatype of value | Description of value |
---|---|---|
Freeform -- enter any key. | string | The value for the corresponding key |
Example request body
{
"foo": "bar"
}
TCGA metadata
You cannot edit the metadata for TCGA files. You can only edit metadata for files that you create or upload.
Response
See a list of CGC-specific response codes that may be contained in the body of the response.
Example response body
The response contains the full metadata specification for the file, including the values that you just added with the request.
{
"library_id": "12345",
"platform": "my_platform",
"foo": "bar",
"my_key_1": "my_value_1",
"my_key_2": "my_value_2"
}