Skip to main content
POST
/
timeseries
/
data
JavaScript SDK
await client.datapoints.insert([{ id: 123, datapoints: [{timestamp: 1557320284000, value: -2}] }]);
from cognite.client.data_classes.data_modeling import NodeId
from cognite.client.data_classes import StatusCode
from datetime import datetime, timezone
to_insert = [
{"id": 1, "datapoints": [
(datetime(2018,1,1, tzinfo=timezone.utc), 1000),
(datetime(2018,1,2, tzinfo=timezone.utc), 2000, StatusCode.Good)],
},
{"external_id": "foo", "datapoints": [
(datetime(2018,1,3, tzinfo=timezone.utc), 3000),
(datetime(2018,1,4, tzinfo=timezone.utc), 4000, StatusCode.Uncertain)],
},
{"instance_id": NodeId("my-space", "my-ts-xid"), "datapoints": [
(datetime(2018,1,5, tzinfo=timezone.utc), 5000),
(datetime(2018,1,6, tzinfo=timezone.utc), None, StatusCode.Bad)],
}
]

import math
to_insert.append(
{"external_id": "bar", "datapoints": [
{"timestamp": 170000000, "value": 7000},
{"timestamp": 180000000, "value": 8000, "status": {"symbol": "Uncertain"}},
{"timestamp": 190000000, "value": None, "status": {"code": StatusCode.Bad}},
{"timestamp": 200000000, "value": math.inf, "status": {"code": StatusCode.Bad, "symbol": "Bad"}},
]})

data_to_clone = client.time_series.data.retrieve(
external_id="bar", include_status=True, ignore_bad_datapoints=False)
to_insert.append({"external_id": "bar-clone", "datapoints": data_to_clone})
client.time_series.data.insert_multiple(to_insert)
List<TimeseriesPointPost> items = new ArrayList<>(); items.add(TimeseriesPointPost.newBuilder() 
.setExternalId("TimeseriesMetadata.id")
.setTimestamp(timeStamp.toEpochMilli())
.setValueNum(ThreadLocalRandom.current().nextLong(-10, 20))
.build());
client.timeseries().dataPoints().upsert(items);
curl --request POST \
--url https://{cluster}.cognitedata.com/api/v1/projects/{project}/timeseries/data \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"items": [
{
"id": 4503599627370496,
"datapoints": [
{
"timestamp": 946727999999.5,
"value": 123,
"status": {
"code": 123,
"symbol": "<string>"
}
}
]
}
]
}
'
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://{cluster}.cognitedata.com/api/v1/projects/{project}/timeseries/data",
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,
'datapoints' => [
[
'timestamp' => 946727999999.5,
'value' => 123,
'status' => [
'code' => 123,
'symbol' => '<string>'
]
]
]
]
]
]),
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/data"

payload := strings.NewReader("{\n \"items\": [\n {\n \"id\": 4503599627370496,\n \"datapoints\": [\n {\n \"timestamp\": 946727999999.5,\n \"value\": 123,\n \"status\": {\n \"code\": 123,\n \"symbol\": \"<string>\"\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))

}
require 'uri'
require 'net/http'

url = URI("https://{cluster}.cognitedata.com/api/v1/projects/{project}/timeseries/data")

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 \"datapoints\": [\n {\n \"timestamp\": 946727999999.5,\n \"value\": 123,\n \"status\": {\n \"code\": 123,\n \"symbol\": \"<string>\"\n }\n }\n ]\n }\n ]\n}"

response = http.request(request)
puts response.read_body
{}
{
"error": {
"code": 400,
"message": "<string>",
"missing": [
{
"id": 4503599627370496
}
]
}
}
{
"error": {
"code": 422,
"message": "<string>",
"duplicated": [
{
"id": 4503599627370496
}
]
}
}

Authorizations

Authorization
string
header
required

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.

Body

The datapoints to insert.

items
(DatapointsWithInternalId · object | DatapointsWithExternalId · object | DatapointsWithInstanceId · object)[]
required
Required array length: 1 - 10000 elements

Response

Empty response.

The response is of type object.

Last modified on July 10, 2026