Skip to main content
POST
/
sequences
JavaScript SDK
const sequences = [
 {
  externalId: 'sequence_name',
  columns: [
   {
     externalId: 'one',
     valueType: SequenceValueType.LONG,
   },
   {
     externalId: 'two',
   },
   {
     externalId: 'three',
     valueType: SequenceValueType.STRING,
   }
  ]
 }
];
const [sequence] = await client.sequences.create(sequences);
from cognite.client.data_classes import SequenceWrite, SequenceColumnWrite
column_def = [
SequenceColumnWrite(value_type="String", external_id="user", description="some description"),
SequenceColumnWrite(value_type="Double", external_id="amount")
]
seq = client.sequences.create(SequenceWrite(external_id="my_sequence", columns=column_def))

seq2 = client.sequences.create(SequenceWrite(external_id="my_copied_sequence", columns=column_def))
List<SequenceColumn> columns = List.of(SequenceColumn.newBuilder() 
.setExternalId("10")
.setName("test_column_")
.setDescription("Description")
.setValueTypeValue(SequenceColumn.ValueType.STRING_VALUE)
.build());

List<SequenceMetadata> upsertSequencesList = List.of( SequenceMetadata.newBuilder()
.setExternalId("10")
.setName("test_sequence_")
.setDescription("Description")
.putMetadata("type", "sdk-data-generator")
.addAllColumns(columns)
.build());

client.sequences().upsert(upsertSequencesList);
curl --request POST \
--url https://{cluster}.cognitedata.com/api/v1/projects/{project}/sequences \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"items": [
{
"columns": [
{
"externalId": "DPS1",
"name": "depth",
"description": "Optional description",
"valueType": "DOUBLE",
"metadata": {
"extracted-by": "cognite"
}
}
],
"name": "Any relevant name",
"description": "Optional description",
"assetId": 1221123111,
"externalId": "my.known.id",
"metadata": {
"extracted-by": "cognite"
},
"dataSetId": 4503599627370496
}
]
}
'
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://{cluster}.cognitedata.com/api/v1/projects/{project}/sequences",
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' => [
[
'columns' => [
[
'externalId' => 'DPS1',
'name' => 'depth',
'description' => 'Optional description',
'valueType' => 'DOUBLE',
'metadata' => [
'extracted-by' => 'cognite'
]
]
],
'name' => 'Any relevant name',
'description' => 'Optional description',
'assetId' => 1221123111,
'externalId' => 'my.known.id',
'metadata' => [
'extracted-by' => 'cognite'
],
'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}/sequences"

payload := strings.NewReader("{\n \"items\": [\n {\n \"columns\": [\n {\n \"externalId\": \"DPS1\",\n \"name\": \"depth\",\n \"description\": \"Optional description\",\n \"valueType\": \"DOUBLE\",\n \"metadata\": {\n \"extracted-by\": \"cognite\"\n }\n }\n ],\n \"name\": \"Any relevant name\",\n \"description\": \"Optional description\",\n \"assetId\": 1221123111,\n \"externalId\": \"my.known.id\",\n \"metadata\": {\n \"extracted-by\": \"cognite\"\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}/sequences")

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 \"columns\": [\n {\n \"externalId\": \"DPS1\",\n \"name\": \"depth\",\n \"description\": \"Optional description\",\n \"valueType\": \"DOUBLE\",\n \"metadata\": {\n \"extracted-by\": \"cognite\"\n }\n }\n ],\n \"name\": \"Any relevant name\",\n \"description\": \"Optional description\",\n \"assetId\": 1221123111,\n \"externalId\": \"my.known.id\",\n \"metadata\": {\n \"extracted-by\": \"cognite\"\n },\n \"dataSetId\": 4503599627370496\n }\n ]\n}"

response = http.request(request)
puts response.read_body
{
  "items": [
    {
      "id": 1,
      "columns": [
        {
          "valueType": "DOUBLE",
          "createdTime": 100000000000,
          "lastUpdatedTime": 100000000000,
          "name": "depth",
          "externalId": "DPS1",
          "description": "Optional description",
          "metadata": {
            "extracted-by": "cognite"
          }
        }
      ],
      "createdTime": 100000000000,
      "lastUpdatedTime": 100000000000,
      "name": "Any relevant name",
      "description": "Optional description",
      "assetId": 1221123111,
      "externalId": "my.known.id",
      "metadata": {
        "extracted-by": "cognite"
      },
      "dataSetId": 2718281828459
    }
  ]
}
{
"error": {
"code": 401,
"message": "Could not authenticate.",
"missing": [
{}
],
"duplicated": [
{}
]
}
}

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

application/json

Sequence to be stored.

items
object[]
required
Required array length: 1 - 1000 elements

Response

Response with the created sequence.

items
object[]
required
Last modified on July 10, 2026