Configuration

View as MarkdownOpen in Claude

The SignalWire Server SDK uses a layered configuration system. Settings can come from constructor parameters, environment variables, JSON config files, or sensible defaults. The layers are resolved in priority order:

  1. Constructor parameters — highest priority
  2. Environment variables — override config file values
  3. Config file values — loaded from JSON
  4. Defaults — built-in fallback values
import { ConfigLoader } from '@signalwire/sdk';
// Constructor parameters take precedence over everything else
const config = new ConfigLoader('./my_config.json');
const port = config.get<number>('server.port', 3000);

Config File Discovery

When no explicit config file path is provided, the SDK searches for JSON config files using ConfigLoader.search(), which checks these locations in order:

  1. Current working directory
  2. ./config/
  3. ~/.signalwire/

See ConfigLoader for the full file discovery logic and environment variable substitution syntax.

Key Configuration Areas

AreaConfigured ViaReference
Server port, host, routeConstructor, PORT env var, config fileEnvironment Variables
AuthenticationSWML_BASIC_AUTH_* env vars, config fileAuthHandler
CORS and host allowlistsSWML_CORS_ORIGINS, SWML_ALLOWED_HOSTS env varsEnvironment Variables
LoggingSIGNALWIRE_LOG_MODE, SIGNALWIRE_LOG_LEVEL env varsEnvironment Variables
Relay / REST authSIGNALWIRE_PROJECT_ID, SIGNALWIRE_API_TOKEN, SIGNALWIRE_SPACEEnvironment Variables

Quick Example

{
"service": {
"name": "support-agent",
"host": "0.0.0.0",
"port": 8080,
"route": "/support"
},
"security": {
"basic_auth": {
"username": "${AUTH_USER|support_agent}",
"password": "${AUTH_PASSWORD}"
}
},
"agent": {
"auto_answer": true,
"record_call": false
},
"skills": [
{ "name": "datetime" },
{
"name": "native_vector_search",
"params": {
"index_file": "./support_docs.swsearch",
"tool_name": "search_support"
}
}
]
}