For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Log inSign up
Support
GuidesReference
GuidesReference
    • Core
      • Overview
    • Agents
      • Overview
      • AgentBase
      • AgentServer
      • Configuration
        • AuthHandler
        • ConfigLoader
        • Environment Variables
        • Logging
        • PromptManager
        • SchemaUtils
        • ServerlessAdapter
        • SessionManager
          • cleanup
          • createSession
          • createToolToken
          • debugToken
          • deleteSessionMetadata
          • generateToken
          • getSessionMetadata
          • setSessionMetadata
          • validateToken
          • validateToolToken
        • SslConfig
      • ContextBuilder
      • DataMap
      • FunctionResult
      • Helper Functions & Utilities
      • LiveWire
      • PomBuilder
      • Prefabs
      • SkillBase
      • SkillManager
      • SkillRegistry
      • Skills
      • SwaigFunction
      • SwmlBuilder
      • SWMLService
    • RELAY
      • Overview
      • Actions
      • Call
      • Constants
      • Events
      • Message
      • RelayClient
      • RelayError
    • REST Client
      • Overview
      • Addresses
      • Calling
      • ChatResource
      • Compat
      • Datasphere
      • Fabric
      • ImportedNumbersResource
      • Logs
      • LookupResource
      • MFA
      • Number Groups
      • Phone Numbers
      • Project
      • PubSubResource
      • Queues
      • Recordings
      • Registry
      • RestClient
      • RestError
      • Short Codes
      • SIP Profile
      • Verified Callers
      • Video
LogoLogoSignalWire Docs
Log inSign up
Support
On this page
  • Parameters
  • Returns
  • Example
AgentsConfigurationSessionManager

setSessionMetadata

|View as Markdown|Open in Claude|
Was this page helpful?
Edit this page
Previous

validateToken

Next
Built with

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

Two call signatures are supported for Python SDK compatibility:

  • Bulk merge (TS-native): setSessionMetadata(sessionId, metadata) — merges every key in the metadata object into the session, returning void.
  • Single key/value (Python-compatible): setSessionMetadata(sessionId, key, value) — sets a single key, returning true for parity with Python.

Both forms merge into any existing metadata; they do not replace.

Parameters

sessionId
stringRequired

The session identifier.

metadataOrKey
Record<string, unknown> | stringRequired

A metadata record to merge into the session (bulk-merge form), or a single string key (three-argument form).

value
unknown

The value to set when metadataOrKey is a string key. Only used by the three-argument form.

Returns

void for the bulk-merge form; boolean (true) for the three-argument, Python-compatible form.

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" }
7
8sm.setSessionMetadata('session-1', 'priority', 'high');
9// Metadata is now { caller: "John", topic: "billing", priority: "high" }