Update assets
deprecated
Required capabilities:
assetsAcl:WRITE
Update the attributes of assets.
Request throttling
This endpoint is a subject of the new throttling schema (limited request rate and concurrency). Please check Assets resource description for more information.
POST
/
assets
/
update
JavaScript SDK
const assets = await client.assets.update([{id: 123, update: {name: {set: 'New name'}}}]);from cognite.client.data_classes import AssetUpdate
my_update = AssetUpdate(id=1).description.set("New description").metadata.add({"key": "value"})
res1 = client.assets.update(my_update)
another_update = AssetUpdate(id=1).description.set(None)
res2 = client.assets.update(another_update)
from cognite.client.data_classes import AssetUpdate
my_update = AssetUpdate(id=1).metadata.add({"key": "value"})
res1 = client.assets.update(my_update)
another_update = AssetUpdate(id=1).metadata.set(None)
another_update2 = AssetUpdate(id=1).metadata.set({})
res2 = client.assets.update(another_update)
from cognite.client.data_classes import AssetUpdate
my_update = AssetUpdate(id=1).labels.add(["PUMP", "VERIFIED"])
res = client.assets.update(my_update)
from cognite.client.data_classes import AssetUpdate
my_update = AssetUpdate(id=1).labels.remove("PUMP")
res = client.assets.update(my_update)
from cognite.client.data_classes import AssetUpdate
my_update = AssetUpdate(id=1).labels.set("PUMP")
res = client.assets.update(my_update)
List<Asset> upsertedAssets = client.assets().upsert(upsertAssetsList);
curl --request POST \
--url https://{cluster}.cognitedata.com/api/v1/projects/{project}/assets/update \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"items": [
{
"update": {
"externalId": {
"set": "my.known.id"
},
"description": {
"set": "<string>"
},
"dataSetId": {
"set": 123
},
"metadata": {
"set": {
"key1": "value1",
"key2": "value2"
}
},
"source": {
"set": "<string>"
},
"labels": {
"add": [
{
"externalId": "my.known.id"
}
],
"remove": [
{
"externalId": "my.known.id"
}
]
},
"geoLocation": {
"set": {
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
123
]
},
"properties": {}
}
}
},
"id": 4503599627370496
}
]
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{cluster}.cognitedata.com/api/v1/projects/{project}/assets/update",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'items' => [
[
'update' => [
'externalId' => [
'set' => 'my.known.id'
],
'description' => [
'set' => '<string>'
],
'dataSetId' => [
'set' => 123
],
'metadata' => [
'set' => [
'key1' => 'value1',
'key2' => 'value2'
]
],
'source' => [
'set' => '<string>'
],
'labels' => [
'add' => [
[
'externalId' => 'my.known.id'
]
],
'remove' => [
[
'externalId' => 'my.known.id'
]
]
],
'geoLocation' => [
'set' => [
'type' => 'Feature',
'geometry' => [
'type' => 'Point',
'coordinates' => [
123
]
],
'properties' => [
]
]
]
],
'id' => 4503599627370496
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{cluster}.cognitedata.com/api/v1/projects/{project}/assets/update"
payload := strings.NewReader("{\n \"items\": [\n {\n \"update\": {\n \"externalId\": {\n \"set\": \"my.known.id\"\n },\n \"description\": {\n \"set\": \"<string>\"\n },\n \"dataSetId\": {\n \"set\": 123\n },\n \"metadata\": {\n \"set\": {\n \"key1\": \"value1\",\n \"key2\": \"value2\"\n }\n },\n \"source\": {\n \"set\": \"<string>\"\n },\n \"labels\": {\n \"add\": [\n {\n \"externalId\": \"my.known.id\"\n }\n ],\n \"remove\": [\n {\n \"externalId\": \"my.known.id\"\n }\n ]\n },\n \"geoLocation\": {\n \"set\": {\n \"type\": \"Feature\",\n \"geometry\": {\n \"type\": \"Point\",\n \"coordinates\": [\n 123\n ]\n },\n \"properties\": {}\n }\n }\n },\n \"id\": 4503599627370496\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}require 'uri'
require 'net/http'
url = URI("https://{cluster}.cognitedata.com/api/v1/projects/{project}/assets/update")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"items\": [\n {\n \"update\": {\n \"externalId\": {\n \"set\": \"my.known.id\"\n },\n \"description\": {\n \"set\": \"<string>\"\n },\n \"dataSetId\": {\n \"set\": 123\n },\n \"metadata\": {\n \"set\": {\n \"key1\": \"value1\",\n \"key2\": \"value2\"\n }\n },\n \"source\": {\n \"set\": \"<string>\"\n },\n \"labels\": {\n \"add\": [\n {\n \"externalId\": \"my.known.id\"\n }\n ],\n \"remove\": [\n {\n \"externalId\": \"my.known.id\"\n }\n ]\n },\n \"geoLocation\": {\n \"set\": {\n \"type\": \"Feature\",\n \"geometry\": {\n \"type\": \"Point\",\n \"coordinates\": [\n 123\n ]\n },\n \"properties\": {}\n }\n }\n },\n \"id\": 4503599627370496\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"items": [
{
"createdTime": 1730204346000,
"lastUpdatedTime": 1730204346000,
"rootId": 4503599627370496,
"name": "<string>",
"id": 4503599627370496,
"aggregates": {
"childCount": 1,
"depth": 1,
"path": [
{
"id": 4503599627370496
}
]
},
"parentId": 4503599627370496,
"parentExternalId": "my.known.id",
"externalId": "my.known.id",
"description": "<string>",
"dataSetId": 4503599627370496,
"metadata": {},
"source": "<string>",
"labels": [
{
"externalId": "my.known.id"
}
],
"geoLocation": {
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
123
]
},
"properties": {}
}
}
]
}{
"error": {
"code": 400,
"message": "`null` values aren't allowed."
}
}{
"error": {
"code": 429,
"message": "Project exceeded maximum number='50' of concurrent requests. Please try again later."
}
}Authorizations
oidc-tokenoauth2-client-credentialsoauth2-open-industrial-dataoauth2-auth-code
Access token issued by the CDF project's configured identity provider. Access token must be an OpenID Connect token, and the project must be configured to accept OpenID Connect tokens. Use a header key of 'Authorization' with a value of 'Bearer $accesstoken'. The token can be obtained through any flow supported by the identity provider.
Scopes
Body
application/json
All provided IDs and external IDs must be unique. Fields that aren't included in the request aren't changed.
⌘I
JavaScript SDK
const assets = await client.assets.update([{id: 123, update: {name: {set: 'New name'}}}]);from cognite.client.data_classes import AssetUpdate
my_update = AssetUpdate(id=1).description.set("New description").metadata.add({"key": "value"})
res1 = client.assets.update(my_update)
another_update = AssetUpdate(id=1).description.set(None)
res2 = client.assets.update(another_update)
from cognite.client.data_classes import AssetUpdate
my_update = AssetUpdate(id=1).metadata.add({"key": "value"})
res1 = client.assets.update(my_update)
another_update = AssetUpdate(id=1).metadata.set(None)
another_update2 = AssetUpdate(id=1).metadata.set({})
res2 = client.assets.update(another_update)
from cognite.client.data_classes import AssetUpdate
my_update = AssetUpdate(id=1).labels.add(["PUMP", "VERIFIED"])
res = client.assets.update(my_update)
from cognite.client.data_classes import AssetUpdate
my_update = AssetUpdate(id=1).labels.remove("PUMP")
res = client.assets.update(my_update)
from cognite.client.data_classes import AssetUpdate
my_update = AssetUpdate(id=1).labels.set("PUMP")
res = client.assets.update(my_update)
List<Asset> upsertedAssets = client.assets().upsert(upsertAssetsList);
curl --request POST \
--url https://{cluster}.cognitedata.com/api/v1/projects/{project}/assets/update \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"items": [
{
"update": {
"externalId": {
"set": "my.known.id"
},
"description": {
"set": "<string>"
},
"dataSetId": {
"set": 123
},
"metadata": {
"set": {
"key1": "value1",
"key2": "value2"
}
},
"source": {
"set": "<string>"
},
"labels": {
"add": [
{
"externalId": "my.known.id"
}
],
"remove": [
{
"externalId": "my.known.id"
}
]
},
"geoLocation": {
"set": {
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
123
]
},
"properties": {}
}
}
},
"id": 4503599627370496
}
]
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{cluster}.cognitedata.com/api/v1/projects/{project}/assets/update",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'items' => [
[
'update' => [
'externalId' => [
'set' => 'my.known.id'
],
'description' => [
'set' => '<string>'
],
'dataSetId' => [
'set' => 123
],
'metadata' => [
'set' => [
'key1' => 'value1',
'key2' => 'value2'
]
],
'source' => [
'set' => '<string>'
],
'labels' => [
'add' => [
[
'externalId' => 'my.known.id'
]
],
'remove' => [
[
'externalId' => 'my.known.id'
]
]
],
'geoLocation' => [
'set' => [
'type' => 'Feature',
'geometry' => [
'type' => 'Point',
'coordinates' => [
123
]
],
'properties' => [
]
]
]
],
'id' => 4503599627370496
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{cluster}.cognitedata.com/api/v1/projects/{project}/assets/update"
payload := strings.NewReader("{\n \"items\": [\n {\n \"update\": {\n \"externalId\": {\n \"set\": \"my.known.id\"\n },\n \"description\": {\n \"set\": \"<string>\"\n },\n \"dataSetId\": {\n \"set\": 123\n },\n \"metadata\": {\n \"set\": {\n \"key1\": \"value1\",\n \"key2\": \"value2\"\n }\n },\n \"source\": {\n \"set\": \"<string>\"\n },\n \"labels\": {\n \"add\": [\n {\n \"externalId\": \"my.known.id\"\n }\n ],\n \"remove\": [\n {\n \"externalId\": \"my.known.id\"\n }\n ]\n },\n \"geoLocation\": {\n \"set\": {\n \"type\": \"Feature\",\n \"geometry\": {\n \"type\": \"Point\",\n \"coordinates\": [\n 123\n ]\n },\n \"properties\": {}\n }\n }\n },\n \"id\": 4503599627370496\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}require 'uri'
require 'net/http'
url = URI("https://{cluster}.cognitedata.com/api/v1/projects/{project}/assets/update")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"items\": [\n {\n \"update\": {\n \"externalId\": {\n \"set\": \"my.known.id\"\n },\n \"description\": {\n \"set\": \"<string>\"\n },\n \"dataSetId\": {\n \"set\": 123\n },\n \"metadata\": {\n \"set\": {\n \"key1\": \"value1\",\n \"key2\": \"value2\"\n }\n },\n \"source\": {\n \"set\": \"<string>\"\n },\n \"labels\": {\n \"add\": [\n {\n \"externalId\": \"my.known.id\"\n }\n ],\n \"remove\": [\n {\n \"externalId\": \"my.known.id\"\n }\n ]\n },\n \"geoLocation\": {\n \"set\": {\n \"type\": \"Feature\",\n \"geometry\": {\n \"type\": \"Point\",\n \"coordinates\": [\n 123\n ]\n },\n \"properties\": {}\n }\n }\n },\n \"id\": 4503599627370496\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"items": [
{
"createdTime": 1730204346000,
"lastUpdatedTime": 1730204346000,
"rootId": 4503599627370496,
"name": "<string>",
"id": 4503599627370496,
"aggregates": {
"childCount": 1,
"depth": 1,
"path": [
{
"id": 4503599627370496
}
]
},
"parentId": 4503599627370496,
"parentExternalId": "my.known.id",
"externalId": "my.known.id",
"description": "<string>",
"dataSetId": 4503599627370496,
"metadata": {},
"source": "<string>",
"labels": [
{
"externalId": "my.known.id"
}
],
"geoLocation": {
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
123
]
},
"properties": {}
}
}
]
}{
"error": {
"code": 400,
"message": "`null` values aren't allowed."
}
}{
"error": {
"code": 429,
"message": "Project exceeded maximum number='50' of concurrent requests. Please try again later."
}
}