setSessionMetadata

View as MarkdownOpen in Claude

Merge metadata into a session, creating the entry if it does not exist. Automatically triggers cleanup when the metadata map exceeds 1000 entries.

Parameters

sessionId
stringRequired

The session identifier.

metadata
Record<string, unknown>Required

Key-value pairs to merge into the session metadata.

Returns

void

Example

1import { SessionManager } from '@signalwire/sdk';
2
3const sm = new SessionManager();
4sm.setSessionMetadata('session-1', { caller: 'John' });
5sm.setSessionMetadata('session-1', { topic: 'billing' });
6// Metadata is now { caller: "John", topic: "billing" }