Back to Insights
VoIP Engineering

FreeSWITCH XML Curl: Dynamic Configuration from Your Own API

Telephony Engineering Team
4 min read
FreeSWITCH XML Curl: Dynamic Configuration from Your Own API

mod_xml_curl makes FreeSWITCH request its configuration as XML from an HTTP endpoint at runtime, instead of reading static files. This is the standard way to build multi-tenant or API-driven FreeSWITCH platforms where users, routes, and settings change without editing files or reloading.

What You Can Serve Dynamically

  • directory: users, passwords, domains, and per-user variables for registration and authentication
  • dialplan: routing for each call, generated for that call
  • configuration: module settings such as callcenter queues or sofia gateways
  • languages / phrases: prompts and speech phrases

Each is a binding in xml_curl.conf.xml with a URL and the section it handles.

How a Request Works

When FreeSWITCH needs, for example, a user for a registration, it sends an HTTP POST to your URL with form fields such as section, key_name, key_value, user, domain, and hostname. Your service returns an XML document in FreeSWITCH's format, and FreeSWITCH uses it as if it had read a file. A "not found" response is a small XML document that tells FreeSWITCH there is nothing matching.

<document type="freeswitch/xml">
  <section name="directory">
    <domain name="tenant1.example.com">
      <user id="1001">
        <params>
          <param name="password" value="generated-secret"/>
        </params>
      </user>
    </domain>
  </section>
</document>

Design Guidance

  1. Keep responses fast. FreeSWITCH waits for your server. Slow responses delay calls and registrations, so aim for milliseconds and cache aggressively.
  2. Secure the endpoint. Restrict access to FreeSWITCH servers by network and authentication. This endpoint hands out credentials.
  3. Handle failure deliberately. Decide what happens if the API is down. Many setups keep a minimal local fallback config.
  4. Generate XML safely. Escape values properly. A tenant name containing special characters must not break or inject into the document.
  5. Return only what the request needs. Smaller responses parse faster.
  6. Log request and response IDs to ease debugging.

Alternatives and Complements

  • Static files with automated deployment work for stable, small setups.
  • mod_lua / mod_python dialplans or the Event Socket give procedural control per call (see FreeSWITCH Event Socket guide).
  • Database-backed directory via ODBC suits some architectures.

Many platforms combine xml_curl for directory with ESL or scripts for dial plan logic.

Multi-Tenant Patterns

Dynamic directory plus per-domain variables is the base for hosted PBX platforms (see multi-tenant PBX architecture and white-label VoIP platform architecture).

Scaling Notes

Each registration refresh and call may trigger a request, so load grows with users. Put a cache in front of your database, and consider a SIP proxy to absorb registrations (see FreeSWITCH horizontal scaling with Kamailio).


Building an API-driven FreeSWITCH platform? Our FreeSWITCH development team builds dynamic, multi-tenant configuration layers that scale.

Discussion

0

Join the conversation

Sign in with your preferred account to comment, reply, and keep the discussion useful for other engineers.

Takes a few seconds. No separate password required.

C

Controva LLC

Engineering Team

We build digital empires that scale. Specializing in high-performance web architecture, AI automation, and headless commerce.

Work with us

Share this article