Update files

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"
          ]
        }
      }
    }
  ]
}

Request throttling

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.

Securityoidc-token or oauth2-client-credentials or oauth2-open-industrial-data or oauth2-auth-code
Request
Request Body schema: application/json
required

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
Responses
200

The response for a successful files/byids, files/search or files/update operation

400

The response for a failed request.

post/files/update
Request samples
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)
Response samples
application/json
{
  • "items": [
    • {
      }
    ]
}