const events = [
{ description: 'Workorder pump abc', startTime: new Date('22 jan 2019') },
{ description: 'Broken rule', externalId: 'rule123', startTime: 1557346524667000 },
];
const createdEvents = await client.events.create(events);from cognite.client.data_classes import EventWrite
events = [EventWrite(start_time=0, end_time=1), EventWrite(start_time=2, end_time=3)]
res = client.events.create(events)List<Event> upsertEventsList = List.of(Event.newBuilder()
.setExternalId("10")
.setStartTime(1552566113)
.setEndTime(1553566113)
.setDescription("generated_event_")
.setType("generated_event")
.setSubtype("event_sub_type")
.setSource("sdk-data-generator")
.putMetadata("type", "sdk-data-generator")
.build());
client.events().upsert(upsertEventsList);curl --request POST \
--url https://{cluster}.cognitedata.com/api/v1/projects/{project}/events \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"items": [
{
"externalId": "my.known.id",
"dataSetId": 4503599627370496,
"startTime": 1730204346000,
"endTime": 1730204346000,
"type": "<string>",
"subtype": "<string>",
"description": "<string>",
"metadata": {},
"assetIds": [
4503599627370496
],
"source": "<string>"
}
]
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{cluster}.cognitedata.com/api/v1/projects/{project}/events",
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' => 'my.known.id',
'dataSetId' => 4503599627370496,
'startTime' => 1730204346000,
'endTime' => 1730204346000,
'type' => '<string>',
'subtype' => '<string>',
'description' => '<string>',
'metadata' => [
],
'assetIds' => [
4503599627370496
],
'source' => '<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}/events"
payload := strings.NewReader("{\n \"items\": [\n {\n \"externalId\": \"my.known.id\",\n \"dataSetId\": 4503599627370496,\n \"startTime\": 1730204346000,\n \"endTime\": 1730204346000,\n \"type\": \"<string>\",\n \"subtype\": \"<string>\",\n \"description\": \"<string>\",\n \"metadata\": {},\n \"assetIds\": [\n 4503599627370496\n ],\n \"source\": \"<string>\"\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}/events")
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\": \"my.known.id\",\n \"dataSetId\": 4503599627370496,\n \"startTime\": 1730204346000,\n \"endTime\": 1730204346000,\n \"type\": \"<string>\",\n \"subtype\": \"<string>\",\n \"description\": \"<string>\",\n \"metadata\": {},\n \"assetIds\": [\n 4503599627370496\n ],\n \"source\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"items": [
{
"id": 4503599627370496,
"lastUpdatedTime": 1730204346000,
"createdTime": 1730204346000,
"externalId": "my.known.id",
"dataSetId": 4503599627370496,
"startTime": 1730204346000,
"endTime": 1730204346000,
"type": "<string>",
"subtype": "<string>",
"description": "<string>",
"metadata": {},
"assetIds": [
4503599627370496
],
"source": "<string>"
}
]
}{
"error": {
"code": 400,
"message": "`null` values aren't allowed."
}
}{
"error": {
"code": 429,
"message": "Project exceeded maximum number='50' of concurrent requests. Please try again later."
}
}Required capabilities:
eventsAcl:WRITE
Creates multiple event objects in the same project. It is possible to post a maximum of 1000 events per request.
Request throttling
This endpoint is a subject of the new throttling schema (limited request rate and concurrency). Please check Events resource description for more information.
const events = [
{ description: 'Workorder pump abc', startTime: new Date('22 jan 2019') },
{ description: 'Broken rule', externalId: 'rule123', startTime: 1557346524667000 },
];
const createdEvents = await client.events.create(events);from cognite.client.data_classes import EventWrite
events = [EventWrite(start_time=0, end_time=1), EventWrite(start_time=2, end_time=3)]
res = client.events.create(events)List<Event> upsertEventsList = List.of(Event.newBuilder()
.setExternalId("10")
.setStartTime(1552566113)
.setEndTime(1553566113)
.setDescription("generated_event_")
.setType("generated_event")
.setSubtype("event_sub_type")
.setSource("sdk-data-generator")
.putMetadata("type", "sdk-data-generator")
.build());
client.events().upsert(upsertEventsList);curl --request POST \
--url https://{cluster}.cognitedata.com/api/v1/projects/{project}/events \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"items": [
{
"externalId": "my.known.id",
"dataSetId": 4503599627370496,
"startTime": 1730204346000,
"endTime": 1730204346000,
"type": "<string>",
"subtype": "<string>",
"description": "<string>",
"metadata": {},
"assetIds": [
4503599627370496
],
"source": "<string>"
}
]
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{cluster}.cognitedata.com/api/v1/projects/{project}/events",
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' => 'my.known.id',
'dataSetId' => 4503599627370496,
'startTime' => 1730204346000,
'endTime' => 1730204346000,
'type' => '<string>',
'subtype' => '<string>',
'description' => '<string>',
'metadata' => [
],
'assetIds' => [
4503599627370496
],
'source' => '<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}/events"
payload := strings.NewReader("{\n \"items\": [\n {\n \"externalId\": \"my.known.id\",\n \"dataSetId\": 4503599627370496,\n \"startTime\": 1730204346000,\n \"endTime\": 1730204346000,\n \"type\": \"<string>\",\n \"subtype\": \"<string>\",\n \"description\": \"<string>\",\n \"metadata\": {},\n \"assetIds\": [\n 4503599627370496\n ],\n \"source\": \"<string>\"\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}/events")
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\": \"my.known.id\",\n \"dataSetId\": 4503599627370496,\n \"startTime\": 1730204346000,\n \"endTime\": 1730204346000,\n \"type\": \"<string>\",\n \"subtype\": \"<string>\",\n \"description\": \"<string>\",\n \"metadata\": {},\n \"assetIds\": [\n 4503599627370496\n ],\n \"source\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"items": [
{
"id": 4503599627370496,
"lastUpdatedTime": 1730204346000,
"createdTime": 1730204346000,
"externalId": "my.known.id",
"dataSetId": 4503599627370496,
"startTime": 1730204346000,
"endTime": 1730204346000,
"type": "<string>",
"subtype": "<string>",
"description": "<string>",
"metadata": {},
"assetIds": [
4503599627370496
],
"source": "<string>"
}
]
}{
"error": {
"code": 400,
"message": "`null` values aren't allowed."
}
}{
"error": {
"code": 429,
"message": "Project exceeded maximum number='50' of concurrent requests. Please try again later."
}
}Authorizations
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
List of events to be posted. It is possible to post a maximum of 1000 events per request.
1 - 1000 elementsShow child attributes
Show child attributes
Response
Paged response with list of events
Show child attributes
Show child attributes
Was this page helpful?