Update time series
deprecated
Updates time series. Requires timeSeriesAcl:WRITE. See Time series.
POST
/
timeseries
/
update
JavaScript SDK
const timeseries = await client.timeseries.update([{
id: 3785438579439,
update: {
name: { set: 'New name' }
}
}]);res = client.time_series.retrieve(id=1)
res.description = "New description"
res = client.time_series.update(res)
from cognite.client.data_classes import TimeSeriesUpdate
my_update = TimeSeriesUpdate(id=1).description.set("New description").metadata.add({"key": "value"})
res = client.time_series.update(my_update)
from cognite.client.data_classes import TimeSeriesUpdate
from cognite.client.data_classes.data_modeling import NodeId
my_update = (
TimeSeriesUpdate(instance_id=NodeId("test", "hello"))
.external_id.set("test:hello")
.metadata.add({"test": "hello"})
)
client.time_series.update(my_update)
client.timeseries().upsert(upsertTimeseriesList);
curl --request POST \
--url https://{cluster}.cognitedata.com/api/v1/projects/{project}/timeseries/update \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"items": [
{
"id": 4503599627370496,
"update": {
"externalId": {
"set": "<string>"
},
"name": {
"set": "<string>"
},
"metadata": {
"set": {
"key1": "value1",
"key2": "value2"
}
},
"unit": {
"set": "<string>"
},
"unitExternalId": {
"set": "<string>"
},
"assetId": {
"set": 123
},
"description": {
"set": "<string>"
},
"securityCategories": {
"set": [
123
]
},
"dataSetId": {
"set": 123
}
}
}
]
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{cluster}.cognitedata.com/api/v1/projects/{project}/timeseries/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' => 4503599627370496,
'update' => [
'externalId' => [
'set' => '<string>'
],
'name' => [
'set' => '<string>'
],
'metadata' => [
'set' => [
'key1' => 'value1',
'key2' => 'value2'
]
],
'unit' => [
'set' => '<string>'
],
'unitExternalId' => [
'set' => '<string>'
],
'assetId' => [
'set' => 123
],
'description' => [
'set' => '<string>'
],
'securityCategories' => [
'set' => [
123
]
],
'dataSetId' => [
'set' => 123
]
]
]
]
]),
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}/timeseries/update"
payload := strings.NewReader("{\n \"items\": [\n {\n \"id\": 4503599627370496,\n \"update\": {\n \"externalId\": {\n \"set\": \"<string>\"\n },\n \"name\": {\n \"set\": \"<string>\"\n },\n \"metadata\": {\n \"set\": {\n \"key1\": \"value1\",\n \"key2\": \"value2\"\n }\n },\n \"unit\": {\n \"set\": \"<string>\"\n },\n \"unitExternalId\": {\n \"set\": \"<string>\"\n },\n \"assetId\": {\n \"set\": 123\n },\n \"description\": {\n \"set\": \"<string>\"\n },\n \"securityCategories\": {\n \"set\": [\n 123\n ]\n },\n \"dataSetId\": {\n \"set\": 123\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))
}require 'uri'
require 'net/http'
url = URI("https://{cluster}.cognitedata.com/api/v1/projects/{project}/timeseries/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\": 4503599627370496,\n \"update\": {\n \"externalId\": {\n \"set\": \"<string>\"\n },\n \"name\": {\n \"set\": \"<string>\"\n },\n \"metadata\": {\n \"set\": {\n \"key1\": \"value1\",\n \"key2\": \"value2\"\n }\n },\n \"unit\": {\n \"set\": \"<string>\"\n },\n \"unitExternalId\": {\n \"set\": \"<string>\"\n },\n \"assetId\": {\n \"set\": 123\n },\n \"description\": {\n \"set\": \"<string>\"\n },\n \"securityCategories\": {\n \"set\": [\n 123\n ]\n },\n \"dataSetId\": {\n \"set\": 123\n }\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"items": [
{
"id": 4503599627370496,
"isString": true,
"type": "<string>",
"isStep": true,
"createdTime": 1730204346000,
"lastUpdatedTime": 1730204346000,
"externalId": "<string>",
"instanceId": {
"space": "<string>",
"externalId": "<string>"
},
"name": "<string>",
"stateSet": {
"space": "<string>",
"externalId": "<string>"
},
"metadata": {},
"unit": "<string>",
"unitExternalId": "<string>",
"assetId": 4503599627370496,
"description": "<string>",
"securityCategories": [
123
],
"dataSetId": 4503599627370496
}
]
}{
"error": {
"code": 400,
"message": "<string>",
"missing": [
{
"id": 4503599627370496
}
]
}
}{
"error": {
"code": 409,
"message": "<string>",
"duplicated": [
{
"externalId": "my.known.id"
}
]
}
}{
"error": {
"code": 422,
"message": "<string>",
"duplicated": [
{
"id": 4503599627370496
}
]
}
}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
List of changes.
⌘I
JavaScript SDK
const timeseries = await client.timeseries.update([{
id: 3785438579439,
update: {
name: { set: 'New name' }
}
}]);res = client.time_series.retrieve(id=1)
res.description = "New description"
res = client.time_series.update(res)
from cognite.client.data_classes import TimeSeriesUpdate
my_update = TimeSeriesUpdate(id=1).description.set("New description").metadata.add({"key": "value"})
res = client.time_series.update(my_update)
from cognite.client.data_classes import TimeSeriesUpdate
from cognite.client.data_classes.data_modeling import NodeId
my_update = (
TimeSeriesUpdate(instance_id=NodeId("test", "hello"))
.external_id.set("test:hello")
.metadata.add({"test": "hello"})
)
client.time_series.update(my_update)
client.timeseries().upsert(upsertTimeseriesList);
curl --request POST \
--url https://{cluster}.cognitedata.com/api/v1/projects/{project}/timeseries/update \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"items": [
{
"id": 4503599627370496,
"update": {
"externalId": {
"set": "<string>"
},
"name": {
"set": "<string>"
},
"metadata": {
"set": {
"key1": "value1",
"key2": "value2"
}
},
"unit": {
"set": "<string>"
},
"unitExternalId": {
"set": "<string>"
},
"assetId": {
"set": 123
},
"description": {
"set": "<string>"
},
"securityCategories": {
"set": [
123
]
},
"dataSetId": {
"set": 123
}
}
}
]
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{cluster}.cognitedata.com/api/v1/projects/{project}/timeseries/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' => 4503599627370496,
'update' => [
'externalId' => [
'set' => '<string>'
],
'name' => [
'set' => '<string>'
],
'metadata' => [
'set' => [
'key1' => 'value1',
'key2' => 'value2'
]
],
'unit' => [
'set' => '<string>'
],
'unitExternalId' => [
'set' => '<string>'
],
'assetId' => [
'set' => 123
],
'description' => [
'set' => '<string>'
],
'securityCategories' => [
'set' => [
123
]
],
'dataSetId' => [
'set' => 123
]
]
]
]
]),
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}/timeseries/update"
payload := strings.NewReader("{\n \"items\": [\n {\n \"id\": 4503599627370496,\n \"update\": {\n \"externalId\": {\n \"set\": \"<string>\"\n },\n \"name\": {\n \"set\": \"<string>\"\n },\n \"metadata\": {\n \"set\": {\n \"key1\": \"value1\",\n \"key2\": \"value2\"\n }\n },\n \"unit\": {\n \"set\": \"<string>\"\n },\n \"unitExternalId\": {\n \"set\": \"<string>\"\n },\n \"assetId\": {\n \"set\": 123\n },\n \"description\": {\n \"set\": \"<string>\"\n },\n \"securityCategories\": {\n \"set\": [\n 123\n ]\n },\n \"dataSetId\": {\n \"set\": 123\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))
}require 'uri'
require 'net/http'
url = URI("https://{cluster}.cognitedata.com/api/v1/projects/{project}/timeseries/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\": 4503599627370496,\n \"update\": {\n \"externalId\": {\n \"set\": \"<string>\"\n },\n \"name\": {\n \"set\": \"<string>\"\n },\n \"metadata\": {\n \"set\": {\n \"key1\": \"value1\",\n \"key2\": \"value2\"\n }\n },\n \"unit\": {\n \"set\": \"<string>\"\n },\n \"unitExternalId\": {\n \"set\": \"<string>\"\n },\n \"assetId\": {\n \"set\": 123\n },\n \"description\": {\n \"set\": \"<string>\"\n },\n \"securityCategories\": {\n \"set\": [\n 123\n ]\n },\n \"dataSetId\": {\n \"set\": 123\n }\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"items": [
{
"id": 4503599627370496,
"isString": true,
"type": "<string>",
"isStep": true,
"createdTime": 1730204346000,
"lastUpdatedTime": 1730204346000,
"externalId": "<string>",
"instanceId": {
"space": "<string>",
"externalId": "<string>"
},
"name": "<string>",
"stateSet": {
"space": "<string>",
"externalId": "<string>"
},
"metadata": {},
"unit": "<string>",
"unitExternalId": "<string>",
"assetId": 4503599627370496,
"description": "<string>",
"securityCategories": [
123
],
"dataSetId": 4503599627370496
}
]
}{
"error": {
"code": 400,
"message": "<string>",
"missing": [
{
"id": 4503599627370496
}
]
}
}{
"error": {
"code": 409,
"message": "<string>",
"duplicated": [
{
"externalId": "my.known.id"
}
]
}
}{
"error": {
"code": 422,
"message": "<string>",
"duplicated": [
{
"id": 4503599627370496
}
]
}
}