Skip to content

Notion: Query session events

Notion sessions.querySessionEvents: arguments, response, policy and SDK examples.

← Sessions operations · Get started

Operation notion.query_session_events

Provider route: POST /v1/sessions/{session_id}/events/query. Alter supplies the connection’s credentials and routing.

Install @alter-ai/sdk @alter-ai/notion with npm, or alter-sdk-notion with pip. Supply your connected customer’s grant ID and the arguments described below.

import { App } from "@alter-ai/sdk";
import { NotionIntegration } from "@alter-ai/notion";
async function execute(input: Parameters<NotionIntegration["sessions"]["querySessionEvents"]>[0]) {
const app = new App({ apiKey: process.env.ALTER_API_KEY! });
try {
const provider = new NotionIntegration(app, { grantId: process.env.PROVIDER_GRANT_ID! });
const call = await provider.sessions.querySessionEvents(input);
const result = await call.wait();
return result.bodyJson();
} finally {
await app.close();
}
}
import os
from alter_sdk import App
from alter_sdk_notion import NotionIntegration
async def execute(arguments):
async with App(api_key=os.environ["ALTER_API_KEY"]) as app:
provider = NotionIntegration(app, {"grant_id": os.environ["PROVIDER_GRANT_ID"]})
call = await provider.sessions.query_session_events(arguments)
result = await call.wait()
return result.body_json()
FieldTypePresenceDescription and constraints
$objectRootAdditional keys: not allowed
pathobjectRequired within parentAdditional keys: not allowed
path.session_idstringRequired within parentThe ID of the session whose events should be queried.
bodyobjectRequired within parentAdditional keys: not allowed
body.filterJSONOptionalA session event property filter, or an and/or compound filter nested up to three levels deep.
body.filter (oneOf 1)objectAlternativeAdditional keys: not allowed
body.filter (oneOf 1).propertystringRequired within parentOne of: id
body.filter (oneOf 1).stringobjectRequired within parentAdditional keys: not allowed
body.filter (oneOf 1).string.equalsstringRequired within parent
body.filter (oneOf 2)ModelAlternativeExpand Query session events — request body — body / filter / property: type
body.filter (oneOf 3)objectAlternativeAdditional keys: not allowed
body.filter (oneOf 3).numberobjectRequired within parentAdditional keys: not allowed
body.filter (oneOf 3).number.greater_thannumberOptional
body.filter (oneOf 3).number.greater_than_or_equal_tonumberOptional
body.filter (oneOf 3).number.less_thannumberOptional
body.filter (oneOf 3).number.less_than_or_equal_tonumberOptional
body.filter (oneOf 3).propertystringRequired within parentOne of: sequence
body.filter (oneOf 4)ModelAlternativeExpand Query session events — request body — body / filter / property: created at
body.filter (oneOf 5)objectAlternativeAdditional keys: not allowed
body.filter (oneOf 5).andarrayRequired within parent
body.filter (oneOf 5).and[]JSONEach item
body.filter (oneOf 5).and[] (oneOf 1)objectAlternativeAdditional keys: not allowed
body.filter (oneOf 5).and[] (oneOf 1).propertystringRequired within parentOne of: id
body.filter (oneOf 5).and[] (oneOf 1).stringobjectRequired within parentAdditional keys: not allowed
body.filter (oneOf 5).and[] (oneOf 1).string.equalsstringRequired within parent
body.filter (oneOf 5).and[] (oneOf 2)ModelAlternativeExpand Query session events — request body — body / filter / property: type
body.filter (oneOf 5).and[] (oneOf 3)objectAlternativeAdditional keys: not allowed
body.filter (oneOf 5).and[] (oneOf 3).numberobjectRequired within parentAdditional keys: not allowed
body.filter (oneOf 5).and[] (oneOf 3).number.greater_thannumberOptional
body.filter (oneOf 5).and[] (oneOf 3).number.greater_than_or_equal_tonumberOptional
body.filter (oneOf 5).and[] (oneOf 3).number.less_thannumberOptional
body.filter (oneOf 5).and[] (oneOf 3).number.less_than_or_equal_tonumberOptional
body.filter (oneOf 5).and[] (oneOf 3).propertystringRequired within parentOne of: sequence
body.filter (oneOf 5).and[] (oneOf 4)ModelAlternativeExpand Query session events — request body — body / filter / property: created at
body.filter (oneOf 5).and[] (oneOf 5)ModelAlternativeExpand Query session events — request body — body filter or or item and
body.filter (oneOf 5).and[] (oneOf 6)ModelAlternativeExpand Query session events — request body — body filter or or item or
body.filter (oneOf 6)objectAlternativeAdditional keys: not allowed
body.filter (oneOf 6).orarrayRequired within parent
body.filter (oneOf 6).or[]JSONEach item
body.filter (oneOf 6).or[] (oneOf 1)objectAlternativeAdditional keys: not allowed
body.filter (oneOf 6).or[] (oneOf 1).propertystringRequired within parentOne of: id
body.filter (oneOf 6).or[] (oneOf 1).stringobjectRequired within parentAdditional keys: not allowed
body.filter (oneOf 6).or[] (oneOf 1).string.equalsstringRequired within parent
body.filter (oneOf 6).or[] (oneOf 2)ModelAlternativeExpand Query session events — request body — body / filter / property: type
body.filter (oneOf 6).or[] (oneOf 3)objectAlternativeAdditional keys: not allowed
body.filter (oneOf 6).or[] (oneOf 3).numberobjectRequired within parentAdditional keys: not allowed
body.filter (oneOf 6).or[] (oneOf 3).number.greater_thannumberOptional
body.filter (oneOf 6).or[] (oneOf 3).number.greater_than_or_equal_tonumberOptional
body.filter (oneOf 6).or[] (oneOf 3).number.less_thannumberOptional
body.filter (oneOf 6).or[] (oneOf 3).number.less_than_or_equal_tonumberOptional
body.filter (oneOf 6).or[] (oneOf 3).propertystringRequired within parentOne of: sequence
body.filter (oneOf 6).or[] (oneOf 4)ModelAlternativeExpand Query session events — request body — body / filter / property: created at
body.filter (oneOf 6).or[] (oneOf 5)ModelAlternativeExpand Query session events — request body — body filter or or item and
body.filter (oneOf 6).or[] (oneOf 6)ModelAlternativeExpand Query session events — request body — body filter or or item or
body.page_sizeintegerOptionalThe number of events to return. Maximum: 100.
Maximum: 100
Minimum: 1
body.sortsarrayOptionalOrdered sort precedence. Defaults to sequence ascending.
Maximum items: 2
Minimum items: 1
body.sorts[]objectEach itemAdditional keys: not allowed
body.sorts[].directionstringRequired within parentOne of: `ascending`, `descending`
One of: ascending, descending
body.sorts[].propertystringRequired within parentOne of: `sequence`, `created_at`
One of: sequence, created_at
body.start_cursorstringOptionalThe continuation cursor returned by the previous page.

Referenced models: Query session events — request body — body filter or or item or, Query session events — request body — body filter or or item and, Query session events — request body — body / filter / property: created at, Query session events — request body — body / filter / property: type

Response media type: application/json. The table describes the pinned successful response. Referenced models link to their complete fields.

FieldTypePresenceDescription and constraints
$objectRootAdditional keys: allowed
has_morebooleanRequired within parent
next_cursorJSONRequired within parent
next_cursor (anyOf 1)stringAlternative
next_cursor (anyOf 2)nullAlternative
objectstringRequired within parentAlways `list`
Must equal: list
resultsarrayRequired within parentMaximum items: 100
results[]JSONEach item
results[] (anyOf 1)objectAlternativeAdditional keys: allowed
results[] (anyOf 1).contentarrayRequired within parent
results[] (anyOf 1).content[]JSONEach item
results[] (anyOf 1).content[] (anyOf 1)objectAlternativeAdditional keys: allowed
results[] (anyOf 1).content[] (anyOf 1).textstringRequired within parent
results[] (anyOf 1).content[] (anyOf 1).typestringRequired within parentAlways `text`
Must equal: text
results[] (anyOf 1).content[] (anyOf 2)objectAlternativeAdditional keys: allowed
results[] (anyOf 1).content[] (anyOf 2).content_typestringRequired within parent
results[] (anyOf 1).content[] (anyOf 2).expiry_timestringOptional
results[] (anyOf 1).content[] (anyOf 2).namestringRequired within parent
results[] (anyOf 1).content[] (anyOf 2).typestringRequired within parentAlways `file`
Must equal: file
results[] (anyOf 1).content[] (anyOf 2).urlstringRequired within parent
results[] (anyOf 1).created_atstringRequired within parent
results[] (anyOf 1).created_byJSONRequired within parent
results[] (anyOf 1).created_by (anyOf 1)objectAlternativeAdditional keys: allowed
results[] (anyOf 1).created_by (anyOf 1).idstringRequired within parent
results[] (anyOf 1).created_by (anyOf 1).typestringRequired within parentOne of: `user`, `bot`
Known values: user, bot
results[] (anyOf 1).created_by (anyOf 2)nullAlternative
results[] (anyOf 1).idstringRequired within parent
results[] (anyOf 1).metadataJSONRequired within parent
results[] (anyOf 1).metadata (anyOf 1)objectAlternativeAdditional keys: see wildcard field
results[] (anyOf 1).metadata (anyOf 1).*stringAdditional keysMaximum length: 2000
results[] (anyOf 1).metadata (anyOf 2)nullAlternative
results[] (anyOf 1).objectstringRequired within parentAlways `session_event`
Must equal: session_event
results[] (anyOf 1).sequenceJSONRequired within parent
results[] (anyOf 1).sequence (anyOf 1)integerAlternativeMinimum: 1
results[] (anyOf 1).sequence (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
results[] (anyOf 1).session_idstringRequired within parent
results[] (anyOf 1).typestringRequired within parentAlways `user.message`
Must equal: user.message
results[] (anyOf 2)objectAlternativeAdditional keys: allowed
results[] (anyOf 2).contentarrayRequired within parent
results[] (anyOf 2).content[]JSONEach item
results[] (anyOf 2).content[] (anyOf 1)objectAlternativeAdditional keys: allowed
results[] (anyOf 2).content[] (anyOf 1).textstringRequired within parent
results[] (anyOf 2).content[] (anyOf 1).typestringRequired within parentAlways `text`
Must equal: text
results[] (anyOf 2).content[] (anyOf 2)objectAlternativeAdditional keys: allowed
results[] (anyOf 2).content[] (anyOf 2).content_typestringRequired within parent
results[] (anyOf 2).content[] (anyOf 2).expiry_timestringOptional
results[] (anyOf 2).content[] (anyOf 2).namestringRequired within parent
results[] (anyOf 2).content[] (anyOf 2).typestringRequired within parentAlways `file`
Must equal: file
results[] (anyOf 2).content[] (anyOf 2).urlstringRequired within parent
results[] (anyOf 2).created_atstringRequired within parent
results[] (anyOf 2).created_byJSONRequired within parent
results[] (anyOf 2).created_by (anyOf 1)objectAlternativeAdditional keys: allowed
results[] (anyOf 2).created_by (anyOf 1).idstringRequired within parent
results[] (anyOf 2).created_by (anyOf 1).typestringRequired within parentOne of: `user`, `bot`
Known values: user, bot
results[] (anyOf 2).created_by (anyOf 2)nullAlternative
results[] (anyOf 2).idstringRequired within parent
results[] (anyOf 2).metadataJSONRequired within parent
results[] (anyOf 2).metadata (anyOf 1)objectAlternativeAdditional keys: allowed
results[] (anyOf 2).metadata (anyOf 1).modelstringRequired within parent
results[] (anyOf 2).metadata (anyOf 2)nullAlternative
results[] (anyOf 2).objectstringRequired within parentAlways `session_event`
Must equal: session_event
results[] (anyOf 2).sequenceJSONRequired within parent
results[] (anyOf 2).sequence (anyOf 1)integerAlternativeMinimum: 1
results[] (anyOf 2).sequence (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
results[] (anyOf 2).session_idstringRequired within parent
results[] (anyOf 2).typestringRequired within parentAlways `agent.message`
Must equal: agent.message
results[] (anyOf 3)objectAlternativeAdditional keys: allowed
results[] (anyOf 3).contentarrayRequired within parent
results[] (anyOf 3).content[]objectEach itemAdditional keys: allowed
results[] (anyOf 3).content[].textstringRequired within parent
results[] (anyOf 3).content[].typestringRequired within parentAlways `text`
Must equal: text
results[] (anyOf 3).created_atstringRequired within parent
results[] (anyOf 3).idstringRequired within parent
results[] (anyOf 3).objectstringRequired within parentAlways `session_event`
Must equal: session_event
results[] (anyOf 3).sequenceJSONRequired within parent
results[] (anyOf 3).sequence (anyOf 1)integerAlternativeMinimum: 1
results[] (anyOf 3).sequence (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
results[] (anyOf 3).session_idstringRequired within parent
results[] (anyOf 3).typestringRequired within parentAlways `agent.thinking`
Must equal: agent.thinking
results[] (anyOf 4)objectAlternativeAdditional keys: allowed
results[] (anyOf 4).created_atstringRequired within parent
results[] (anyOf 4).idstringRequired within parent
results[] (anyOf 4).objectstringRequired within parentAlways `session_event`
Must equal: session_event
results[] (anyOf 4).sequenceJSONRequired within parent
results[] (anyOf 4).sequence (anyOf 1)integerAlternativeMinimum: 1
results[] (anyOf 4).sequence (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
results[] (anyOf 4).session_idstringRequired within parent
results[] (anyOf 4).tool_namestringRequired within parent
results[] (anyOf 4).typestringRequired within parentAlways `agent.tool_use`
Must equal: agent.tool_use
results[] (anyOf 5)objectAlternativeAdditional keys: allowed
results[] (anyOf 5).created_atstringRequired within parent
results[] (anyOf 5).idstringRequired within parent
results[] (anyOf 5).is_errorbooleanRequired within parent
results[] (anyOf 5).objectstringRequired within parentAlways `session_event`
Must equal: session_event
results[] (anyOf 5).sequenceJSONRequired within parent
results[] (anyOf 5).sequence (anyOf 1)integerAlternativeMinimum: 1
results[] (anyOf 5).sequence (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
results[] (anyOf 5).session_idstringRequired within parent
results[] (anyOf 5).tool_namestringRequired within parent
results[] (anyOf 5).tool_use_idstringRequired within parent
results[] (anyOf 5).typestringRequired within parentAlways `agent.tool_result`
Must equal: agent.tool_result
results[] (anyOf 6)objectAlternativeAdditional keys: allowed
results[] (anyOf 6).created_atstringRequired within parent
results[] (anyOf 6).errorobjectOptionalAdditional keys: allowed
results[] (anyOf 6).error.codestringRequired within parent
results[] (anyOf 6).error.messagestringRequired within parent
results[] (anyOf 6).error.retryablebooleanRequired within parent
results[] (anyOf 6).idstringRequired within parent
results[] (anyOf 6).objectstringRequired within parentAlways `session_event`
Must equal: session_event
results[] (anyOf 6).required_actionsarrayOptional
results[] (anyOf 6).required_actions[]objectEach itemAdditional keys: allowed
results[] (anyOf 6).required_actions[].action_idstringRequired within parent
results[] (anyOf 6).required_actions[].optionsarrayRequired within parentMaximum items: 100
results[] (anyOf 6).required_actions[].options[]objectEach itemAdditional keys: allowed
results[] (anyOf 6).required_actions[].options[].idstringRequired within parentOne of: `approve`, `reject`
Known values: approve, reject
results[] (anyOf 6).required_actions[].options[].labelstringRequired within parent
results[] (anyOf 6).required_actions[].titlestringRequired within parent
results[] (anyOf 6).sequenceJSONRequired within parent
results[] (anyOf 6).sequence (anyOf 1)integerAlternativeMinimum: 1
results[] (anyOf 6).sequence (anyOf 2)stringAlternativePattern: ^-?[0-9]+(?:.[0-9]+)?(?:[eE][+-]?[0-9]+)?$
results[] (anyOf 6).session_idstringRequired within parent
results[] (anyOf 6).statusstringRequired within parentOne of: `requires_action`, `completed`, `failed`, `canceled`, `terminated`
Known values: requires_action, completed, failed, canceled, terminated
results[] (anyOf 6).typestringRequired within parentAlways `session.status`
Must equal: session.status
session_eventobjectRequired within parentAdditional keys: allowed
typestringRequired within parentAlways `session_event`
Must equal: session_event
Query session events — request body — body filter or or item or
FieldTypePresenceDescription and constraints
$objectRootAdditional keys: not allowed
orarrayRequired within parent
or[]JSONEach item
or[] (oneOf 1)objectAlternativeAdditional keys: not allowed
or[] (oneOf 1).propertystringRequired within parentOne of: id
or[] (oneOf 1).stringobjectRequired within parentAdditional keys: not allowed
or[] (oneOf 1).string.equalsstringRequired within parent
or[] (oneOf 2)ModelAlternativeExpand Query session events — request body — body / filter / property: type
or[] (oneOf 3)objectAlternativeAdditional keys: not allowed
or[] (oneOf 3).numberobjectRequired within parentAdditional keys: not allowed
or[] (oneOf 3).number.greater_thannumberOptional
or[] (oneOf 3).number.greater_than_or_equal_tonumberOptional
or[] (oneOf 3).number.less_thannumberOptional
or[] (oneOf 3).number.less_than_or_equal_tonumberOptional
or[] (oneOf 3).propertystringRequired within parentOne of: sequence
or[] (oneOf 4)ModelAlternativeExpand Query session events — request body — body / filter / property: created at
or[] (oneOf 5)ModelAlternativeExpand Query session events — request body — body filter or or item or or item and
or[] (oneOf 6)ModelAlternativeExpand Query session events — request body — body filter or or item or or item or

Referenced models: Query session events — request body — body filter or or item or or item and, Query session events — request body — body filter or or item or or item or, Query session events — request body — body / filter / property: created at, Query session events — request body — body / filter / property: type

Query session events — request body — body filter or or item and
FieldTypePresenceDescription and constraints
$objectRootAdditional keys: not allowed
andarrayRequired within parent
and[]JSONEach item
and[] (oneOf 1)objectAlternativeAdditional keys: not allowed
and[] (oneOf 1).propertystringRequired within parentOne of: id
and[] (oneOf 1).stringobjectRequired within parentAdditional keys: not allowed
and[] (oneOf 1).string.equalsstringRequired within parent
and[] (oneOf 2)ModelAlternativeExpand Query session events — request body — body / filter / property: type
and[] (oneOf 3)objectAlternativeAdditional keys: not allowed
and[] (oneOf 3).numberobjectRequired within parentAdditional keys: not allowed
and[] (oneOf 3).number.greater_thannumberOptional
and[] (oneOf 3).number.greater_than_or_equal_tonumberOptional
and[] (oneOf 3).number.less_thannumberOptional
and[] (oneOf 3).number.less_than_or_equal_tonumberOptional
and[] (oneOf 3).propertystringRequired within parentOne of: sequence
and[] (oneOf 4)ModelAlternativeExpand Query session events — request body — body / filter / property: created at
and[] (oneOf 5)ModelAlternativeExpand Query session events — request body — body filter or or item or or item and
and[] (oneOf 6)ModelAlternativeExpand Query session events — request body — body filter or or item or or item or

Referenced models: Query session events — request body — body filter or or item or or item and, Query session events — request body — body filter or or item or or item or, Query session events — request body — body / filter / property: created at, Query session events — request body — body / filter / property: type

Query session events — request body — body / filter / property: created at
FieldTypePresenceDescription and constraints
$objectRootAdditional keys: not allowed
propertystringRequired within parentOne of: created_at
timestampobjectRequired within parentAdditional keys: not allowed
timestamp.afterstringOptionalFormat: date-time
timestamp.beforestringOptionalFormat: date-time
timestamp.equalsstringOptionalFormat: date-time
timestamp.on_or_afterstringOptionalFormat: date-time
timestamp.on_or_beforestringOptionalFormat: date-time
Query session events — request body — body / filter / property: type
FieldTypePresenceDescription and constraints
$objectRootAdditional keys: not allowed
event_typeobjectRequired within parentAdditional keys: not allowed
event_type.equalsstringOptionalOne of: user.message, agent.message, agent.thinking, agent.tool_use, agent.tool_result, session.status
event_type.inarrayOptional
event_type.in[]stringEach itemOne of: user.message, agent.message, agent.thinking, agent.tool_use, agent.tool_result, session.status
propertystringRequired within parentOne of: type
Query session events — request body — body filter or or item or or item and
FieldTypePresenceDescription and constraints
$objectRootAdditional keys: not allowed
andarrayRequired within parent
and[]JSONEach item
and[] (oneOf 1)objectAlternativeAdditional keys: not allowed
and[] (oneOf 1).propertystringRequired within parentOne of: id
and[] (oneOf 1).stringobjectRequired within parentAdditional keys: not allowed
and[] (oneOf 1).string.equalsstringRequired within parent
and[] (oneOf 2)ModelAlternativeExpand Query session events — request body — body / filter / property: type
and[] (oneOf 3)objectAlternativeAdditional keys: not allowed
and[] (oneOf 3).numberobjectRequired within parentAdditional keys: not allowed
and[] (oneOf 3).number.greater_thannumberOptional
and[] (oneOf 3).number.greater_than_or_equal_tonumberOptional
and[] (oneOf 3).number.less_thannumberOptional
and[] (oneOf 3).number.less_than_or_equal_tonumberOptional
and[] (oneOf 3).propertystringRequired within parentOne of: sequence
and[] (oneOf 4)ModelAlternativeExpand Query session events — request body — body / filter / property: created at

Referenced models: Query session events — request body — body / filter / property: created at, Query session events — request body — body / filter / property: type

Query session events — request body — body filter or or item or or item or
FieldTypePresenceDescription and constraints
$objectRootAdditional keys: not allowed
orarrayRequired within parent
or[]JSONEach item
or[] (oneOf 1)objectAlternativeAdditional keys: not allowed
or[] (oneOf 1).propertystringRequired within parentOne of: id
or[] (oneOf 1).stringobjectRequired within parentAdditional keys: not allowed
or[] (oneOf 1).string.equalsstringRequired within parent
or[] (oneOf 2)ModelAlternativeExpand Query session events — request body — body / filter / property: type
or[] (oneOf 3)objectAlternativeAdditional keys: not allowed
or[] (oneOf 3).numberobjectRequired within parentAdditional keys: not allowed
or[] (oneOf 3).number.greater_thannumberOptional
or[] (oneOf 3).number.greater_than_or_equal_tonumberOptional
or[] (oneOf 3).number.less_thannumberOptional
or[] (oneOf 3).number.less_than_or_equal_tonumberOptional
or[] (oneOf 3).propertystringRequired within parentOne of: sequence
or[] (oneOf 4)ModelAlternativeExpand Query session events — request body — body / filter / property: created at

Referenced models: Query session events — request body — body / filter / property: created at, Query session events — request body — body / filter / property: type

SDK function policy ID: notion.query_session_events. Catalog operation: query_session_events. Rules can name either ID; function rules distinguish managed calls and conservatively cover raw calls sharing the route. Existing grant permissions and policy rules apply. wait() returns an immediate result or waits for a required approval; it never approves the request itself. Persist the approval ID to resume after a restart.

Provider errors retain their response; JSON decoding raises ProviderAPIError for provider failures. ManagedOperationError identifies contract/input/retention errors. See error handling and provider-specific behavior. Sensitive input may be refused before approval storage. A decoding error never resubmits a write.

Pinned headers: {"Notion-Version": "2026-03-11"}

Official provider source

Report an issue with this page

Necessary

Required for sign-in, security, authorization, and remembering your choices.

Always active

Analytics

Helps us understand which product and documentation features are useful.

Performance diagnostics

Uses performance tracing and privacy-masked session replay to diagnose problems.

You can change these choices at any time from Cookie settings.