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
          • findConfigFile
          • get
          • getAll
          • getConfig
          • getConfigFile
          • getFilePath
          • getSection
          • has
          • hasConfig
          • interpolateEnvVars
          • load
          • loadFromObject
          • mergeWithEnv
          • search
          • set
          • substituteVars
        • Environment Variables
        • Logging
        • PromptManager
        • SchemaUtils
        • ServerlessAdapter
        • SessionManager
        • 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
AgentsConfigurationConfigLoader

substituteVars

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

Environment Variables

Next
Built with

Recursively substitute ${VAR|default} environment-variable references in any value. Walks strings, objects, and arrays. After substitution, resulting strings are coerced to:

  • true / false when they equal "true" / "false" (case-insensitive)
  • an integer when they match /^\d+$/
  • a float when they match /^\d+\.\d+$/
  • otherwise left as a string

For raw string interpolation without type coercion, use interpolateEnvVars() instead.

Parameters

value
unknownRequired

The value to process. Can be a string, object, array, or primitive.

maxDepth
numberDefaults to 10

Maximum recursion depth. Throws Error("Maximum variable substitution depth exceeded") when the limit is reached.

Returns

The input value with all environment variables substituted. Type depends on the input and the coercion rules above.

Example

1import { ConfigLoader } from '@signalwire/sdk';
2
3const loader = new ConfigLoader();
4const config = {
5 port: '${PORT|8080}',
6 debug: '${DEBUG|false}',
7 name: '${SERVICE_NAME|my-service}',
8};
9
10const resolved = loader.substituteVars(config);
11console.log(resolved);
12// { port: 8080, debug: false, name: "my-service" } (types coerced)