Skip to content

Ingest a batch of sensor events for the authenticated user

POST
/api/v1/sensor/events
curl --request POST \
--url http://localhost:11044/api/v1/sensor/events \
--header 'Content-Type: application/json' \
--header 'X-Embabel-Api-Key: <X-Embabel-Api-Key>' \
--data '{ "events": [ { "kind": "example", "activities": [ "example" ], "app": "example", "confidence": 1, "detail": "example", "focusMode": "example", "locked": true, "media": "example", "stream": "example" } ], "source": "example", "timeZone": "example" }'

A batch from one sensor, for the authenticated user: source (required, 400 when blank) names the sensor and namespaces its context streams; each event’s kind is fact (stored as a memory, {user} replaced by the user’s name, at most 2,000 characters, skipped as duplicate when an active memory has the same text ignoring case) or context (replaces that stream’s previous right-now signal, never stored). Events are accepted or rejected one by one; timeZone, an IANA zone, updates the user’s zone and is ignored when invalid

Media typeapplication/json

A batch of events the sensor app on the user’s machine pushes to POST /sensor/events

object
events
required

The events, each discriminated by its kind (fact or context). Each gets its own receipt

Array
One of:
object
kind
required
string
activities
required
Array<string>
app
string
confidence
number format: double
detail
string
focusMode
string
locked
boolean
media
string
stream
required
string
source
required

Which sensor is talking, e.g. me-app. Must not be blank; context streams are namespaced under it

string
timeZone

IANA zone of the sensor’s machine, e.g. Australia/Sydney. A valid zone becomes the user’s time zone; an invalid one is ignored, and absent leaves the user’s zone as it is

string

Example generated

{
"events": [
{
"kind": "example",
"activities": [
"example"
],
"app": "example",
"confidence": 1,
"detail": "example",
"focusMode": "example",
"locked": true,
"media": "example",
"stream": "example"
}
],
"source": "example",
"timeZone": "example"
}

Per-event receipts with accepted/deduplicated/rejected counts

Media typeapplication/json

What became of a sensor batch: counts by outcome, and a receipt per event

object
duplicates
required

Facts skipped because the same text, ignoring case and surrounding whitespace, is already an active memory in the user’s current context

integer format: int32
observed
required

Context events recorded as what the user is doing now

integer format: int32
receipts
required

One receipt per event, in the order the events were sent. A blank-source 400 carries a single receipt instead

Array<object>

The outcome for one event in a sensor batch

object
detail

For stored, the new proposition’s id; for duplicate, the existing proposition it matched; for rejected, the reason; for observed, the activities and focus recorded, or null when there were none

string
label

A fact’s label as sent, or a context event’s stream. Null when the fact had no label, for a context event rejected for a blank stream, and on the one receipt of a blank-source rejection

string
status
required

stored (a new memory), duplicate (that text is already remembered), observed (a context signal recorded, never persisted) or rejected

string
rejected
required

Events refused. On a blank-source 400 this is every event in the batch

integer format: int32
stored
required

Facts stored as new memories

integer format: int32

Example generated

{
"duplicates": 1,
"observed": 1,
"receipts": [
{
"detail": "example",
"label": "example",
"status": "example"
}
],
"rejected": 1,
"stored": 1
}

Blank source. The body is a batch response that rejects every event, with the reason on its one receipt

Media typeapplication/json

What became of a sensor batch: counts by outcome, and a receipt per event

object
duplicates
required

Facts skipped because the same text, ignoring case and surrounding whitespace, is already an active memory in the user’s current context

integer format: int32
observed
required

Context events recorded as what the user is doing now

integer format: int32
receipts
required

One receipt per event, in the order the events were sent. A blank-source 400 carries a single receipt instead

Array<object>

The outcome for one event in a sensor batch

object
detail

For stored, the new proposition’s id; for duplicate, the existing proposition it matched; for rejected, the reason; for observed, the activities and focus recorded, or null when there were none

string
label

A fact’s label as sent, or a context event’s stream. Null when the fact had no label, for a context event rejected for a blank stream, and on the one receipt of a blank-source rejection

string
status
required

stored (a new memory), duplicate (that text is already remembered), observed (a context signal recorded, never persisted) or rejected

string
rejected
required

Events refused. On a blank-source 400 this is every event in the batch

integer format: int32
stored
required

Facts stored as new memories

integer format: int32

Example generated

{
"duplicates": 1,
"observed": 1,
"receipts": [
{
"detail": "example",
"label": "example",
"status": "example"
}
],
"rejected": 1,
"stored": 1
}