Updates the information for the files specified in the request body.
If you want to update the file content, uploaded using the uploadUrl, please use the initFileUpload request with the query parameter 'overwrite=true'. Alternatively, delete and recreate the file.
For primitive fields (String, Long, Int), use 'set': 'value' to update value; use 'setNull': true to set that field to null.
For the Json Array field (e.g. assetIds and securityCategories): Use either only 'set', or a combination of 'add' and/or 'remove'.
AssetIds update examples:
Example request body to overwrite assetIds with a new set, asset ID 1 and 2.
{
"items": [
{
"id": 1,
"update": {
"assetIds" : {
"set" : [ 1, 2 ]
}
}
}
]
}
Example request body to add one asset Id, and remove another asset ID.
{
"items": [
{
"id": 1,
"update": {
"assetIds" : {
"add" : [ 3 ],
"remove": [ 2 ]
}
}
}
]
}
Metadata update examples:
Example request body to overwrite metadata with a new set.
{
"items": [
{
"id": 1,
"update": {
"metadata": {
"set": {
"key1": "value1",
"key2": "value2"
}
}
}
}
]
}
Example request body to add two key-value pairs and remove two other key-value pairs by key for the metadata field.
{
"items": [
{
"id": 1,
"update": {
"metadata": {
"add": {
"key3": "value3",
"key4": "value4"
},
"remove": [
"key1",
"key2"
]
}
}
}
]
}
Please note that this endpoint is subject to the new throttling policy, which imposes limits on both request rate and concurrency. For more details, please refer to the Files resource documentation.
The JSON request body which specifies which files and fields to update.
required | Array of FileChangeUpdateById (object) or FileChangeUpdateByExternalId (object) or FileChangeUpdateByInstanceId (object) (FileChangeUpdate) [ 1 .. 1000 ] items |
The response for a successful files/byids, files/search or files/update operation
The response for a failed request.
file_metadata = client.files.retrieve(id=1) file_metadata.description = "New description" res = client.files.update(file_metadata) from cognite.client.data_classes import FileMetadataUpdate my_update = FileMetadataUpdate(id=1).source.set("new source").metadata.add({"key": "value"}) res = client.files.update(my_update) from cognite.client.data_classes import FileMetadataUpdate my_update = FileMetadataUpdate(id=1).labels.add(["PUMP", "VERIFIED"]) res = client.files.update(my_update) from cognite.client.data_classes import FileMetadataUpdate my_update = FileMetadataUpdate(id=1).labels.remove("PUMP") res = client.files.update(my_update)
{- "items": [
- {
- "externalId": "my.known.id",
- "name": "string",
- "directory": "string",
- "source": "string",
- "mimeType": "image/jpeg",
- "metadata": {
- "property1": "string",
- "property2": "string"
}, - "assetIds": [
- 1
], - "dataSetId": 1,
- "sourceCreatedTime": 1730204346000,
- "sourceModifiedTime": 1730204346000,
- "securityCategories": [
- 1
], - "labels": [
- {
- "externalId": "my.known.id"
}
], - "geoLocation": {
- "type": "Feature",
- "geometry": {
- "type": "Point",
- "coordinates": [
- 0,
- 0
]
}, - "properties": { }
}, - "id": 1,
- "uploaded": true,
- "uploadedTime": 1730204346000,
- "createdTime": 1730204346000,
- "lastUpdatedTime": 1730204346000,
- "instanceId": {
- "space": "string",
- "externalId": "string"
}
}
]
}