Extending RustPBX

RustPBX is designed to be programmed, not just configured. This page maps every extension point, helps you choose the right one, and links to the details.

1. Choose Your Extension Point

You need to…UseDetail
Decide routing per call, from your own serviceHTTP dynamic routingRouting → HTTP dynamic routing
Drive each call step from your own codeStep IVRStep IVR Provider
React to events (calls, queues, agents)RWI WebhookRWI Events & Webhooks
Control live calls interactivelyRWI WebSocketRWI Protocol Reference
Script call control / query stateREST APIRWI Protocol Reference §3
Add a subsystem (tables, console pages, routes)Addon traitTechnical Specs §5
Offload recordings/CDRs/flowsStorage backendsBasic Setup → Storage

2. Inbound Decisions: HTTP routing & Step IVR

HTTP dynamic routing asks your service once per INVITE: it returns trunk/reject/busy, and can override the caller identity. fallback_to_static = true keeps calls flowing if your endpoint is down.

Step IVR asks your service once per call step: play, collect, branch, record, hand off. It’s the right tool when the IVR logic lives in your application (CRM lookups, balances, AI decisions).

Both are covered with config in the routing chapter and the Step IVR guide.

3. Outbound Events: RWI Webhook

Every platform event (call lifecycle, queue/ACD, agent state, DTMF, IVR traces, call_error) can be pushed to an HTTP endpoint:

[rwi_webhook]
url = "https://your-server.example.com/api/rwi/events"
events = ["call_hangup", "call_error", "queue_agent_connected"]
retries = 3

Delivery runs on dedicated workers with exponential backoff and a stable idempotency key. Details: RWI Events & Webhooks.

4. Two-Way Control: RWI WebSocket

A single WebSocket gives you commands out and events back on one ordered channel: originate, answer, transfer, hold, play, DTMF, queue operations, conference control, session user data.

Key properties for integrators:

  • Root call identity on every call-scoped event (call_id + session_id)
  • Attribution (src_ip / client_ip) for multi-tenant filtering
  • Owner-routed in clusters — commands reach the call wherever it lives
  • User data replicates and survives transfers

Reference: RWI Protocol Reference.

5. REST API

Every interactive capability has a REST twin for scripting and batch jobs:

OperationEndpoint
Active callsGET /api/calls/active
Session detailGET /api/calls/active/{session_id}
Send commandPOST /api/calls/active/{session_id}/commands
User dataGET / PUT /api/calls/active/{session_id}/userdata
Call recordsGET /api/call-records
ReportsGET /api/reports/v2/{call,trunk,…}
Extensions / trunks / routingPUT /api/extensions, /api/sip-trunk, /api/routing

Authenticate with scoped API tokens ([console] api_tokens); see Users, Roles & Departments.

6. Addons

When extension means new functionality — tables, console pages, API routes, dialplan inspectors, call hooks — implement the Addon trait. Addons participate in:

  • Routing contributions — appear in the unified routing stack
  • Extension lifecycle hooks — on_extension_created / _updated / _deleting
  • Console page/API routes — mounted automatically
  • Error catalog — contribute typed call errors
  • Seed fixtures — for demo/testing data

Community addons: ACME, Archive, Transcript, Queue, Observability. Commercial: Wholesale, Contact Center, IVR Editor, Voicemail, Endpoint Manager, Enterprise Auth, Telemetry.

7. Config & Storage Hooks

  • Config store — generated configs (queues, routes, trunks, ACL, IVR) can live in the database and be exported to files for GitOps
  • Storage backends — one [storage] block feeds recording, CDR archive, SipFlow offload, with presigned URLs
  • TTS/ASR drivers — CLI and HTTP drivers pluggable per deployment

8. Integration Blueprints

GoalCompose
CRM screen-popRWI Webhook (events) + per-key X-* headers + desk popup template
Click-to-callREST originate + RWI events for state
AI receptionistStep IVR (logic) + realtime bridge (conversation) + transcription
Fraud controlHTTP routing (decision) + ACL/frequency limits (enforcement)
Custom QARWI Webhook (transcripts/recordings) + reports API

Start from the Extensibility blog series for worked examples.