JavaScript SDK
const timeseries = [
{ name: 'Pressure sensor', assetId: 123 },
{ name: 'Temprature sensor', description: 'Pump abc', unit: 'C' },
];
const createdTimeseries = await client.timeseries.create(timeseries);from cognite.client.data_classes import TimeSeriesWrite
ts = client.time_series.create(TimeSeriesWrite(name="my_ts", data_set_id=123, external_id="foo"))
List<TimeseriesMetadata> upsertTimeseriesList = List.of(TimeseriesMetadata.newBuilder()
.setExternalId("10")
.setName("test_ts")
.setIsString(false)
.setIsStep(false)
.setDescription("Description")
.setUnit("TestUnits")
.putMetadata("type", "sdk-data-generator")
.putMetadata("sdk-data-generator", "sdk-data-generator")
.build());
client.timeseries().upsert(upsertTimeseriesList);
curl --request POST \
--url https://{cluster}.cognitedata.com/api/v1/projects/{project}/timeseries \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"items": [
{
"externalId": "<string>",
"name": "<string>",
"legacyName": "<string>",
"isString": false,
"metadata": {},
"unit": "<string>",
"unitExternalId": "<string>",
"assetId": 4503599627370496,
"isStep": false,
"description": "<string>",
"securityCategories": [
123
],
"dataSetId": 4503599627370496
}
]
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{cluster}.cognitedata.com/api/v1/projects/{project}/timeseries",
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' => [
[
'externalId' => '<string>',
'name' => '<string>',
'legacyName' => '<string>',
'isString' => false,
'metadata' => [
],
'unit' => '<string>',
'unitExternalId' => '<string>',
'assetId' => 4503599627370496,
'isStep' => false,
'description' => '<string>',
'securityCategories' => [
123
],
'dataSetId' => 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}/timeseries"
payload := strings.NewReader("{\n \"items\": [\n {\n \"externalId\": \"<string>\",\n \"name\": \"<string>\",\n \"legacyName\": \"<string>\",\n \"isString\": false,\n \"metadata\": {},\n \"unit\": \"<string>\",\n \"unitExternalId\": \"<string>\",\n \"assetId\": 4503599627370496,\n \"isStep\": false,\n \"description\": \"<string>\",\n \"securityCategories\": [\n 123\n ],\n \"dataSetId\": 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}/timeseries")
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 \"externalId\": \"<string>\",\n \"name\": \"<string>\",\n \"legacyName\": \"<string>\",\n \"isString\": false,\n \"metadata\": {},\n \"unit\": \"<string>\",\n \"unitExternalId\": \"<string>\",\n \"assetId\": 4503599627370496,\n \"isStep\": false,\n \"description\": \"<string>\",\n \"securityCategories\": [\n 123\n ],\n \"dataSetId\": 4503599627370496\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>",
"metadata": {},
"unit": "<string>",
"unitExternalId": "<string>",
"assetId": 4503599627370496,
"description": "<string>",
"securityCategories": [
123
],
"dataSetId": 4503599627370496
}
]
}{
"code": 400,
"message": "<string>",
"missingFields": [
{}
]
}{
"error": {
"code": 409,
"message": "<string>",
"duplicated": [
{
"externalId": "my.known.id"
}
]
}
}{
"error": {
"code": 422,
"message": "<string>",
"duplicated": [
{
"id": 4503599627370496
}
]
}
}Required capabilities:
timeSeriesAcl:WRITE
Creates one or more time series.
POST
/
timeseries
JavaScript SDK
const timeseries = [
{ name: 'Pressure sensor', assetId: 123 },
{ name: 'Temprature sensor', description: 'Pump abc', unit: 'C' },
];
const createdTimeseries = await client.timeseries.create(timeseries);from cognite.client.data_classes import TimeSeriesWrite
ts = client.time_series.create(TimeSeriesWrite(name="my_ts", data_set_id=123, external_id="foo"))
List<TimeseriesMetadata> upsertTimeseriesList = List.of(TimeseriesMetadata.newBuilder()
.setExternalId("10")
.setName("test_ts")
.setIsString(false)
.setIsStep(false)
.setDescription("Description")
.setUnit("TestUnits")
.putMetadata("type", "sdk-data-generator")
.putMetadata("sdk-data-generator", "sdk-data-generator")
.build());
client.timeseries().upsert(upsertTimeseriesList);
curl --request POST \
--url https://{cluster}.cognitedata.com/api/v1/projects/{project}/timeseries \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"items": [
{
"externalId": "<string>",
"name": "<string>",
"legacyName": "<string>",
"isString": false,
"metadata": {},
"unit": "<string>",
"unitExternalId": "<string>",
"assetId": 4503599627370496,
"isStep": false,
"description": "<string>",
"securityCategories": [
123
],
"dataSetId": 4503599627370496
}
]
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{cluster}.cognitedata.com/api/v1/projects/{project}/timeseries",
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' => [
[
'externalId' => '<string>',
'name' => '<string>',
'legacyName' => '<string>',
'isString' => false,
'metadata' => [
],
'unit' => '<string>',
'unitExternalId' => '<string>',
'assetId' => 4503599627370496,
'isStep' => false,
'description' => '<string>',
'securityCategories' => [
123
],
'dataSetId' => 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}/timeseries"
payload := strings.NewReader("{\n \"items\": [\n {\n \"externalId\": \"<string>\",\n \"name\": \"<string>\",\n \"legacyName\": \"<string>\",\n \"isString\": false,\n \"metadata\": {},\n \"unit\": \"<string>\",\n \"unitExternalId\": \"<string>\",\n \"assetId\": 4503599627370496,\n \"isStep\": false,\n \"description\": \"<string>\",\n \"securityCategories\": [\n 123\n ],\n \"dataSetId\": 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}/timeseries")
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 \"externalId\": \"<string>\",\n \"name\": \"<string>\",\n \"legacyName\": \"<string>\",\n \"isString\": false,\n \"metadata\": {},\n \"unit\": \"<string>\",\n \"unitExternalId\": \"<string>\",\n \"assetId\": 4503599627370496,\n \"isStep\": false,\n \"description\": \"<string>\",\n \"securityCategories\": [\n 123\n ],\n \"dataSetId\": 4503599627370496\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>",
"metadata": {},
"unit": "<string>",
"unitExternalId": "<string>",
"assetId": 4503599627370496,
"description": "<string>",
"securityCategories": [
123
],
"dataSetId": 4503599627370496
}
]
}{
"code": 400,
"message": "<string>",
"missingFields": [
{}
]
}{
"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.
Body
application/json
Required array length:
1 - 1000 elementsShow child attributes
Show child attributes
Response
Response with the created time series.
List of responses. The order matches the requests order.
Show child attributes
Show child attributes
Last modified on July 10, 2026
Was this page helpful?
⌘I