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
      • BedrockAgent
      • CLI Tools
      • Configuration
        • AuthHandler
        • ConfigLoader
          • find_config_file
          • get
          • get_config
          • get_config_file
          • get_section
          • has_config
          • merge_with_env
          • substitute_vars
        • Environment Variables
        • SecurityConfig
      • ContextBuilder
      • DataMap
      • FunctionResult
      • Helper Functions
      • LiveWire
      • MCP Gateway
      • PomBuilder
      • Prefabs
      • Search
      • SkillBase
      • Skills
      • SWAIGFunction
      • SWMLBuilder
      • SWMLService
      • WebService
    • RELAY
      • Overview
      • Actions
      • Call
      • Constants
      • Events
      • Message
      • RelayClient
      • RelayError
    • REST Client
      • Overview
      • Addresses
      • Calling
      • Chat
      • Compat
      • Datasphere
      • Fabric
      • Imported Numbers
      • Logs
      • Lookup
      • MFA
      • Number Groups
      • Phone Numbers
      • Project
      • PubSub
      • Queues
      • Recordings
      • Registry
      • RestClient
      • Short Codes
      • SignalWireRestError
      • SIP Profile
      • Verified Callers
      • Video
LogoLogoSignalWire Docs
Log inSign up
Support
On this page
  • Parameters
  • Returns
  • Example
AgentsConfigurationConfigLoader

substitute_vars

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

Environment Variables

Next
Built with

Recursively substitute environment variables in a configuration value. Supports ${VAR} and ${VAR|default} syntax.

Parameters

value
AnyRequired

The value to process. Can be a string, dict, list, or any other type. Strings are scanned for ${VAR|default} patterns. Dicts and lists are processed recursively.

max_depth
intDefaults to 10

Maximum recursion depth to prevent infinite substitution loops.

Returns

Any — The value with all ${VAR|default} patterns replaced by the corresponding environment variable values. Strings that resolve to "true"/"false" are converted to booleans. Numeric strings are converted to int or float.

Example

1import os
2from signalwire.core.config_loader import ConfigLoader
3
4os.environ["API_KEY"] = "secret123"
5loader = ConfigLoader()
6
7# Simple substitution
8result = loader.substitute_vars("${API_KEY}")
9print(result) # "secret123"
10
11# With default value
12result = loader.substitute_vars("${MISSING_VAR|fallback}")
13print(result) # "fallback"
14
15# Nested structure
16config = {
17 "auth": {"token": "${API_KEY}"},
18 "timeout": "${TIMEOUT|30}",
19}
20result = loader.substitute_vars(config)
21print(result) # {"auth": {"token": "secret123"}, "timeout": 30}