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… | Use | Detail |
|---|---|---|
| Decide routing per call, from your own service | HTTP dynamic routing | Routing → HTTP dynamic routing |
| Drive each call step from your own code | Step IVR | Step IVR Provider |
| React to events (calls, queues, agents) | RWI Webhook | RWI Events & Webhooks |
| Control live calls interactively | RWI WebSocket | RWI Protocol Reference |
| Script call control / query state | REST API | RWI Protocol Reference §3 |
| Add a subsystem (tables, console pages, routes) | Addon trait | Technical Specs §5 |
| Offload recordings/CDRs/flows | Storage backends | Basic 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:
| Operation | Endpoint |
|---|---|
| Active calls | GET /api/calls/active |
| Session detail | GET /api/calls/active/{session_id} |
| Send command | POST /api/calls/active/{session_id}/commands |
| User data | GET / PUT /api/calls/active/{session_id}/userdata |
| Call records | GET /api/call-records |
| Reports | GET /api/reports/v2/{call,trunk,…} |
| Extensions / trunks / routing | PUT /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
| Goal | Compose |
|---|---|
| CRM screen-pop | RWI Webhook (events) + per-key X-* headers + desk popup template |
| Click-to-call | REST originate + RWI events for state |
| AI receptionist | Step IVR (logic) + realtime bridge (conversation) + transcription |
| Fraud control | HTTP routing (decision) + ACL/frequency limits (enforcement) |
| Custom QA | RWI Webhook (transcripts/recordings) + reports API |
Start from the Extensibility blog series for worked examples.