getSessionMetadata

View as MarkdownOpen in Claude

Retrieve metadata associated with a session. Always returns an object — callers can check truthiness or iterate keys without a null guard.

Parameters

sessionId
stringRequired

The session identifier.

Returns

Record<string, unknown> — The metadata record for the session, or an empty object ({}) when no metadata has been stored. This matches the Python SDK’s get_session_metadata behavior.

Example

1import { SessionManager } from '@signalwire/sdk';
2
3const sm = new SessionManager();
4sm.setSessionMetadata('session-1', { caller: 'John', topic: 'billing' });
5
6const meta = sm.getSessionMetadata('session-1');
7console.log(meta); // { caller: "John", topic: "billing" }
8
9const missing = sm.getSessionMetadata('unknown-session');
10console.log(missing); // {}