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

mergeWithEnv

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

search

Next
Built with

Merge the loaded configuration with environment variables whose names start with a given prefix. Config file values take precedence over environment variables — env vars only fill in keys that are missing from the config.

Matching env var names are:

  1. Stripped of the prefix
  2. Lowercased
  3. Split on _ to produce a nested object path

For example, with prefix SWML_, SWML_SERVER_PORT=3000 produces { server: { port: "3000" } }.

All values inherited from env vars are written as strings (Node returns process.env values as strings). Apply substituteVars() to the result if you need type coercion.

Parameters

envPrefix
stringDefaults to 'SWML_'

Prefix for environment variables to consider.

Returns

Record<string, unknown> — the merged configuration (file + prefixed env vars) with ${VAR} substitution applied to file values.

Example

1import { ConfigLoader } from '@signalwire/sdk';
2
3// Given config.json: { "server": { "host": "0.0.0.0" } }
4// And env: SWML_SERVER_PORT=3000
5
6const loader = new ConfigLoader('config.json');
7const merged = loader.mergeWithEnv();
8console.log(merged);
9// { server: { host: "0.0.0.0", port: "3000" } }