Update annotations
deprecated
Required capabilities:
annotationsAcl:WRITE
Updates the referenced annotations.
The caller must have read-access on all the annotated resources, otherwise the call will fail.
POST
/
annotations
/
update
JavaScript SDK
const data = {
pageNumber: 8,
fileRef: { externalId: 'def_file_changed' },
textRegion: { xMin: 0, xMax: 0.1, yMin: 0, yMax: 0.2 },
};
const changes = [
{
id: 1,
update: {
data: {
set: data,
},
},
},
];
const updatedResp = await client.annotations.update(changes);curl --request POST \
--url https://{cluster}.cognitedata.com/api/v1/projects/{project}/annotations/update \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"items": [
{
"id": 4096,
"update": {
"data": {
"set": {
"assetRef": {
"externalId": "abc"
},
"symbolRegion": {
"xMin": 0.1,
"xMax": 0.2,
"yMin": 0.1,
"yMax": 0.2
},
"textRegion": {
"xMin": 0.4,
"xMax": 0.5,
"yMin": 0.4,
"yMax": 0.5
},
"pageNumber": 43
}
}
}
}
]
}
'import requests
url = "https://{cluster}.cognitedata.com/api/v1/projects/{project}/annotations/update"
payload = { "items": [
{
"id": 4096,
"update": { "data": { "set": {
"assetRef": { "externalId": "abc" },
"symbolRegion": {
"xMin": 0.1,
"xMax": 0.2,
"yMin": 0.1,
"yMax": 0.2
},
"textRegion": {
"xMin": 0.4,
"xMax": 0.5,
"yMin": 0.4,
"yMax": 0.5
},
"pageNumber": 43
} } }
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{cluster}.cognitedata.com/api/v1/projects/{project}/annotations/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' => [
[
'id' => 4096,
'update' => [
'data' => [
'set' => [
'assetRef' => [
'externalId' => 'abc'
],
'symbolRegion' => [
'xMin' => 0.1,
'xMax' => 0.2,
'yMin' => 0.1,
'yMax' => 0.2
],
'textRegion' => [
'xMin' => 0.4,
'xMax' => 0.5,
'yMin' => 0.4,
'yMax' => 0.5
],
'pageNumber' => 43
]
]
]
]
]
]),
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}/annotations/update"
payload := strings.NewReader("{\n \"items\": [\n {\n \"id\": 4096,\n \"update\": {\n \"data\": {\n \"set\": {\n \"assetRef\": {\n \"externalId\": \"abc\"\n },\n \"symbolRegion\": {\n \"xMin\": 0.1,\n \"xMax\": 0.2,\n \"yMin\": 0.1,\n \"yMax\": 0.2\n },\n \"textRegion\": {\n \"xMin\": 0.4,\n \"xMax\": 0.5,\n \"yMin\": 0.4,\n \"yMax\": 0.5\n },\n \"pageNumber\": 43\n }\n }\n }\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))
}HttpResponse<String> response = Unirest.post("https://{cluster}.cognitedata.com/api/v1/projects/{project}/annotations/update")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"items\": [\n {\n \"id\": 4096,\n \"update\": {\n \"data\": {\n \"set\": {\n \"assetRef\": {\n \"externalId\": \"abc\"\n },\n \"symbolRegion\": {\n \"xMin\": 0.1,\n \"xMax\": 0.2,\n \"yMin\": 0.1,\n \"yMax\": 0.2\n },\n \"textRegion\": {\n \"xMin\": 0.4,\n \"xMax\": 0.5,\n \"yMin\": 0.4,\n \"yMax\": 0.5\n },\n \"pageNumber\": 43\n }\n }\n }\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{cluster}.cognitedata.com/api/v1/projects/{project}/annotations/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 \"id\": 4096,\n \"update\": {\n \"data\": {\n \"set\": {\n \"assetRef\": {\n \"externalId\": \"abc\"\n },\n \"symbolRegion\": {\n \"xMin\": 0.1,\n \"xMax\": 0.2,\n \"yMin\": 0.1,\n \"yMax\": 0.2\n },\n \"textRegion\": {\n \"xMin\": 0.4,\n \"xMax\": 0.5,\n \"yMin\": 0.4,\n \"yMax\": 0.5\n },\n \"pageNumber\": 43\n }\n }\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"items": [
{
"id": 4096,
"createdTime": 1730204346000,
"lastUpdatedTime": 1730204346000,
"annotatedResourceType": "file",
"annotatedResourceId": 1337,
"annotationType": "pointcloud.BoundingVolume",
"creatingApp": "cognite-vision",
"creatingAppVersion": "1.2.1",
"creatingUser": "john.doe@cognite.com",
"data": {
"assetRef": {
"externalId": "abc"
}
},
"status": "approved"
}
]
}{
"error": {
"code": 401,
"message": "Could not authenticate.",
"missing": [
{}
],
"duplicated": [
{}
]
}
}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
A request for updating existing annotations
⌘I
JavaScript SDK
const data = {
pageNumber: 8,
fileRef: { externalId: 'def_file_changed' },
textRegion: { xMin: 0, xMax: 0.1, yMin: 0, yMax: 0.2 },
};
const changes = [
{
id: 1,
update: {
data: {
set: data,
},
},
},
];
const updatedResp = await client.annotations.update(changes);curl --request POST \
--url https://{cluster}.cognitedata.com/api/v1/projects/{project}/annotations/update \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"items": [
{
"id": 4096,
"update": {
"data": {
"set": {
"assetRef": {
"externalId": "abc"
},
"symbolRegion": {
"xMin": 0.1,
"xMax": 0.2,
"yMin": 0.1,
"yMax": 0.2
},
"textRegion": {
"xMin": 0.4,
"xMax": 0.5,
"yMin": 0.4,
"yMax": 0.5
},
"pageNumber": 43
}
}
}
}
]
}
'import requests
url = "https://{cluster}.cognitedata.com/api/v1/projects/{project}/annotations/update"
payload = { "items": [
{
"id": 4096,
"update": { "data": { "set": {
"assetRef": { "externalId": "abc" },
"symbolRegion": {
"xMin": 0.1,
"xMax": 0.2,
"yMin": 0.1,
"yMax": 0.2
},
"textRegion": {
"xMin": 0.4,
"xMax": 0.5,
"yMin": 0.4,
"yMax": 0.5
},
"pageNumber": 43
} } }
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{cluster}.cognitedata.com/api/v1/projects/{project}/annotations/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' => [
[
'id' => 4096,
'update' => [
'data' => [
'set' => [
'assetRef' => [
'externalId' => 'abc'
],
'symbolRegion' => [
'xMin' => 0.1,
'xMax' => 0.2,
'yMin' => 0.1,
'yMax' => 0.2
],
'textRegion' => [
'xMin' => 0.4,
'xMax' => 0.5,
'yMin' => 0.4,
'yMax' => 0.5
],
'pageNumber' => 43
]
]
]
]
]
]),
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}/annotations/update"
payload := strings.NewReader("{\n \"items\": [\n {\n \"id\": 4096,\n \"update\": {\n \"data\": {\n \"set\": {\n \"assetRef\": {\n \"externalId\": \"abc\"\n },\n \"symbolRegion\": {\n \"xMin\": 0.1,\n \"xMax\": 0.2,\n \"yMin\": 0.1,\n \"yMax\": 0.2\n },\n \"textRegion\": {\n \"xMin\": 0.4,\n \"xMax\": 0.5,\n \"yMin\": 0.4,\n \"yMax\": 0.5\n },\n \"pageNumber\": 43\n }\n }\n }\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))
}HttpResponse<String> response = Unirest.post("https://{cluster}.cognitedata.com/api/v1/projects/{project}/annotations/update")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"items\": [\n {\n \"id\": 4096,\n \"update\": {\n \"data\": {\n \"set\": {\n \"assetRef\": {\n \"externalId\": \"abc\"\n },\n \"symbolRegion\": {\n \"xMin\": 0.1,\n \"xMax\": 0.2,\n \"yMin\": 0.1,\n \"yMax\": 0.2\n },\n \"textRegion\": {\n \"xMin\": 0.4,\n \"xMax\": 0.5,\n \"yMin\": 0.4,\n \"yMax\": 0.5\n },\n \"pageNumber\": 43\n }\n }\n }\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{cluster}.cognitedata.com/api/v1/projects/{project}/annotations/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 \"id\": 4096,\n \"update\": {\n \"data\": {\n \"set\": {\n \"assetRef\": {\n \"externalId\": \"abc\"\n },\n \"symbolRegion\": {\n \"xMin\": 0.1,\n \"xMax\": 0.2,\n \"yMin\": 0.1,\n \"yMax\": 0.2\n },\n \"textRegion\": {\n \"xMin\": 0.4,\n \"xMax\": 0.5,\n \"yMin\": 0.4,\n \"yMax\": 0.5\n },\n \"pageNumber\": 43\n }\n }\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"items": [
{
"id": 4096,
"createdTime": 1730204346000,
"lastUpdatedTime": 1730204346000,
"annotatedResourceType": "file",
"annotatedResourceId": 1337,
"annotationType": "pointcloud.BoundingVolume",
"creatingApp": "cognite-vision",
"creatingAppVersion": "1.2.1",
"creatingUser": "john.doe@cognite.com",
"data": {
"assetRef": {
"externalId": "abc"
}
},
"status": "approved"
}
]
}{
"error": {
"code": 401,
"message": "Could not authenticate.",
"missing": [
{}
],
"duplicated": [
{}
]
}
}