Notion: Retrieve a session
Notion sessions.retrieveSession: arguments, response, policy and SDK examples.
← Sessions operations · Get started
Operation notion.retrieve_session
Provider route: GET /v1/sessions/{session_id}. Alter supplies the connection’s credentials and routing.
Call through Alter
Section titled “Call through Alter”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"]["retrieveSession"]>[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.retrieveSession(input); const result = await call.wait(); return result.bodyJson(); } finally { await app.close(); }}import osfrom alter_sdk import Appfrom 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.retrieve_session(arguments) result = await call.wait() return result.body_json()| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Additional keys: not allowed |
path | object | Required within parent | Additional keys: not allowed |
path.session_id | string | Required within parent | The ID of the session to retrieve. |
Response
Section titled “Response”Response media type: application/json. The table describes the pinned successful response. Referenced models link to their complete fields.
| Field | Type | Presence | Description and constraints |
|---|---|---|---|
$ | object | Root | Additional keys: allowed |
agent_id | string | Required within parent | |
agent_version | JSON | Required within parent | |
agent_version (anyOf 1) | object | Alternative | Additional keys: allowed |
agent_version (anyOf 1).id | string | Required within parent | |
agent_version (anyOf 1).number | JSON | Required within parent | |
agent_version (anyOf 1).number (anyOf 1) | integer | Alternative | Minimum: 1 |
agent_version (anyOf 1).number (anyOf 2) | string | Alternative | Pattern: ^-?[0-9]+(?:.[0-9]+)?(?:[eE][+-]?[0-9]+)?$ |
agent_version (anyOf 1).published_at | string | Required within parent | Format: date-time |
agent_version (anyOf 2) | null | Alternative | |
chat_user_emails | JSON | Optional | |
chat_user_emails (anyOf 1) | array | Alternative | |
chat_user_emails (anyOf 1)[] | string | Each item | |
chat_user_emails (anyOf 2) | null | Alternative | |
created_at | string | Required within parent | Format: date-time |
created_by | object | Required within parent | Additional keys: allowed |
created_by.id | string | Required within parent | |
created_by.type | string | Required within parent | One of: `user`, `bot` Known values: user, bot |
credits_used | JSON | Optional | Premium AI credits this session consumed. Reported with at most two decimal places, rounded down. |
credits_used (anyOf 1) | JSON | Alternative | |
credits_used (anyOf 1) (anyOf 1) | number | Alternative | |
credits_used (anyOf 1) (anyOf 2) | string | Alternative | Pattern: ^-?[0-9]+(?:.[0-9]+)?(?:[eE][+-]?[0-9]+)?$ |
credits_used (anyOf 2) | null | Alternative | |
error | object | Optional | Additional keys: allowed |
error.code | string | Required within parent | |
error.message | string | Required within parent | |
error.retryable | boolean | Required within parent | |
id | string | Required within parent | |
message_count | JSON | Optional | |
message_count (anyOf 1) | JSON | Alternative | |
message_count (anyOf 1) (anyOf 1) | integer | Alternative | Minimum: 0 |
message_count (anyOf 1) (anyOf 2) | string | Alternative | Pattern: ^-?[0-9]+(?:.[0-9]+)?(?:[eE][+-]?[0-9]+)?$ |
message_count (anyOf 2) | null | Alternative | |
models | JSON | Required within parent | |
models (anyOf 1) | object | Alternative | Additional keys: allowed |
models (anyOf 1).type | string | Required within parent | Always `auto` Must equal: auto |
models (anyOf 2) | object | Alternative | Additional keys: allowed |
models (anyOf 2).ids | array | Required within parent | |
models (anyOf 2).ids[] | JSON | Each item | |
models (anyOf 2).ids[] (anyOf 1) | string | Alternative | |
models (anyOf 2).ids[] (anyOf 2) | null | Alternative | |
models (anyOf 2).type | string | Required within parent | Always `pinned` Must equal: pinned |
object | string | Required within parent | Always `session` Must equal: session |
required_actions | array | Optional | |
required_actions[] | object | Each item | Additional keys: allowed |
required_actions[].action_id | string | Required within parent | |
required_actions[].options | array | Required within parent | Maximum items: 100 |
required_actions[].options[] | object | Each item | Additional keys: allowed |
required_actions[].options[].id | string | Required within parent | One of: `approve`, `reject` Known values: approve, reject |
required_actions[].options[].label | string | Required within parent | |
required_actions[].title | string | Required within parent | |
runs_completed | JSON | Optional | |
runs_completed (anyOf 1) | JSON | Alternative | |
runs_completed (anyOf 1) (anyOf 1) | integer | Alternative | Minimum: 0 |
runs_completed (anyOf 1) (anyOf 2) | string | Alternative | Pattern: ^-?[0-9]+(?:.[0-9]+)?(?:[eE][+-]?[0-9]+)?$ |
runs_completed (anyOf 2) | null | Alternative | |
status | string | Required within parent | One of: `queued`, `in_progress`, `requires_action`, `completed`, `failed`, `canceled`, `terminated` Known values: queued, in_progress, requires_action, completed, failed, canceled, terminated |
title | string | Required within parent | |
tool_call_count | JSON | Optional | |
tool_call_count (anyOf 1) | JSON | Alternative | |
tool_call_count (anyOf 1) (anyOf 1) | integer | Alternative | Minimum: 0 |
tool_call_count (anyOf 1) (anyOf 2) | string | Alternative | Pattern: ^-?[0-9]+(?:.[0-9]+)?(?:[eE][+-]?[0-9]+)?$ |
tool_call_count (anyOf 2) | null | Alternative | |
tool_types | JSON | Optional | |
tool_types (anyOf 1) | array | Alternative | |
tool_types (anyOf 1)[] | string | Each item | |
tool_types (anyOf 2) | null | Alternative | |
trigger_type | string | Optional | |
type_labels | JSON | Optional | |
type_labels (anyOf 1) | array | Alternative | |
type_labels (anyOf 1)[] | string | Each item | |
type_labels (anyOf 2) | null | Alternative | |
updated_at | string | Required within parent | Format: date-time |
Policy, approvals and errors
Section titled “Policy, approvals and errors”SDK function policy ID: notion.retrieve_session. Catalog operation: retrieve_session. 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"}