Architecture¶
siphon-pbx is a controller: a Rust service that drives siphon-sip entirely over siphon-sip's remote control plane, with siphon-rtp behind siphon-sip for media and Postgres for persistence. This document is the reference for how the pieces fit and, more importantly, why they fit that way. When the code and this document disagree, one of them is wrong; fix whichever it is in the same change.
Shape¶
browser ──HTTPS / WSS──▶ siphon-pbx (its own container)
├─ control-plane client ──siphon-control.v1 (loopback)──▶ siphon-sip
├─ flow engine: one executor per call, commands out, events in
├─ queue engine: one per queue, shared by the calls waiting in it
├─ services: schedules and overrides, voicemail, CDR + path trace,
│ AI gateway (hosted providers or an OpenAI-compatible local endpoint)
└─ HTTP API + event stream + embedded UI
siphon-sip (stock release image, no script) ──▶ siphon-rtp (media) postgres
optional: pipecat bot (pipecat-siphon) | local GPU voice agent (siphon-voice-agent)
A controller on the control plane¶
siphon-sip offers a remote control plane: a WebSocket protocol through which an application is handed calls and drives them with verbs (answer, play, dial, bridge, transfer, stream to an AI agent) while receiving events (digits, answers, hang-ups). siphon-pbx is such an application, and the control plane is its only interface to siphon-sip. That choice is deliberate:
- Only some calls survive a PBX restart. The control plane keeps a disconnected controller's calls up
for a grace period and hands them back on reconnect (
resync). siphon-pbx re-owns the calls it placed itself and the recording sessions it took, whose state is in the channel's variables. A flow call, a web call included, is ended with a 500: the handover says which call it is and not where its flow had got to, and siphon-pbx keeps no such state. A web call's token is released at that moment. An upgrade therefore drains the old process first (see Rolling upgrades), and a plain restart ends the calls in progress. - What ships is what runs. siphon-sip runs from its stock release image. The PBX exercises exactly the control plane every other controller uses, and every gap it finds is fixed there, for all of them.
- Releases are independent. siphon-pbx is pinned to the protocol, not to a build of siphon-sip.
No scripting¶
siphon-sip is scriptable in Python, which is the right tool for complex carrier deployments where an engineer writes routing logic. A PBX is the opposite case: its administrator configures behaviour through the UI and never sees a script. The PBX deployment therefore contains no script at all: calls and registrations reach siphon-sip's control plane and registrar through configuration alone, and every routing decision is made by siphon-pbx's flow engine.
One exception exists, and it is temporary. siphon-sip 1.9.0 takes INVITEs from configuration
(control.inbound) with no script, but it has no scriptless path for REGISTER. So the telephony stack
mounts a minimal deploy/siphon-sip/pbx_register.py that challenges each REGISTER against the
credential view and saves the binding; it registers no INVITE handler, so calls still reach siphon-pbx
from configuration. The REGISTER handler is the part siphon-sip cannot replace yet: at 1.15.1 a REGISTER
with no script handler is answered 405. The script is deleted when siphon-sip answers REGISTER from
configuration.
Registration state comes over the control plane, not from the script. The control app subscribes
to registration (the bindings siphon-sip's registrar holds, each with the received source it
registered from) and outbound_registration (whether each registering trunk is registered with its
carrier). siphon-sip numbers every event of a class with a per-process seq and stamps its boot
instance_epoch, and two verbs, registrations and outbound_registrations, answer with the whole
state and the seq it is current to. So registration_sync in siphon-pbx-control keeps a node's copy
whole by siphon-sip's own rule: read the whole state on connecting and replace the node's rows with it;
apply an event only when it is the next number, leaving an older one out rather than letting it
overwrite something newer; and on a skipped number or a changed epoch (events lost to a full queue, a
lagging event task or a siphon-sip restart) read the whole state again and apply only what is newer.
Because the control client reconnects on its own without saying so, the whole state is also read again
every five minutes, as a backstop for a loss with no later event to reveal it. A snapshot event is the
AoR's whole state, numbered like any other, and is applied like any other.
Every node keeps its own. Each siphon-pbx node has a siphon-sip, and so a registrar, of its own.
Every binding row names the node whose registrar holds it, keyed by that node and the AoR, and a trunk's
outbound-registration state is kept per trunk and node; a node only ever replaces its own rows, so two
nodes on one database cannot overwrite each other. A read that answers "is this extension registered,
and where" (listing, ringing, and tying an outbound call to the phone that placed it, which decides who
pays for it) counts the rows of every live node (instances::live_nodes) and nothing else: a node that
stops beating stops counting at once, and what it wrote is swept once the registry forgets it. Calls and
their legs record the node that wrote them too.
Trunk health comes from siphon-sip's OPTIONS probes. GET /api/v1/trunks/health (an organisation
member, no-store) reads siphon-sip's GET /admin/gateways and answers one entry per trunk of the acting
organisation: {trunk_id, state, up, total, checks_missed, failure_threshold}, wrapped as a reading
(configured, unavailable with its reason, value) so an admin API that is not configured or does not
answer is said, never shown as a state. state is healthy (a destination answers), down (destinations
built, none answers), no_address (served as a carrier but siphon-sip has no destination for it, which is
a host that does not resolve) or not_served (inbound only, never probed). Only groups named by the
organisation's own trunk ids are read. It is this node's view: every node probes on its own.
The same script answers SUBSCRIBE, for the same reason and with the same split. A subscription is a SIP
dialog, which siphon-sip holds (proxy.subscribe_state), while who may watch what and what a
notification says belong to siphon-pbx, where the organisations and the mailboxes are. So the script
authenticates the subscriber against the resource's own SIP domain, asks siphon-pbx over the http
extension, and turns the answer into a SIP response and a NOTIFY; nothing in the script knows what an
event package's body looks like, and it keeps no subscriptions of its own. Two packages are served.
message-summary (RFC 3842) is the message-waiting light on a desk phone, whose body siphon-pbx renders
from the mailbox that extension owns. Which light a mailbox drives is not stored anywhere: it is the
extension the mailbox belongs to, because the body names that account and no other mailbox's counts could
truthfully appear in it — a second column saying which light to drive could only disagree. So a phone may
watch its own extension and nothing else, a mailbox a team shares lights nothing, and an extension whose
mailbox was taken away is refused rather than given a subscription whose count would never change.
That hop runs in both directions, over the same http extension and the same shared token. The script
reports each accepted subscription — the dialog id siphon-sip handed out, and the extension it watches —
to siphon-pbx, which keeps the index, because subscribe_state gives a script no way to ask which
dialogs it holds and because that index has to survive a restart. When a mailbox's messages change (one
left, one played back, one deleted), siphon-pbx renders the new summary and pushes it to a route the
script serves on loopback; the script performs the NOTIFY on that dialog. A push for a dialog siphon-sip
no longer holds is answered 404 and the index entry is dropped, which is how a siphon-sip restart
settles by itself: its dialogs went with it, the phones re-subscribe, and every accepted SUBSCRIBE —
refresh included — carries the current summary.
dialog (RFC 4235) is the busy lamp: a phone watches another extension and is told whether it is idle,
ringing or in a call. It differs from message-waiting in the two places that matter. Who may watch
whom cannot be "its own extension", because watching somebody else is the whole point — so the rule is
that the subscriber and the extension it asks for are both extensions of the one organisation the realm
resolves to, and that is the boundary between two organisations sharing a deployment. Within an
organisation any extension may watch any other, since a lamp key is provisioned per phone and the phone
already decides what it shows. Where the state comes from is the control plane, not this side's own
call state: siphon-pbx sees one outcome for a whole forked dial and so cannot say which member of a ring
group is ringing, which answered and which was cancelled, while siphon-sip watches each leg's own dialog
and reports it (control.apps[].events: [dialog], from siphon-sip 1.12.0). A lamp derived from a dial's
outcome would be right for a single extension and wrong for every ring group.
Two consequences of serving it are worth knowing. Subscribing to that event class makes siphon-sip add its own Record-Route to a relayed or forked INVITE involving a registered address-of-record, which is how the BYE comes back to it — a change to what leaves the box, allowed by RFC 3261 section 16.6 step 4, and the reason the class is rendered only because this release consumes it. And the index of who watches what is held in memory rather than in the database, because everything in it is derived from subscribe dialogs siphon-sip itself loses on restart; a table would persist an index to state that cannot persist. The cost is that a siphon-pbx restart leaves a lamp stale until each phone's next refresh, which is why a dialog subscription is granted minutes where a message-waiting one is granted an hour.
What a lamp shows today is calls coming in, not calls going out, and that is a measured limitation
rather than a design choice. A call to an extension is attributed to it by the {aor} target the
dial resolved from, which is siphon-pbx's own and always right. A call the extension places is
attributed by siphon-sip matching the INVITE against a live binding of the address in its From — and
because that match compares a whole socket address, the source port included, it only succeeds while
a phone happens to reuse one port for its REGISTER and its INVITEs. On a deployment with no script
challenging an INVITE, as this one has none, that comparison is the only arm of the match left. Measured
end to end: the incoming direction reports trying, early, confirmed and terminated; the outgoing
direction reports nothing, and nothing logs. The end-to-end suite pins it the other way round, so the day
it starts working the suite says so. Written up for upstream.
Every other package is answered 489 Bad Event, with Allow-Events naming the two that are served.
Configuration and credentials¶
- siphon-pbx renders siphon-sip's configuration from its own database onto a volume the siphon-sip
container mounts, so an operator never edits a siphon YAML file. Settings that need siphon-sip to
restart (listeners, TLS) are applied as an explicit, announced restart; everything else is applied at
runtime.
siphon-pbx init-telephonywrites it once as the stack starts, from the stack's secrets and the address phones reach the machine at. - What an administrator changes is not in that file. siphon-sip polls siphon-pbx over the loopback hop the two share for the carriers a call may be placed out through and for the trunks it registers to, and reconciles what it holds against each answer, so a trunk added, edited, disabled or deleted in the UI is followed without re-rendering anything and without restarting siphon-sip, which would drop every phone's registration. The answer is the complete desired state and never a delta, and a siphon-pbx that cannot read its trunks refuses the request rather than answering with none: an empty answer means "de-register everything". Nothing of a trunk is written into the rendered file, and that is load-bearing rather than tidy, because siphon-sip's reconcile owns only the entries it created and would leave an address of record named in the file alone.
- Both of those routes are internal: outside the tenant API, authenticated by the shared token the
REGISTER script already uses, and refusing any request that carries a browser
Origin. The trunk one hands over a password in the clear, which is what an outbound registration needs and what keeps the sealing in siphon-pbx, so it is served only on the address siphon-sip reaches siphon-pbx on, its answer is never cached, and neither the answer nor a password in it is ever logged. - A trunk may have an outbound proxy (
proxy, a SIP URI such assip:sbc.example.com:5060;transport=udp,sips:meaning TLS), for a carrier whose registrar domain has no DNS record and whose requests must reach its SBC. The trunk's host stays the registrar and address-of-record domain: a REGISTER's Request-URI is the registrar, its To and From are the address of record, and a call out's Request-URI issip:<number>@<domain>, while the datagram goes to the proxy. It is served to siphon-sip as the registrant row's and the gateway row'sproxykey (left out when a trunk has none), and a call placed through the control plane puts it in the dial'snext_hopwith the Request-URI still on the domain. It is validated on write (asip:orsips:URI with a host, an optional port and atransportofudp,tcportls; no user part, no other parameter) and stored normalised. siphon-sip resolves the proxy host by A/AAAA only, never SRV, so the port is written into what it is served when the URI has none (5060, or 5061 for TLS) while the stored URI is kept as given; give a port when the carrier's is not the default. Two trunks on one domain with different proxies are two groups and two registrations, never merged (siphon-sip fails over between them), but two that share a username as well as a domain share an address of record, which siphon-sip keys its registrations on, so give each of them its own account. - A trunk may register under a number of its own (
registration_user, the console's "Registration number"): the user part of the address of record, for a carrier that wantssip:<number>@<registrar>in the To and From of the REGISTER while the accountusernameis used only in the DigestAuthorization. It is one function,registration_aor, that forms the address (the number when set, else the username), so the registrant row'saor, the by-address lookup siphon-sip uses to de-register a registration it holds but no longer serves, and the match of a reported registration state back to its trunk cannot disagree. The row'susernamestays the account's. It is a SIP user part, validated on write and by a CHECK constraint. The address of record is what siphon-sip keys registrations on, so two trunks on one domain with the same effective user collide, as two with one username always did (nothing prevents it). Changing the number moves the credential to another address of record, so it needs the secrets authority a change of host does. The number is also served as the registrant row'scontact_user, the user part of the REGISTER's Contact (siphon-sip keeps its own address, transport and token), so a call the carrier sends to that Contact arrives for the number and resolves to the flow that owns it (flows::live_for_number, which matches with or without a leading+). A trunk without a number leaves the key out and the Contact is the username's. - siphon-sip reads secrets only literally or from its environment, so the control token and the engine secret are in that file. It is readable by root alone, on a volume only siphon-sip mounts.
- SIP credentials live in siphon-pbx's Postgres. siphon-sip reads them for REGISTER through a
database view exposing only digest HA1 values (MD5 and SHA-256), so phones keep registering while
siphon-pbx restarts, and nobody who can read the view can register as a phone. Plaintext SIP
passwords are shown once when generated and never stored. Where siphon-sip reaches that database is
postgres:5432/siphon_pbxunlessSIPHON_PBX_SIP_CREDENTIALS_DATABASEnames anotherhost:port/database(a replica, or a database server outside the compose stack); the role and password stay the stack's own. - siphon-sip caches each credential lookup for five minutes, and siphon-pbx flushes it. A digest that
fails against a cached hash makes siphon-sip re-read the view once, so a reset password works at once; a
digest that still matches a cached hash is never re-read, so the old password of a reset or deleted
extension would keep registering until the entry ran out. Every write that changes what the view returns
(issuing, resetting or revoking a credential, deleting an extension, changing or giving an organisation
its SIP domain, deleting an organisation) records which credentials it changed in
credential_changes, in its own transaction, under a generation that commits in order. Each node keeps its own place in that sequence and asks its own siphon-sip (POST /admin/auth/cache/invalidate, on its loopback) to drop what changed: at once for a write it took, within five seconds for one another node took. A flush that fails leaves the place where it was and is sent again; a node that has never flushed, or that fell behind changes old enough to be pruned (a day), drops the whole cache. The five minutes only bound a flush that never arrives: a node without the admin API, a write by an older release during a rolling upgrade, or a row changed by hand. - Secrets siphon-pbx must read back (a trunk's password, an authenticator app's secret) are sealed with AES-256-GCM under a master key that lives in a file on the secrets volume, readable by siphon-pbx alone, never in the database. The table, column and row a value is stored in are its additional data, so a sealed value moved to another row does not open, and a database dump alone opens nothing. Losing the key makes them unrecoverable, so it is backed up with the database.
Several nodes on one database: which node registers each trunk¶
Every node has its own siphon-sip, and siphon-sip registers to whatever trunks its siphon-pbx serves it. So
with several nodes on one database each registering trunk is owned by one node, and a node serves its
own siphon-sip only what it owns (trunk_ownership in siphon-pbx-core); otherwise the carrier would hold a
contact per node for one account and fork calls between them.
- A lease on the trunk's row.
owner_nodeholds the trunk untilowner_expires_at(30 seconds) by the database's clock, renewed on every 10-second beat of that node. Only processes that serve a siphon-sip take part (instances.registers_trunks); a process without one would take a share and register none of it. - One beat at a time. Each beat is one transaction under a transaction-level advisory lock, so two nodes
can never both claim a trunk. It finishes handoffs, renews its own leases, claims the free trunks pinned
to it and then free trunks up to an even share (
ceil(trunks / nodes)), and starts at most one handoff toward itself: a trunk pinned to it that another node holds, or, when it holds fewer thanfloor(trunks / nodes)and nothing is free, one of the busiest node's. A trunk is free when nobody owns it, its lease ran out, or its owner is no longer a member, so a node that stops cleanly hands its trunks over at the next beat of another, and one that dies within a lease. - Make before break. A trunk moves by handoff: both nodes serve it from the start, ownership changes only once the new node's own siphon-sip has reported it registered (a report from after the handoff began), and only then does the old node let go and its siphon-sip clear its own contact. A handoff not confirmed within two leases is given up and the trunk stays put.
- A node whose siphon-pbx dies does not take the trunk back. Each row of
/internal/registrantscarrieshold_secs(siphon-sip 1.21.0): what is left on this node's claim to the trunk, lessHOLD_MARGIN(5 seconds), never below zero, by the database's clock. For a trunk this node owns the claim is its lease; for one being handed to it, the time left before the handoff is given up (two leases from its start) but never more than a lease, because past that nobody believes it is this node's, and a handoff that completes after the last read leaves the node a lease, not the rest of the window. A siphon-sip that cannot read the list stops registering the trunk once that long has passed since its last good read, sending nothing (noExpires: 0, since it cannot know who holds the binding now), so it stops before another node can have taken the trunk. A single node serves the same hold from the same lease. The lookup's row carries none: it answers for a trunk siphon-sip no longer serves. - A pin (
preferred_node, a node id, set per trunk) sends a trunk to that node whenever it runs. A pin to a node that is not running leaves the trunk to the others rather than unregistered. /internal/registrantsanswers only this node's trunks, and the URL siphon-sip is rendered with names its node (?node=<id>); a poll naming another node is refused409, so a siphon-sip that reached the wrong siphon-pbx keeps what it holds. The default node's URL names none, so a single-node deployment's rendered file, and so its siphon-sip, are untouched by the upgrade. Until a node's first beat has run it answers503, never an empty list, which would de-register every trunk on every upgrade. The first beat runs before the HTTP listener opens./internal/registrants/lookup?aor=answers any one trunk, from any node, for siphon-sip'sregistrant.http.lookup_url(...lookup?aor={aor}, no?node=). It is rendered only with the registrar store, the one case siphon-sip records a binding to clear: a node killed outright and restarted sends anExpires: 0for each binding no live entry of it owns (a trunk whose lease moved meanwhile), and the lookup is where it gets the credential to answer the carrier's challenge, since none is stored. The records keep siphon-sip's defaultregistrant_key_prefix, shared by the nodes, because its check that another node has not registered the contact since reads every node's records./internal/gatewaysanswers every carrier on every node, each with its own credential. It used to name the outbound registration a destination borrows its credential from (registers), but siphon-sip looks that registration up in its own process, and on a node that does not register the trunk there is none to find.- Telling siphon-sip. A node asks its own siphon-sip to re-read both answers whenever a beat changed
what it serves or any trunk changed (a count and the latest
updated_at, so an edit on another node reaches this one within a beat), and a trunk saved through this node wakes a beat at once. A node never asks another node's siphon-sip anything. - Known limits. A node that loses the database but keeps running keeps its siphon-sip registered until its
hold_secshas passed (about the time the lease has left), and a node that is stopped cleanly rather than killed hands its trunks over at once, inside that window. A node that dies cannot clear what it registered; the carrier holds that contact until it lapses. And a node that lets a trunk go does not clear its contact at a carrier that challenges the de-REGISTER either: siphon-sip (v1.15.1) sends it fire-and-forget without credentials, so such a carrier answers401and keeps the old contact until it expires, beside the new node's. That is siphon-sip's to fix, anddeploy/e2e/cluster.shshows it. A release older than this one, running beside it during an upgrade, serves every trunk as it always did. Every node needs the same master key, since a trunk's password is sealed under it.
Several nodes on one database: ringing a phone registered on another node¶
A registrar is a node's own: a phone that registered on node B is reachable through node B's siphon-sip
alone, over the connection it registered on, and an {aor} dial on node A resolves only against A's
registrar. So when a ring on node A reaches an extension whose phone is registered on node B, A sends that
leg to B's siphon-sip and B's controller rings the phone (cluster in siphon-pbx-control).
- Where each phone is. A ring reads every live binding of the extension with the node that holds it
(
registrations::bindings_by_node). A binding on this node is an{aor}target as before; one on another live node is a{uri}target sent over TCP to that node's cluster address on 5060 (sip:<aor>;x-siphon-node=<node>, withtothe AoR), carrying a signedX-Siphon-Clusterheader, this node's cluster address as its Contact host, and a carrier's media profile toward the other engine. Ring groups, queue offers and diverts take the same path, so a ring group with members on both nodes is one parallel dial: the first to answer wins and the rest are CANCELled, the remote ones by that node. - The hop header is signed.
v1;from=<node>;kind=ext;aor=<aor>;ts=<unix>;n=<nonce>;mac=<hex>, the MAC HMAC-SHA256 under a key derived with HKDF from the master key every node already shares (labelsiphon-pbx cluster hop). A node acts on one only when all of these hold: the INVITE came from insideSIPHON_PBX_CLUSTER_NETWORK, the MAC verifies, the timestamp is within 60 seconds of its own clock, the nonce has not been acted on before, the sender is not itself, and the sender is a live member. Anything else is dropped without an answer and counted assiphon_pbx_calls_ended_total{outcome="cluster_hop_refused"}. A call carrying the header is never routed any other way.kind=extandkind=trunk(below) are acted on; any other kind is refused like a malformed header. - The receiving node runs no flow. It rings the one AoR the signature covers, with a connecting dial
under the phone profile, showing the phone the caller exactly as the calling node presented it, and relays
the outcome as the hop's final response (
486busy,480no answer, otherwise the phone's own code). It never resolves the extension again, so a hop is never forwarded to a third node or back. It writes no call record of its own: the calling node owns the call, and the receiving node appends its leg to that record, found by the hop's Call-ID, with its own node id on the row. - Media goes through both engines: the caller's engine anchors the caller, plain RTP crosses to the other node's engine, which anchors the phone.
- Listener and abuse controls. When SIP binds a single address that is not the cluster address, the
rendered siphon-sip configuration gets an extra
listen.tcpon<cluster address>:5060; a wildcard bind already covers it. The cluster networks joinsecurity.trusted_cidrs, since a node never presents a digest and so could never clear a score. A node with neither configured renders the file it always did. - Known limits. In-call features of a phone rung through another node land on that node's controller,
which holds no flow for the call: a transfer that phone asks for is refused (
603 Transfer Not Available), and a pickup is served only by the node that placed the ring (a phone registered on another node finds nothing ringing to pick up). A transfer to an extension registered only on another node is not carried out either (refused480). Every node needs the same master key, a cluster address (SIPHON_PBX_CLUSTER_ADDRESS) and the cluster network (SIPHON_PBX_CLUSTER_NETWORK).
Several nodes on one database: a call out from the node that registers the trunk¶
Some carriers accept a call only from the address that registered the account. With several nodes, only the
trunk's owner registered it, so a call out placed on any other node reaches such a carrier from an address it
never saw register and is refused. A trunk set to outbound_via_owner (a registering trunk only; off by
default) has its calls out leave from its owner instead.
- The calling node decides per leg (
trunk_ownership::decide_call_out, read in the trunk's route). Flag off, or this node the owner: the leg is the ordinary one. Owned by another live member with a cluster address: the leg keeps the carrier's Request-URI, identity and headers, goes over TCP to the owner's cluster address on 5060 with this node's cluster address as its Contact host, faces the other engine with plain RTP under its own per-target profile, and carries a signed hop. No owner now, or an owner that stopped beating or records no cluster address: the leg is skipped and the hunt moves on to the next trunk, since sending it from here is a call the carrier refuses. - The hop signs the call, not only the trunk.
v1;from=<node>;kind=trunk;org=<organisation>;trunk=<trunk>;num=<number>;as=<presented>;priv=<0|1>;ts=…;n=…;mac=…. The number in the form the carrier is to be sent it, the number the caller is presented as (empty for none of ours) and whether the caller withheld it are the calling flow's decisions, and nothing on the path can rewrite them. It is checked exactly as akind=exthop is (source, MAC, age, nonce, sender, membership). - The owner places that one leg and nothing else. It honours the hop only while it owns the trunk now,
by its lease, and only when the trunk is one of the organisation the hop names; otherwise it answers
503at once (so the calling node's hunt moves on rather than waiting out the INVITE) and counts it ascluster_hop_refused. Honoured, it builds the leg with the sameoutbound_lega call out placed there uses, from its own route to the carrier and the signed decisions, so the carrier sees what it would have seen had the call started there; a diverted call's history headers ride along. It dials through its own siphon-sip, relays the carrier's final response (its own code,486for busy,480for no answer), and appends its leg to the calling node's record. A hop is never passed on. - Media: caller → the calling node's engine → plain RTP → the owner's engine → carrier.
- Known limits. A transfer out through such a trunk is not sent to the owner: siphon-sip's
accept_refertakes no Contact host for the leg it dials, which a leg to another node needs, so that trunk is skipped for a transfer and the flow's next trunk is tried.
Several nodes on one database: a voice bot asking the node that does not hold its session¶
Voice sessions live in the process whose call they serve. With several nodes behind one name (DNS
round-robin, nothing in front choosing a node per call), a bot fetching its brief
(/voice/sessions/{token}) or posting its report (/voice/sessions/{token}/report) reaches whichever node
the name resolved to. So the request is handed to the node that holds the session.
- The token says where. A node with a cluster address mints tokens as
<32 hex>.<node id>(VoiceSessions::mint). A node without one mints bare hex as before, and a bare token (one minted before this, during a rolling upgrade) is served by whichever node holds it and is never forwarded. - Forwarded once. A node that does not hold the session, given a token naming another node, reads the
live membership and sends the request unchanged (path, body,
Authorization) to that node's cluster address on the HTTP port, addingx-siphon-pbx-forwarded: <its own node id>. A request already carrying that header is never forwarded again, so two nodes that disagree about where a session is answer404instead of passing it between them. Only200(brief) and204(report) are relayed; anything else, including a node that cannot be reached within 5 s, is the usual404. - Who is trusted with what. The owning node authenticates a forwarded request exactly as a direct one:
the session's own bot's secret, or the runtime token for a bot this deployment runs. A forward therefore
grants nothing a direct request would not, and the forwarded header can only cause a refusal, so it
carries no signature. The other direction is what needs care, since a forward carries the bot's
credential (and a hosted bot's brief carries its providers' keys back) over plain HTTP: a node forwards
only to a live member's registered cluster address that lies inside
SIPHON_PBX_CLUSTER_NETWORK, the network the signed SIP hops already cross. Every node needs the same HTTP port. - The listener. When the HTTP server binds a single address that is not the cluster address (the
host-network shape binds
SIPHON_PBX_TELEPHONY_ADDRESS), a second listener at<cluster address>:<HTTP port>serves the two session routes and nothing else (cluster_router)./internal/*and the rest of the application are not served there. A wildcard bind already covers it.
Live calls: an organisation's view of the calls that are up, and ending one¶
GET /api/v1/calls/live lists the organisation's calls that are up now: the caller, the dialled number, the
flow and its version, the block the call is in, who it is ringing or connected to, its direction and its start.
POST /api/v1/calls/live/{id}/hang-up ends one ({id} is the SIP Call-ID). Both belong to the calls section;
a member sees and may end only the calls on their own extensions (placed from, ringing or connected to one),
unless a permission group grants them calls. A call that is not theirs is 404, as one that is not up is.
- The actors' own snapshots. Each call's actor registers itself in the node's
LiveCallRegistrywhen its flow starts and publishes a snapshot into awatchchannel it alone writes each time something changes; the registry holds only the receiving halves and the actor's mailbox of end requests. Dropping the actor's guard removes the entry, so every way out of the actor leaves the registry empty (a steady-state leak test holds that). No lock is held over a call's state. - Ending goes through the actor. The request reaches the actor's mailbox and is answered only once the actor
has asked siphon-sip to hang up with a
Reasonheader (Q.850;cause=16), which makes siphon-sip send a BYE to every leg of an answered call (the caller's carries the Reason; the far leg's does not) or a final response to an unanswered one. A hang-up siphon-sip refuses leaves the call and its flow as they were (502); one that finds the call already gone is410. Once it went through the flow is told as if the caller had left, the call's record says it was ended by this PBX and its path ends withended by <name>, and the audit log getscall.ended. - Every node's calls. Calls of one organisation may be on several nodes. The node asked lists its own
registry and asks every other live member at its cluster address (
GET /cluster/calls/live?tenant=), and sends an end request to the node the call is on (POST /cluster/calls/live/end). These carry no credential the receiving node can check, so each is signed:X-Siphon-Cluster-Request: v1;from;ts;n;mac, an HMAC-SHA256 over those fields, the method, the request target and the body's digest, under a key derived from the master key with its own HKDF label, valid for 60 s either way. A node that is a member but does not answer is named inunreachable_nodesrather than silently missing. Only a live member inside the cluster network is ever sent anything.
Several nodes on one database: one set of certificates for every node's proxy¶
Each node runs its own Caddy, and by default each keeps its certificates, keys, ACME account and issuance
locks on its own caddy-data volume. Behind DNS round-robin that breaks on-demand issuance: the node a
browser reaches orders a certificate, the authority checks the name over port 80 or 443 and may reach a
different node, which has no record of the challenge, and every node orders its own certificate for every
name, which runs into the authority's rate limits.
- One shared store.
SIPHON_PBX_CADDY_STORAGE_DSNset, Caddy keeps that state in Postgres through caddy-siphon'scaddy.storage.postgresqlmodule (caddy-siphon0.3.0 and later): a certificate is issued once and served by every node, a challenge is answered by whichever node the authority reaches, and a lock row (expiring by the database's clock) keeps two nodes from ordering the same certificate. - The render says which storage, never how to reach it. The compose layer hands the connection string
to Caddy alone, as
CADDY_STORAGE_DSN, and gives init-proxy and siphon-pbx onlySIPHON_PBX_CADDY_STORAGE=postgresql, derived from the same variable (${...:+postgresql}), so the two cannot disagree and the processes that render never hold the password. The render adds one global option,storage postgresql { dsn "{env.CADDY_STORAGE_DSN}" }, and nothing else; unset, the render is the default byte for byte.{env.*}is resolved when Caddy provisions the storage, so the password is never in the rendered file or in theautosave.jsonCaddy writes (a{$*}placeholder would be substituted at adapt time and land there). - Give Caddy its own role and schema. A role that owns only a
caddyschema, reached with?sslmode=verify-full&search_path=caddy, keeps Caddy's two tables (caddy_objects,caddy_locks) out of siphon-pbx's schema and keeps a Caddy that is compromised away from siphon-pbx's data. It may be the same server as siphon-pbx's database or another one. Caddy refuses to start when it cannot reach it. - What is not shared. The address rules are per node as before (each node's write loads its own
proxy). An issuer of Caddy's own (
SIPHON_PBX_CERTIFICATE_ISSUER=internal) keeps its root in the shared store too, so every node issues from one authority.
siphon-sip's registrar on Redis or Valkey¶
By default siphon-sip keeps its registrar in memory, so a restart of siphon-sip drops every binding until
each phone registers again. A deployment whose nodes are meant to be replaceable can give siphon-sip a Redis
or Valkey outside the node instead (docker-compose.redis.yml). siphon-pbx renders it into siphon-sip's
configuration and never connects to it.
- Settings.
SIPHON_PBX_REDIS_URL(redis.url) is one of the four forms siphon-sip reads:redis://,rediss://(TLS),redis+sentinel://h1,h2/master/dborrediss+sentinel://.- Secrets are files:
SIPHON_PBX_REDIS_PASSWORD_FILE,SIPHON_PBX_REDIS_SENTINEL_PASSWORD_FILE, andSIPHON_PBX_REDIS_CA_FILEfor a private CA. - The URL is refused if it carries credentials, a
ca_fileor asentinel_password, so no secret is ever written into a configuration. init-telephonypercent-encodes the passwords into the URL in siphon-sip's own file, which is written0600on a volume only siphon-sip mounts. It renders a literal and not a${VAR}, because an unset variable would expand to nothing and siphon-sip would connect unauthenticated.- The CA is copied beside that file under a name of its content, so a rotated CA changes the file and siphon-sip is restarted onto it.
- Unset renders exactly the file of an in-memory registrar.
- Each node keeps its own keys (
siphon:reg:<node id>:,siphon:presence:<node id>:), andread_through_ttl_msis 0, so lookups read the node's own memory. - With one shared keyspace, siphon-sip 1.16 would have every node restore, look up and report every
other node's phones. Each phone would be counted once per node in
registrations, and a node would ring a phone over a connection it does not hold. - With the per-node keyspace, a phone stays held by the node it registered with. The previous section (ringing a phone registered on another node) works unchanged.
- The store buys restart durability, and only for the node id that wrote it: a replacement node keeps
the bindings only if it takes over the same
SIPHON_PBX_NODE_ID. - What a restart restores, and what it cannot.
- A phone that registered over UDP is reachable again as soon as siphon-sip has restored its binding.
- A phone that registered over TCP or TLS, which is every phone behind the TLS proxy, is restored with the id of a connection that died with the old process. It reads as registered and cannot be rung until it registers again.
- siphon-sip drops restored bindings without their security association for IPsec, and nothing yet does the same for a dead connection. That is siphon-sip's to fix.
- A server that is down when siphon-sip starts. siphon-sip logs
failed to connect to Redis registrar backendonce and runs with an in-memory registrar and no write-through for the life of the process. It does not retry, and its readiness does not change, so that node has no durability until its siphon-sip is restarted with the server reachable.
Logs and call detail records for a log shipper¶
One variable, SIPHON_PBX_LOG_FORMAT, chooses how the engines write their log: pretty (the default, and
what unset or blank mean) or json, one object per line with no colour codes. Any other value stops the
start with an error naming it, because a typo that fell back to pretty would be found when the shipper's
parser failed.
| Process | What json does |
Where it is applied |
|---|---|---|
| siphon-pbx | a JSON fmt layer on stdout: timestamp, level, target, fields (the message is fields.message), span and spans |
the process, at start |
| siphon-sip | log.format: json in the rendered siphon.yaml; pretty renders no log block, so the file of a deployment that never set the knob is byte for byte what it was |
init-telephony; applied on a restart, which apply-telephony does |
| siphon-rtp | nothing: it has no JSON option at the pinned version (1.0.0). Its init_tracing installs the plain fmt subscriber and takes no flag, config key or variable for the format. Its lines stay text until that is added upstream |
The console's log view is unchanged either way: siphon-pbx's in-memory ring is a separate layer that sees
the same events, and siphon-sip's retained log is read over its admin API, which does not depend on its
console format. Of the other containers, only siphon-pbx's own image is covered: the voice runtime writes
asctime level name message text, Postgres and Prometheus write their own text, and Caddy keeps its default.
The one-shots (init-*, apply-telephony, the apply commands) print plain lines to stdout and stderr and are
not log streams.
Call detail records come from siphon-sip's own cdr block, enabled by the layer
deploy/docker-compose.cdr.yml (without it no block is rendered and no record is written):
SIPHON_PBX_CDR_DIR, an absolute host directory, mounted into siphon-sip at the same path. siphon-sip appends one JSON object per line to<dir>/cdr.jsonl.SIPHON_PBX_CDR_ROTATE_SIZE_MB(default 100, siphon-sip's own): the file is renamed tocdr.jsonl.<UTC timestamp>at that size, and siphon-sip never deletes a rotated file, so retention is the shipper's or logrotate's.0turns rotation off.SIPHON_PBX_CDR_HTTP_URLadds a second sink that POSTs every record to a collector, andSIPHON_PBX_CDR_HTTP_TOKEN_FILEnames a file holding its bearer token. The sinks are independent in siphon-sip (each has its own channel), so a collector that is down does not cost the file copy a record. A collector URL or token file without a directory, an unreadable or empty token file and a rotation size that is no number all stop init-telephony rather than being skipped.
The token cannot be kept out of the rendered file: siphon-sip's auth_header takes a literal or an
environment expansion and nothing that reads a file. The least-bad choice is the literal, written into
siphon.yaml, which init-telephony writes readable by its owner alone on a volume only siphon-sip mounts,
exactly where the control token and the engine secret already are. The alternative, an environment variable
on siphon-sip, would put it in docker inspect and in every process's environment. It is never in a compose
file, an environment variable of any service or a command line.
auto_emit is on, so every call siphon-sip takes through the control plane writes a record (answered, failed,
cancelled and refused calls alike), and no script has to. REGISTER events are not recorded. The fields of a
call's record, from siphon-sip's Cdr (v1.17.0): timestamp, call_id, from_uri, to_uri, ruri,
method, response_code, timestamp_start, timestamp_answer, timestamp_end, duration_secs (answer to
end, 0 if unanswered), source_ip, destination_ip, transport, user_agent, auth_user,
disconnect_initiator (caller, callee, timeout, error) and sip_reason, plus rf_session_id and
rf_result_code when Rf accounting is on (it is not here). A refused call adds refusal_scope,
refusal_reason and, for a gateway group, gateway_group. When the media engine reports a call's summary a
second record with method: MEDIA is written under the same call_id, carrying media_reason,
media_duration_ms and per-leg near_* / far_* fields (tag, codec, addresses, payload type). Filter on
method to count calls.
The join with siphon-pbx's call history is the SIP Call-ID. A record's call_id is the Call-ID of the INVITE
siphon-sip received, and that is what the call history keeps as sip_call_id (GET /calls?call_id= takes it).
siphon-pbx's own row id is not in the record, and nothing needs it: a Call-ID names one call. A leg siphon-pbx
places itself (a ring, a transfer, a call back) is its own dialog under a Call-ID siphon-sip generated, with
its own record, and the call history lists it under the call as a leg with that Call-ID.
The telephony stack¶
siphon-sip, siphon-rtp and siphon-pbx share one network namespace and reach each other on loopback:
the control plane on port 9092, the engine on 8081, siphon-pbx's HEP collector on 9060. That is forced
rather than chosen. siphon-sip reads the engine's address and its HEP endpoint as an IP and a port,
siphon-rtp reads its HEP collector the same way, and no committed file may name a real address. The
control listener and the engine therefore never face a network: the stack publishes SIP, siphon-pbx's
UI and the HEP port, and nothing else. The engine's image has no shell to run a health check with, so
siphon-pbx probe waits for all three to answer before the stack counts as up.
The namespace is held by a pause container that does nothing else, not by any of the three. A container that joins another's namespace comes back into it when it restarts, but the container that owns a namespace comes back with a new one and strands whatever had joined it. When the namespace was siphon-sip's, one siphon-sip crash left the engine unreachable until it was restarted by hand. The pause container has nothing to crash for, so each of the three restarts on its own and rejoins; the stack test restarts siphon-sip the way a crash would and checks that.
In an IMS core¶
siphon-pbx can be an application server on an IMS core's Service Control interface (ISC), for an organisation whose phones, mobile and desk alike, are IMS subscribers. The IMS registers and authenticates them; siphon-pbx registers nothing for them and holds no credential of theirs. The S-CSCF's filter criteria hand each user's originating and terminating INVITEs to the PBX, and the PBX runs the organisation's flows for them as a routing B2BUA (TS 24.229 §5.7.5).
- Trust is the S-CSCF's address.
isc.trusted_sources(SIPHON_PBX_ISC_TRUSTED_SOURCES, addresses or networks) names the S-CSCFs. A call from one of them that carries aP-Served-Userwith a session case is read as handed over. The header is believed from nowhere else: from any other source it is ignored and the call is routed as any call from that source would be. The same sources are exempt from siphon-sip's abuse controls, for the reason a carrier is. - IMS lines. An operator binds an extension to an IMS public identity (
ims_lines, migration 0053,PUT /api/v1/operator/organisations/{id}/ims-lines/{extension}), and gives the organisation its IMS domain. An identity, and the E.164 number read off it, belong to one extension on the whole deployment, because the served user is what decides whose flow runs. Binding is the operator's alone for the same reason. Provisioning the subscriber is the home subscriber server's; the PBX only references it. - Registration state. The IMS line's phones register to the S-CSCF, not here. With a REGISTER
criterion naming the PBX in the user's profile, the S-CSCF reports every registration, re-registration and
de-registration with a third-party REGISTER (TS 24.229 §5.4.1.7): From the S-CSCF, To the public
identity, the granted
Expires, and the user's own REGISTER as a message/sip body. siphon-sip's REGISTER script tells it from a phone's by From differing from To with no credentials (RFC 3261 §10.2), never challenges it, never binds it, and hands it to/internal/ims-registrations, which trusts it by the S-CSCF's address as a call is. Each device is the body's+sip.instance(else its Contact), a desk phone when its private identity is the line's desk identity, with the access type of itsP-Access-Network-Info(never the cell).Expires: 0ends every device of the line; a device whose refresh never comes reads as expired at its expiry (ims_registrations, migration 0058). The organisation's Extensions page andGET /api/v1/operator/organisations/{id}/ims-registrationsshow it, read-only. The S-CSCF sends no third-party REGISTER when one device of several leaves (§5.4.1.7: the identity stays registered), so such a device shows until its own expiry. - Terminating. The served user's extension is being called. The call enters the flow published for the user's own number (their MSISDN is their DDI), or else rings the extension.
- Originating. The served user is calling. The dialled number is read as a desk phone's is: a feature code, a number a flow claims, a colleague's extension, a colleague's own number (another IMS line of the organisation, in E.164 or written through its dialling plan, rung as the extension would be), and otherwise the organisation's outbound flow. An organisation with no outbound flow has no policy to apply, so the call goes back unchanged.
- Conference factory. A handset merging a three-way call (TS 24.605) sends an INVITE to the network's
conference factory URI, which the originating filter criteria may hand to the PBX like any other
originating call. The organisation's conference factory URI (
PUT .../conference-factory-uri,tenants.conference_factory_uri, migration 0117) names it: an originating INVITE whose Request-URI matches it is continued to the S-CSCF unchanged, exactly as the no-outbound-flow path continues a call (same Route, same asserted identity and charging vector), whatever the organisation's flows say, because a Request-URI rewritten into a dialled number no longer names the factory and the REFERs that follow to the focus are refused. It matches on scheme, user and host: URI parameters, headers and the port are ignored, the scheme and host without case, the user with it (RFC 3261 §19.1.4). With none set, nothing changes. The focus URI the core answers with is the core's to hand out and is not known here, so only the factory is configured; the setting is named for the conference so that a PBX that hosts the conference itself can take a mode beside it. - Legs back into the IMS. Ringing an extension with an IMS line rings its public identity, sent
through the S-CSCF with the S-CSCF's own Route entry (its original dialog identifier included), so the
S-CSCF continues the session where it left off and forks to every device registered for the identity.
The way back is every Route entry after the PBX's own leading ones, an entry being the PBX's when its
host is
isc.sip_address(SIPHON_PBX_SIP_ADDRESS, required with S-CSCF sources). That reads both an S-CSCF that puts the AS on top (TS 24.229 §5.4.3.2 step 5) and one that reaches it by next hop with only its own entry. A call out leaves the same way, assip:<number>@<IMS domain>;user=phone, with the outbound flow's caller-ID policy asserted; the S-CSCF and its BGCF own the breakout, so the dial-out block's trunks are not used. Each leg asserts the caller the S-CSCF asserted (or, going out, the company number) and keeps the session'sP-Charging-Vector. - Responses back to the S-CSCF. With S-CSCF sources set, siphon-sip is rendered with a header policy
of its own,
ims-application-server@1:sip-trunk-edge@2026withP-Asserted-Identity,P-Charging-Vector,P-Charging-Function-Addresses,P-Early-MediaandP-Access-Network-Infopassed on responses, so the core keeps the answering party, the terminating IOI and the early-media authorisation. Requests are stripped as before. It is the default for every leg, sincedialtakes no policy, so on such a deployment a phone registered directly at the PBX gets those headers from a carrier's responses too. - Media. A ring that reaches only IMS lines is not anchored while the caller waits: both ends are IMS endpoints on one core, and the SDP goes end to end. A caller the flow has answered (a prompt, a mailbox) is anchored, and an IMS line is then bridged under the trunk profile.
- A served user nobody has bound.
isc.unknown_served_user(SIPHON_PBX_ISC_UNKNOWN_SERVED_USER):reject(the default) refuses it404and leaves the S-CSCF's default handling to decide;continuesends it back to the S-CSCF unchanged with the control plane'sroute, and the PBX lets go of it. - Desk phones. A desk phone is an IMS subscriber too, registering the user's public identity through
the organisation's internet-facing P-CSCF (
PUT .../ims-pcscf) over TLS, with a private identity of its own (desk_impion the IMS line). Left out, the desk IMPI is the one the S-CSCF derives from the IMPU for a REGISTER with no Authorization (TS 24.229 §5.4.1.2.1: the IMPU without its scheme, port and parameters), which is the only one a Linphone phone can register as, since it sends no Authorization in its first REGISTER. A Linphone link is refused for any other desk IMPI, and the console says why. The link renders identity the IMPU, digestuseridthe desk IMPI, realm the IMS domain, outbound proxy the P-CSCF. It carries no credential, because the subscriber's digest is the home subscriber server's; the phone asks for the password on the first challenge. - Message waiting. An IMS phone's
message-summarySUBSCRIBE, handed over by the S-CSCF, is accepted without a digest when siphon-pbx confirms the source is an S-CSCF and the resource is the served user's own identity; the NOTIFYs follow the subscription dialog back through the S-CSCF. -
When siphon-pbx is away. siphon-sip answers a handed-over INVITE
503at once when no controller is connected, so the S-CSCF's default handling (SESSION_CONTINUED) reaches the user directly. Releases before siphon-sip 1.14.0 never answered it. -
Diverting to an outside number. On a call an S-CSCF handed over, a divert to a number outside leaves as an IMS leg too, never through a trunk: the number as
sip:<number>@<IMS domain>;user=phonethrough the S-CSCF's Route, the caller the core asserted, the session's charging vector, and the diversion as the served user's application server (TS 24.604):History-Infowith the cause (302 unconditional, 486 busy, 408 no answer) andDiversionwith the served user as the diverting party. It applies to the extension's forward always, busy and no answer, to the feature codes that set them and to a flow's Divert block alike, and it needs no trunk, so an organisation that is IMS only can forward to a mobile. The divert leaves through the IMS when the diverting extension has an IMS line (or the flow diverts for the served user, with no extension in play); a colleague's extension with no IMS line still leaves by the flow's trunks, and a divert to a colleague is rung as it always was. -
Call forwarding over XCAP (TS 24.623). An IMS front-end (an application server's Ut interface, in front of the handsets) reads and writes the line's
simservsdocument on a listener of its own,SIPHON_PBX_XCAP_LISTEN, which every node serves and which is never the web listener (no host-site resolution, noX-Forwarded-For, no UI). It serves/simservs.ngn.etsi.org/users/<XUI>/simservs.xml, whole or by node selector (/~~/), and nothing else (thexcap-capsandglobaltrees are 404; deleting the whole document is 405). A request is checked in this order: the connected address is inSIPHON_PBX_XCAP_TRUSTED_SOURCES(403), there is noOriginheader (403), oneAuthorization: Bearercarries the token ofSIPHON_PBX_XCAP_TOKEN_FILE(401), exactly oneX-3GPP-Asserted-Identityparses as a comma-separated list of quoted SIP and tel URIs (403), and the XUI is one of those identities and the identities bound to an IMS line name exactly one line (403 for none, or for two). That line alone gives the organisation and the extension: a handset without an ISIM has a temporary public identity as its XUI, bound to no line, and the set the front-end asserts carries the one that is.X-3GPP-Intended-Identityis never read. The document is rendered from the extension's forward columns (seesimservs::store); a write the PBX cannot keep exactly as written is a 409 withapplication/xcap-error+xmland aphrasesaying why, and every write is logged (organisation, extension, change) with no audit row, as a feature code's is not. Strong ETags are honoured withIf-MatchandIf-None-Match(412, 304); bodies are limited to 64 KiB.
The listener can also speak TLS (SIPHON_PBX_XCAP_TLS_CERT_FILE and SIPHON_PBX_XCAP_TLS_KEY_FILE) and
require a client certificate chaining to a configured authority (SIPHON_PBX_XCAP_TLS_CLIENT_CA_FILE, mutual
TLS). Handshakes run on tasks of their own with a deadline, so a stalled client holds up nobody, and the checks
above are not relaxed by it: the source network and the token still decide every request, with the peer address
the TCP connection came from. A certificate says who connected, not that they may assert an identity.
What the front-end has to do, for this to be safe: authenticate the handset (GBA or an equivalent) and terminate
TLS itself; strip every 3GPP identity header the client sent and add exactly one X-3GPP-Asserted-Identity
carrying the whole implicit registration set; send the bearer token and no Origin; forward the method, path,
query, body and conditional headers unchanged; connect only from the agreed addresses, over a protected network;
and pass the statuses through unchanged, retrying no 409 or 412 and caching nothing.
- Recording and transcription. A flow's Record and Transcribe steps work on a call an S-CSCF handed
over, terminating (the flow claims the served user's number) and originating (the served user dials a
number a flow claims). The Record step answers the call, so it is anchored on the media engine and the
S-CSCF sees one 200 carrying the engine's SDP. Ringing an IMS line from there bridges the pair under the
trunk profile; the recording carries on as a second part and the copy for the transcriber is asked for
again, so the stored transcript holds both parties.
deploy/e2e/ims.shproves it in both directions with audio from both ends. A call that is rung through the IMS and never answered by a flow stays unanchored, so there is nothing of it to record until a step answers it.
Not served on ISC yet: an extension with an IMS line is rung through the IMS only on a call an S-CSCF
handed over (a call in over a trunk rings its phones registered here, and a forward from it to an outside
number leaves by a trunk, there being no S-CSCF route to send it back through), and transfers, queues,
presence and a voice bot's transfer are not wired for IMS lines (a bot answering a handed-over call is, and
ims.sh runs one). It needs siphon-sip with a route set on a dial and a route target.
With Microsoft Teams¶
siphon-pbx can be a Microsoft Teams Direct Routing SBC for several organisations at once, so an extension can belong to a Teams user, and calls go both ways. Transfers through Teams do not yet.
- One SBC, a derived trunk per organisation. The deployment has one SBC FQDN, the base
(
SIPHON_PBX_TEAMS_SBC_FQDN), which is the carrier trunk Microsoft probes with OPTIONS. An operator gives each organisation a subdomain label (tenants.teams_label, migration 0066), unique across the deployment, and that organisation is the derived trunk<label>.<base>in its own Teams tenant. Microsoft finds the customer tenant by the FQDN in the Contact of the SBC's INVITE, never by number, so that FQDN is also what places a call from Teams in an organisation. The label is the operator's because it has to be in DNS and in the certificate, neither of which an organisation controls. - Teams lines. An organisation's own administrator binds an extension to the E.164 number of a Teams
user (
teams_lines, migration 0066). The number is unique within the organisation, not across the deployment: the organisation is already known from the FQDN, so a number only has to say which of its extensions a Teams user is. That is why the administrator may bind it, where an IMS identity is the operator's. - A listener of its own. siphon-sip is rendered with a second TLS listener on
SIPHON_PBX_TEAMS_PORT(default 5068, the carrier trunk's-SIPSignalingPort), advertising<base>:<port>(siphon-sip takes a port inadvertisefrom 1.15.0). It is published directly bydocker-compose.teams.yml, not through the TLS proxy: the proxy's certificates are the wrong ones and its PROXY hop would hide Microsoft's address. It takes no PROXY header. The proxied listener phones reach is unchanged. - The certificate. One certificate for
<base>and*.<base>, both named: a wildcard covers exactly one label, so it does not cover the base the OPTIONS use. It is served by SNI for those names and is also siphon-sip's default certificate, so a Microsoft proxy that sends no server name still gets it. The only other client of the default is the TLS proxy's hop, which does not verify what it is shown. It is also presented as siphon-sip's client certificate when Microsoft asks for one. That client certificate is global in siphon-sip, so a TLS trunk that asked for one would be shown it too. siphon-sip reloads it when the files are replaced. A Let's Encrypt certificate works in practice and is not one Microsoft lists as supported. - Microsoft's addresses.
52.112.0.0/14,52.120.0.0/14and2603:1063:400::/40by default (SIPHON_PBX_TEAMS_SIGNALLING_NETWORKS), exempt from the abuse controls for the reason a carrier is: Microsoft never presents a digest, so it could never clear a score. - Microsoft's proxies.
sip,sip2andsip3.pstnhub.microsoft.com:5061are served to siphon-sip over the internal gateway route as theteamsgroup, in that order, over TLS, and probed with OPTIONS once a minute from<base>. - Media. Toward Teams, SDES-SRTP with the caller answered in its own transport (
teams, orphone_to_teamsfor one of our phones behind NAT, whose half takes the source hint); from Teams out through a plain trunk, the carrier offered plain RTP and Teams answered in SRTP (teams_to_trunk); from Teams out through an SRTP trunk,teams. A Teams user ringing a desk phone gets the ordinaryphoneprofile, as a carrier's call does: that hints the Teams half too, with the proxy's address, where Teams' media really leaves its media processors, but its gate issymmetric, so the hint only moves where the relay aims until Teams' first packet arrives. No ICE, no DTLS, no media bypass. - A call from Teams. One of Microsoft's sources and a Request-URI host of
<label>.<base>for a label an organisation holds; both are required, because the host alone is the sender's to write. The Teams user's number (P-Asserted-Identity, elseFrom) has to be bound in that organisation, and then the call is that extension's, read in the order a desk phone's is: a feature code, a number a flow claims, an extension, the outbound flow. An unknown label or an unbound number is refused404and never reaches the outbound flow, which is the toll gate. The caller's origin isElsewhere. Every Contact it is shown names the derived trunk:contact_hostonanswer,caller_contact_hoston everydial(siphon-sip 1.15.0). - A call to Teams. An extension bound to a Teams user rings Teams and only Teams:
sip:+E164@<proxy>;user=phone, sent to the proxy over TLS with the SBC certificate as the client certificate, the derived trunk in the Contact, the caller inFromandP-Asserted-Identityat that host, under the Teams profile named on that target alone (siphon-sip 1.15.1's per-targetprofile). - Failover without ringing anyone twice. A ring of one Teams user alone is a sequential
dialdownsip,sip2andsip3, each target withreroute_after_progress: false: a proxy that never rang the user (no connection, a failure before any101-199, a503withRetry-After) moves the dial on, and one that rang them ends it on whatever comes next, a busy or the ring timeout included, so nobody is rung again through the next proxy after they did not pick up. A proxy that accepts the INVITE and then says nothing costs a whole ring timeout before the next is tried. A ring of several people at once takes the first proxy for each Teams user in it: it is a paralleldial, and a parallel dial cannot nest a hunt inside one of its targets.sip.pstnhub.microsoft.comroutes to Microsoft's nearest healthy region, so that is still failover, only Microsoft's. All three proxies stay the probedteamsgateway group. - Early offer. A ring after a prompt, a queue's offer and a divert after one are bridging dials, whose
legs go out with no SDP by default; Direct Routing takes no INVITE without one, so every Teams target of
such a dial carries
offer: "early"and the engine offers the caller's media under the Teams profile. A connecting dial's legs already carry the caller's offer. Desk phones on a bridging dial are offered early too, under the phone profile: a delayed offer set a phone up twice (answered alone in its own first codec, then re-INVITEd onto the caller's), and a G722-first phone's packets from before that re-INVITE reached a PCMA-only carrier, which then played the caller nothing. A caller whose media relays to another party since an earlier bridge cannot be offered early (caller_relaying); the ring fails, takes its unavailable port, and says why in an error. - A queue offers a Teams-bound agent the caller in Teams, through the same target selection and media profile as a ring, and counts such an agent as reachable although no phone of theirs is registered here (Teams presence is not read; a busy Teams user declines and is rested like a busy phone).
- A ring reaches Teams and phones at once. Each Teams target names its own media profile beside the dial's phone profile, so a ring group, or a ring-all queue tier, of Teams users and phones is one dial that rings both.
- What Teams is trusted by. The source networks, and nothing else: siphon-sip's
verify_clientis one setting for every TLS listener, so Microsoft's client certificate cannot be required on the Teams listener alone without requiring one of every phone behind the TLS proxy. Asked of siphon-sip as a per-listener setting. - Microsoft's certificates are verified once the deployment names what they chain to.
SIPHON_PBX_TEAMS_SERVER_CAis a PEM bundle, rendered as siphon-sip'stls.server_ca; set, every Teams target and every Teams gateway destination carriesverify_server: true, so the dial and the OPTIONS probe both check the chain against that bundle and the proxy's host as a SIP domain, exactly (RFC 5922 §7, no wildcards; Microsoft's certificate namessip,sip2andsip3.pstnhub.microsoft.comoutright). The bundle replaces siphon-sip's bundled roots, but only the Teams legs and probes are verified, so nothing else is checked against it. It is not on by default because those bundled roots will not do: on 2026-10-20 Microsoft's proxies chained toDigiCert Global Root CA, which the Mozilla set siphon-sip 1.15.1 bundles no longer carries, so a default of verification would refuse every call. The bundle has to hold whatever root Microsoft's chain ends at when it is deployed, and be updated if Microsoft moves to another. Unset, the connection is encrypted and not authenticated, as before, and siphon-pbx says so once at start. - Known limits.
- Transfers: a REFER from a Teams leg is declined
603at once. - Pickup from Teams: a Teams user may dial the organisation's feature codes, but a Pick up block reached
from a call that came in from Teams takes its
failedport and asks no ringing call, for the same reason a transfer is declined. The other way works: a call ringing a Teams-bound extension is in the pickup registry under that extension, and one of the organisation's phones picking it up stops the Teams ring with the rest of the dial and takes the caller, as it would from a desk phone. - An Extension status block reads a Teams-bound extension as unavailable: it has no phone registered here, and Teams presence is not read.
- A call an S-CSCF handed over does not ring Teams: an extension with an IMS line rings it, and one without rings its registered phone.
- A divert to a Teams-bound extension carries no
History-InfoorDiversionheader: which of the two Microsoft reads from an SBC is to be settled on a trial tenant. - A call placed through the API to an extension (
POST /api/v1/callswith anextensiondestination) rings that extension's registered phones and never Teams, so for a Teams-bound extension, which has none, it ends unanswered with480. Ringing Teams there needs the placed leg to carry the Teams profile, proxy and Contact host, and the call out dialled onto it to be answered back in SRTP; the placed-call path takes none of them yet.
Who does what. The console carries each part to whoever holds it, with the values filled in.
- The operator, once per deployment: the DNS for
<base>and the certificate naming both<base>and*.<base>; and, in the carrier's own Microsoft 365 tenant, the carrier trunk, once:New-CSOnlinePSTNGateway -FQDN <base> -SIPSignalingPort <port> -ForwardPAI $true. The deployment as an SBC isGET /api/v1/operator/teams(enabled,sbc_fqdn,port). - The operator, per organisation: its label (
PUT /api/v1/operator/organisations/{id}/teams-label, body{ "teams_label": "office" };DELETEtakes it away), shown asteams_labelon the organisation, on the organisation's Microsoft Teams card in the console. A label on a deployment that is no SBC is refused409 teams_not_enabled, since it could reach nothing; one another organisation holds is409, one that is not a DNS label422. Then the DNS for<label>.<base>(an A/AAAA record at the SBC, or a CNAME to<base>) and the TXT record the organisation's Microsoft 365 tenant asks for to verify the domain, which lives in the base domain's DNS and so is the operator's to publish. - The organisation's administrator, in their own Microsoft 365 tenant: add and verify the domain
<label>.<base>; activate it with one Teams-licensed user or resource account whose sign-in name is in it; add it to a voice route as a derived trunk (Set-CsOnlineVoiceRoute -Identity <route> -OnlinePstnGatewayList @{add="<label>.<base>"}); and give each Teams user their number as a Direct Routing number with a voice routing policy holding that route (Set-CsPhoneNumberAssignment -Identity <user> -PhoneNumber <number> -PhoneNumberType DirectRouting). - The organisation's administrator, in siphon-pbx: binds extensions on the Microsoft Teams page
(
GET /api/v1/teamsfor the connection and the lines,PUT /api/v1/teams/lines/{extension}with{ "number": "+15550100" },DELETEto unbind). A binding is refused409 teams_not_connecteduntil the operator has given the organisation a label, and409 teams_not_enabledon a deployment that is no SBC. An operator acting as the organisation may bind and unbind, recorded against them: unbinding is not a carve-out, because nothing is lost that the audit log does not hold, and a bind already replaces a line. A member is refused both. The Extensions page marks a bound extension "Teams" and says it rings in Teams only. Teams lines are not in the MCP directory: a flow names the extension, never the Teams line behind it.
To confirm on a Microsoft 365 trial tenant before release: that Microsoft's INVITE names the derived-trunk FQDN as its Request-URI host, that a Let's Encrypt certificate and the two names above are accepted, and Microsoft's real SDP.
What siphon-sip still needs¶
siphon-sip 1.9.0 takes calls and registrations with no routing script and anchors a handed-over call's media on siphon-rtp, so a flow answers the caller and plays prompts to it. What the control plane still does not do: conference three parties, and join two dialogs it already hosts (which is the attended half of transfer, below). Until those land, a step that needs one is reported to the flow as a command the connected siphon-sip could not carry out, and the call ends as a flow error its trace explains. Nothing here pretends otherwise: no answering callers first to imitate a dial, and no 200 with nothing behind it.
A phone's hold is not on that list. siphon-sip relays a re-INVITE or UPDATE on one leg of a bridge or a dial to
the other leg (1.11.2 for a bridge the control plane formed; the two legs of a dial relay it as any B2BUA call
does), so a hold, a resume and a refresh reach the far party and its answer comes back as the 200, and siphon-pbx
is never told. A call with no second leg (an IVR, a queue, voicemail) answers the hold itself, sendonly with
recvonly (1.9.0). deploy/e2e/ims.sh holds and resumes a call handed over on ISC both ways, with a
re-INVITE that holds nothing beside it.
Ringing a phone for an unanswered caller landed in 1.11.1 (dial {on_answer}), recording in 1.10.0, and
the last thing a queue was waiting on — stopping a ring without ending the caller — in 1.13.0
(cancel_dial). No flow command maps to an unsupported step in this release, which is why
siphon_pbx_flow_steps_unsupported_total reads zero on a healthy deployment rather than being a counter
nobody looks at.
On siphon-sip 1.9.0 that means:
- a number no flow owns gets 404 where the call came from a peer this system has a relationship with —
one of its registered phones, or a trunk an organisation configured — and no final response at all
where it did not (siphon-sip's automatic 100 Trying precedes the handover and is not suppressible
from here). A carrier offering a number we do not host needs its 404, or it retries and then marks us
down; a phone's user hears nothing unless the call is answered. A source neither of those is owed
nothing, and a 404 would tell it whether the number it probed exists, which is the one thing an
enumeration sweep places the call for. A dropped call is counted on
siphon_pbx_calls_ended_total{outcome="dropped"} and its INVITE stays in the operator's capture; it
writes no call record, because at a swept port's rate a row per probe is itself a denial of service. A
trunk is recognised by the address its SIP is already sent to, by a source network an operator declared,
or — for a host that is a DNS name — by the addresses that name was last resolved to. Those are resolved
on a schedule and on every trunk change, never while a call is being decided, since the calls that reach
this decision are the sweep itself; and the decision fails open, so while a name's addresses are
unknown nothing is dropped at all. Refusing a scanner costs one response, silencing a carrier costs
inbound calling. The exemption rendered into siphon-sip's own configuration stays name-blind, because
that one is written into a file that outlives its lookup;
- a flow that hangs up before answering gets 480, not a 6xx, so a trunk can still try elsewhere;
- an announcement or an IVR menu answers the call (200), plays its prompt on the media anchored at the
engine, and an IVR menu branches on the key the caller presses;
- a caller reaches a queue, waits in it with looping hold music, and is bridged onto the agent who
answers; the caller's maximum wait and the breakout key both stop the agents' phones ringing first
(cancel_dial, siphon-sip 1.13.0) so that nobody is joined to a caller who has left the line;
- a call that arrives while siphon-pbx is not connected is left to siphon-sip's own control-loss policy.
A desk phone's transfer is carried out rather than refused, on siphon-sip 1.13.0 and later: a blind transfer to an extension of the referrer's own organisation rings that extension's registered address-of-record — the only form that reaches a phone registered over TLS through the proxy — and a blind transfer to a number outside the organisation is routed by that organisation's own outbound flow, so the trunk the call leaves by, the number it shows and whether the destination may be called at all are decided in the one place that decides them for a call a phone dials itself. A transfer is not a second dial plan, and a transfer the flow places no call for is refused rather than sent out some other way.
A transferred call's record does not name where the call went, and that is a gap of ours rather than a
property of transfers. The leg a transfer rings is placed by siphon-sip on the REFER rather than by a
dial, so no DialBranch names it and it is not one of the call's legs; what the record holds is the call
up to the transfer — the flow it ran, the phone that answered, and that answer as its outcome. siphon-sip
does report the move on the surviving channel (PeerReplaced, carrying the new leg's Call-ID and
origin: "refer"), and reading that event is unbuilt. Until it is, which call was transferred and to whom
is answered by the log line the transfer writes, carrying the Refer-To and the referring extension.
A transfer is authorised the way a call out is and never by anything the asking party wrote. The call's own caller is authorised by the registrar — which live binding its INVITE's source belongs to — and a party the call dialled by what it was dialled at, since a ring resolves an extension of this organisation out of the directory and dials the registrar's own key for its phone. A carrier, a phone of another organisation, and a carrier leg of a call out are each refused, each with its own cause in the log and a status on the wire that says only that the request was refused.
The attended transfer is the one shape still refused, and it is refused upstream. A phone that has
spoken to the target first sends a Replaces, which asks for the party staying on this call to be joined
to the party staying on the consultation call. siphon-sip 1.13.0 names the dialog (replaces.local) and
offers accept_refer {mode: "controller"} for an application to move the parties itself, but the only verb
that joins two live dialogs addresses a channel, and the field that would name the consultation call's
surviving channel (bridged_with) is read from a control-plane bridge between two calls — so it is empty
for an ordinary two-leg consultation call, which is what one always is. It is therefore declined 603 with
siphon-pbx's own reason phrase rather than approximated by re-dialling a party who is already on the line,
and b2bua.accept_replaces stays off, because enabling it without the takeover built lets the transferee's
INVITE arrive as an ordinary unrelated call. Written up for upstream.
Phones register through the credential view above; over TLS, they reach the stack through the TLS proxy covered below.
SIP over WebSocket (RFC 7118), for browsers. wss://<an organisation's hostname>/sip reaches siphon-sip
through the same Caddy, on 443: no port of its own is published. The proxy's HTTPS site proxies a request that
is a WebSocket upgrade on /sip (Connection: Upgrade, Upgrade: websocket) to siphon-sip's listen.ws,
after the address rules and the rate limit and ahead of the proxy to siphon-pbx, so every other request,
GET /sip without an upgrade included, is siphon-pbx's as before. Like the TLS hop, the connection opens with
a PROXY protocol v2 header (the http transport's own proxy_protocol, stock in Caddy), and siphon-sip takes
the browser's address from it from the TLS proxy's networks alone (listen.ws[].proxy_protocol.from, the same
list as listen.tls); the WebSocket listener is plain ws, bound on the compose bridge (loopback on the
host's namespace) on its own port (SIPHON_PBX_SIP_WS_LISTEN, default 5080), and no layer publishes it.
Registrations over it are ordinary bindings with transport=ws in their source; nothing in siphon-pbx reads the
transport beyond writing it into the source it compares a call's against.
- A reload closes a WebSocket, unless told not to. siphon-pbx loads a render into the running Caddy for every
saved address rule, and Caddy closes proxied WebSockets when a configuration is replaced. The route sets
stream_close_delay 5m, so a connection outlives a reload by up to five minutes (siphon-sip's own idle limit is 300 s) and an address a new rule refuses keeps a connection it already has for no longer than that. - siphon-sip closes an inbound WebSocket after 300 s without a byte from the browser. The web phone to come has to keep the connection alive (a keepalive, or a registration refreshed inside that time); nothing here does.
- A desk-phone password works over WSS. The credential is the extension's, whatever the transport, until the web phone has a credential of its own that works over WSS alone.
- No call is placed over WebSocket yet. Browser media (ICE, DTLS-SRTP) is a media profile of its own and is not part of this transport.
Rolling upgrades¶
Upgrading the PBX must not drop calls, so the old and the new release run side by side against one database until the old one has finished the calls it holds.
- The database allows it. Every migration declares the oldest release that can still run against it. A release refuses to start against a schema it cannot serve, and a migration that would break a release still running waits for that release to stop rather than breaking it. Migrations that only add are the normal case; one that takes something away is a separate release, after the code that used it is gone.
- Instances are known. Each process registers and refreshes a row while it runs, so an upgrade in progress is visible in the UI and to the migration gate.
- Several nodes and a contracting migration. A new release that carries a contracting migration waits, logging that the older release should drain and stop, for as long as any older siphon-pbx on the same database is live, including one on another node. It opens no ports while it waits, so a readiness probe times out without naming the other node. Upgrade by stopping siphon-pbx on the other nodes first (their calls drain first if they are stopped gracefully), or upgrade every node before expecting any of them to answer.
- They may share a node id, and web calls do not mind. A web call's token belongs to the process that spent it, so the new release's startup and reconcile never release the old release's live web calls. See the web-call token lifecycle.
- Why not restart and resync. The control plane hands a reconnecting controller its calls back, but not where each call was: which menu it was in, how long it had been queued. Finishing those calls in the old process is the only way to keep them whole.
- What siphon-sip still needs for it. A connection cannot say it is draining, so the old process keeps being given new calls until its socket closes, and there is no verb to hand one call to another connection of the same application, which is what a queue needs to pass its waiting callers on with their place in line. Both are in the change requests.
Capture and observability¶
siphon-sip and siphon-rtp export HEP, so siphon-pbx collects it: every SIP message and RTCP report, continuously, filed under its call. Nothing has to be turned on before a call goes wrong.
- Packets live in a table partitioned by day, so retention costs a dropped partition rather than a delete of millions of rows. Office volume fits Postgres comfortably; a carrier-scale deployment would put the same rows in a column store, which is a change to one module.
- A day is the grain the setting needs.
SIPHON_PBX_CAPTURE_RETENTION_DAYS(7 by default) is counted in days, and a partition goes only once every hour it covers is past the window, so the window is rounded up, never down: seven days keeps seven to eight. A month per partition could not serve it at all — the month holding today is droppable only when the whole month is a week past, which kept up to five weeks for a setting that said one. Deleting the rows instead was the alternative and was rejected: it leaves a live partition full of dead tuples for autovacuum, where dropping a table leaves no bloat. - The sweep runs with the partition creation, at start and every six hours, under an advisory lock keyed to the database, so sweeps cannot queue up behind each other and two instances starting together cannot drop the same partition twice.
- OPTIONS keepalives are never stored, dropped at ingest before they reach the queue or the table,
requests and responses alike — a response says which transaction it belongs to only in
CSeq, and half the traffic was200 OKand401 Unauthorizedanswers. A keepalive that succeeded says a peer answered, which is liveness rather than a packet worth keeping, and liveness is already reported by the registration state each trunk pushes. There is no carve-out for a failed one: a401challenge to a keepalive is routine, so keeping the failures would be a second firehose. REGISTER is untouched, since a registration that will not complete is diagnosed from it. - A call's traffic belongs to the organisation whose flow took it: the call claims its Call-ID as it enters the flow, and the first claim wins. An organisation reads only its own calls, from a minute before each claim (the INVITE is captured before the call reaches its flow); the operator reads everything, traffic no flow took included.
- Everything that is not a call is attributed from the message itself, because nothing else reaches
a flow: a phone's REGISTER and a SUBSCRIBE are answered by siphon-sip's registrar and
script. An organisation is named by where a message was sent — the request
URI and
To, which are what the PBX routes on — and a trunk by an address its SIP already goes to, a declared source network, or its configured host.Fromcan name a trunk, since a response names the carrier nowhere else, but never an extension: a message merely claiming to be a phone is not that phone's. A message that names two organisations is attributed to neither, and one that names none stays with the operator, which is what the scanners a public SIP port collects do. - Attribution is written per packet, not per Call-ID: a Call-ID is whatever the sender wrote, so a grant keyed by one could be claimed for another organisation and would hand over every packet that shares it. Deciding each packet on its own content cannot do that.
- What an exchange is, is derived when it is read, from the first request method captured in it:
call, registration, keepalive, subscription, other, or media alone. Nothing about the kind is
stored, so traffic captured before any of this reads correctly too. A list of calls asks for calls,
which is what keeps tens of thousands of registrations and subscriptions a day off it.
keepalivestill reads back what was captured before keepalives stopped being stored, and nothing after. - An extension and a trunk each trace their own recent SIP, on their page, out of the same attribution. Which registration was turned down, what the carrier answered a call with, and the pcap of either, without going through a list of everything.
- A call's page shows its ladder, what the far end heard from its RTCP (loss, jitter, round trip, a score from the G.107 impairment factors) and a pcap of the whole call, with the frames rebuilt around each payload. siphon-rtp scores the leg it carries itself; the reports are the other end's view, arriving while the call is still up.
- The CDR joins the same call: one page for what happened, what was said on the wire and how it sounded, rather than three places to look.
- Prometheus metrics are served on their own listener, never on the public side. The stack scrapes siphon-pbx, siphon-sip and siphon-rtp, so call volume, media quality and system health share one set of graphs.
The System view, and what each component can actually be asked¶
Capture answers "what happened on that call". The operator console's System view answers "what is this machine doing now", and the three processes do not answer it equally. The view is shaped around that rather than around a uniform set of tiles, because a tile drawn for a component that cannot report it would have to invent the number.
| what it exposes | its log | |
|---|---|---|
| siphon-sip | an admin HTTP API: dialogs, B2BUA calls, transactions, connections by transport, requests by method, registrations, live calls with per-branch outcomes, and security counters | a fixed-size ring of its own warnings and errors, over the same API |
| siphon-rtp | GET /metrics, /healthz, /readyz and nothing else — label-free numbers, no packet counters, no media port-window gauge, no per-call listing |
none: it writes to its own output and serves no log at all |
| siphon-pbx | its own exporter, its instance registry and its control-plane state, all already in-process | the last 500 lines in a bounded ring in memory |
- siphon-sip's admin API is a block of its own and nothing exposed it before. It is separate from
metrics.prometheus.listen, which serves the scrape and nothing else, so none of the state above was reachable until siphon-pbx began renderingadmin:. See Security defaults for how it is bound and gated. - Per-branch outcomes are the ring-group diagnosis nothing else provides.
dialtells a controller that a dial failed and never which of the rung phones answered or what each one replied./admin/callscarries abrancheslist with each target, its status and, on a branch that failed, the code it failed with. - Three actions, and only three: drop a registration, lift a blocked source, end a live call. The same API also drains the node, reloads siphon-sip's script and marks a carrier up or down. None of those is reachable from siphon-pbx: the client models every request it can make as one value of a closed list, that list is the only way a request is built, and a test walks it to prove no drain-shaped path is in it. Draining siphon-sip would stop it admitting every inbound call, quietly, which is not something an operator console should be one click away from.
- Rates come from the Prometheus the stack already scrapes. Every number above is an instantaneous gauge or a monotonic counter, and a counter is not a rate; keeping the previous scrape in siphon-pbx to divide would be a second, worse copy of what Prometheus is for. The graphs ask for one of six named series whose expressions are held in Rust, so nothing a request carries reaches Prometheus as a query.
- A number nothing measured is drawn as an em dash and never as a zero. Both upstreams make this
distinction deliberately — siphon-sip serialises a subsystem this deployment does not run as
null, and the media engine withholds its CPU gauge until it has a sample so that the gauge never reports a misleading 0 — and coalescing either into a zero would erase it. Every panel therefore has three states: not configured, unreadable with the reason siphon-pbx gave, or a value. - The bans list has one ambiguity that is stated rather than guessed at. siphon-sip answers an empty list
both when nothing is banned and when its ban store is not configured, and nothing on the read side of the
API tells the two apart. siphon-pbx always renders
security.failed_auth_ban, so on a stack it configured an empty list means nothing is banned, and the view says that rather than inferring it from a zero.
Logs are read per component, because a shared log volume cannot be built¶
The obvious arrangement — one volume every container writes its log to — is not implementable. Docker's
json-file driver chooses the path itself, under a root-owned directory, and log_opt accepts max-size,
max-file, labels, env and compress and no path. Making those files readable means bind-mounting
the daemon's own container directory, which exposes every container on the host and needs root to read, while
siphon-pbx runs as uid 10001 — close enough to handing it the docker socket to be the same decision.
So each component is read where it genuinely has a surface:
- siphon-sip: its admin log tail, which the admin token is what enables — siphon-sip refuses to serve
it unauthenticated at all.
GET /admin/logsis a fixed-size ring of warnings and errors only: nothing atinfoor below has ever been in it, it takes no parameters, and it drops the oldest as new ones arrive. The view labels it as that and never as scrollback. - siphon-pbx: a
tracinglayer beside the formatting one, sodocker logsis unchanged, filling a ring bounded by construction. It holds whatever the process's ownRUST_LOGadmits, which is more than siphon-sip's ring gives, and a restart empties it. Every string in a record is bounded before it is stored, because a log line carries text a peer influenced — aUser-Agent, a URI, a header value. - siphon-rtp: nothing, and the view says so. The only way to change that without a docker socket is a logging driver shipping the output off the machine, which is an operator's decision.
Separately, every container's log is now bounded (10 MiB across 3 files). Nothing bounded them before, on a disk that also holds Postgres and the capture.
Media¶
siphon-pbx never opens its own control connection to siphon-rtp. An engine call belongs to the control connection that created it, so a second controller could not act on siphon-sip's calls in any case. Every media intent (play a prompt, collect digits, record, bridge, stream to an AI agent) is a control-plane verb to siphon-sip, which drives the engine. Gaps in what the engine can do are fixed in siphon-rtp, not worked around here.
A browser is a property of one leg, and every other leg stays what it was. A WebRTC client (JsSIP in a
browser) registers over WSS, so the binding siphon-sip records for it carries transport=ws or wss
(registrations::is_browser_source, the one place that says what a browser is). A call from one has
CallerOrigin::RegisteredBrowser: everything true of one of the organisation's own registered clients is true
of it (CallerOrigin::is_registered), and only its media differs. A ring toward an extension whose every
binding is a browser's is a RingTarget::Browser. Both choose among media profiles rendered for the purpose
(siphon_sip::media_profiles), where each half of a profile faces one party (see MediaProfile):
- Toward the browser:
UDP/TLS/RTP/SAVPF,ice: force(an ICE leg: siphon-rtp runs--ice-fullin every compose shape, so the engine runs a full RFC 8445 agent that answers checks on its advertised address and offers noa=ice-lite, and answers a browser itself, for a prompt or a voice bot's WebSocket takeover), no DTLS role imposed (the engine takesactiveanswering a browser'sactpassand offersactpassitself, RFC 5763 §5),rtcp_mux: require(RFC 9429 §4.1.1) andcodec.offer: [opus], withcodec.transcode: [opus]added to an offer so a desk phone's G.711 has an Opus to be transcoded to. - Away from it: the plain profile's own half, with
codec.offer: [G722, PCMA, PCMU]when the browser is the caller, so the far side is never offered Opus and the engine holds the browser leg on it. The caller's source hint is dropped for a browser: ICE verifies its address, which a hint only guesses. - Not done: one extension with a browser and a desk phone registered together. siphon-sip 1.19.1 applies a dial's one media profile to every contact of an address-of-record, so the ring offers that extension what the phone takes and its browser does not ring. A per-contact profile is the upstream change that closes it.
A browser holds its registration inside siphon-sip's 300 second idle close of a WebSocket by refreshing it: the browser phone registers for 120 seconds, which JsSIP refreshes at most 88 seconds after the last request.
Prompt audio travels over a filesystem, not the control connection. The play verb names a path,
and siphon-pbx writes each prompt once onto a private volume the engine also mounts, under the SHA-256
of its audio. The control plane's other source for a prompt is an inline blob, and a blob cannot carry
one: it reaches the engine as a JSON array of decimal numbers against a 1 MiB frame ceiling, so a prompt
over roughly 318 KB of WAV — under four seconds at 44.1 kHz — is refused and the call ends as a flow
error. Playing by path has no ceiling and lets the engine's own prompt cache keep the audio decoded; a
prompt already on the volume costs one small row and no audio. Naming files by content means replacing a
prompt's audio writes a new file rather than mutating one a call is playing, and nothing has to
invalidate anything; what that leaves behind is audio no prompt hashes to any more, which the controller
sweeps once before it takes calls. Outside compose, mount the same directory at the same path in both
and set SIPHON_PBX_PROMPTS_DIR (default /prompts): writable by siphon-pbx, readable by the engine.
AI providers¶
An organisation configures its own providers, and today one thing uses them: a prompt written as text instead of recorded. A provider is a kind (which interface the endpoint speaks), a base URL and a key sealed under the master key like a trunk's password, so an endpoint on the organisation's own hardware is configured exactly as a hosted service is. A voice is a name of the organisation's own over a provider's model, and it is what the prompt editor offers.
A generated prompt is an ordinary prompt. The endpoint is called, its answer is checked to be a WAV file, and only then is a prompt row written — through the same function an upload goes through, into the same content-addressed store above. So the call path is untouched, playing a written prompt needs no network, and a generation that fails leaves nothing behind because nothing was created yet. The editor shows the provider's own reason, read out of its answer.
The provider row is deliberately about the connection rather than about speech: a later feature that recognises speech or asks a language model on the same account adds a child table beside the voices rather than a second provider to configure and a second key to rotate. What leaves the machine today is the prompt text and nothing else — no call audio, no caller information — and the console says so, naming the host it goes to. The features this is a foundation for would send a caller's voice off the machine, which is a different thing for an organisation to agree to, so the wording stays scoped to what exists.
Outbound HTTP goes over one request on one connection with a deadline and a response ceiling
(ai::https), built on the hyper already compiled in, with the root certificates bundled so a distroless
image can verify one. It follows no redirects: a redirect would send the organisation's key to a host it
did not configure.
Email¶
Mail leaves through an SMTP server, configured in two places: an instance default the operator sets,
so mail works before any organisation has configured anything, and an optional organisation override,
typically the organisation's own sender domain so its SPF and DKIM hold. mail::resolve takes the
organisation's row if it has one and the instance default otherwise; neither is MailError::NotConfigured,
which the caller reports rather than dropping the message. One table (mail_transports) holds both, one
row per scope, enforced by two partial unique indexes.
The password is sealed under the master key like a trunk's, write-only through the API, and bound to its
row. Protection is enforced, not advised: STARTTLS is required (a server or a network in between that
does not offer it gets no password and no message), implicit TLS is TLS from the first byte, and a
connection with no protection is refused to anything but a loopback address written out, in Rust and
again by a CHECK. Certificates are checked against the bundled Mozilla roots over the same rustls and
ring the rest of the binary uses, with no setting to skip it.
Sending uses lettre (SMTP transport, tokio, rustls on ring, MIME builder; no connection pool): one
connection per message, each SMTP step bounded at 20 s and the whole send at 60 s. A message is one
recipient, a subject, a plain-text body and at most one attachment. A failure is logged with where it was
going and why, never the password, and the server's own reply is carried back so a "send a test" action
tells an administrator which setting to fix.
Invites by email¶
An invite's one-time link is emailed to the invited address when a server resolves for it
(invite_email): the organisation's own server or the instance default for an invite to join an
organisation, and the instance default alone for what an operator issues (another operator, an
organisation's first administrator). The email is plain text: who invited them, to what and as what, the
link on a line of its own, when it expires on the organisation's clock (UTC for an operator), and that it
works once. Names that go into the subject are cleaned by the same function a voicemail email's caller
name goes through.
It is sent inline, in the request that issues the invite, and deliberately not through an outbox like
voicemail's. Only a hash of the token is stored, so the link exists in clear only while that request runs;
a queued row would have to hold it, which is what storing the hash is there to avoid. So the send is
bounded (15 s as a whole, since an administrator is waiting on it) and never retried. The invite is
committed before the mail server is spoken to, and the answer always carries the link with emailed:
sent, not_configured or failed (with email_error, the server's own words). Sending again is
inviting the address again, which already voids the earlier link and mints a new one; there is no
endpoint that resends without reissuing. Neither the link nor the token is logged or audited.
Voicemail to email¶
Each mailbox says whether a new message is emailed (mailboxes.email_delivery): off (the default),
notify (who called, when on the organisation's clock, how long, which mailbox, and a link to the Voicemail
page on the organisation's first hostname) or attach (the same with the recording as audio/wav). It goes
to whoever holds the extension of a mailbox of its own, and to the members of a shared one, each address
once; an administrator is not mailed every message just for being able to read it.
Sending never sits on the call's path. voicemail::save stores the message and, when its mailbox emails,
a row in voicemail_email_outbox, in one statement: a stored message is one that will be emailed, whatever
happens to the process afterwards. A worker (voicemail_email::Outbox, spawned at startup) takes due rows
with FOR UPDATE SKIP LOCKED and a lease, so several instances can run it and a worker that dies mid-send
leaves the row to be taken up again. The recording import wakes it after a save; a 30 s poll is the
backstop for retries and for rows another instance queued. A mail server that is slow or down therefore
delays only the email, never the call or the save.
Every row settles and leaves the outbox. Nobody to send to, no mail server at either scope
(NotConfigured), or the setting turned off since are settled at once with the reason in the log and are
not retried. A refusal, a failed connection or a timeout is retried with backoff (1 minute doubling to an
hour, eight attempts), and the addresses already sent to are recorded on the row, so a partial failure
never sends anybody a second copy. After the last attempt it is given up with an error!; the message
itself is kept. A recording over 10 MB is linked instead of attached, and the email says so. There is no
transcript in it yet.
Call flows¶
A call flow is a graph: nodes are blocks, each block has typed output ports, and an edge connects a
port to the next node. The model, its validator and its executor live in crates/siphon-pbx-flow,
which has no I/O, no clock and no dependency on the SIP stack or the control plane.
- Versioned. A flow is edited as a draft and published as an immutable version. A call pins the version it entered on, so publishing never changes the behaviour of a call in progress, and rolling back is selecting an earlier version.
- One validator. The editor, the simulator, the copilot and the live executor all use the same validation, so a flow that validates in the editor is exactly a flow the executor can run.
- Cycles allowed, bounded. An IVR menu that loops back to itself is normal. Every call carries a transition budget so a flow with no wait between steps cannot spin.
- Blocks. Entry points (inbound number, internal extension, feature code); routing (time schedule with holiday calendar and a feature-code override, override toggle, set override, variable set and switch, extension status, divert, go to flow, language); media and people (announcement, remote announcement, IVR menu, ring extension, ring group, pick up, queue, voicemail, park, conference, record with consent, dial external); integration (webhook, sub-flow); AI (agent, intent classification); and hang up.
- A divert carries its own signalling. Forwarding a call to an extension or to a number outside
puts
History-Info(RFC 7044) andDiversion(RFC 5806) on the leg it places, naming which of the organisation's parties forwarded the call and why, as an RFC 4458 cause code and an RFC 5806 reason token. A call that arrives already forwarded keeps every hop and gains one; which of the two headers a carrier is sent is that trunk's own setting. The headers are built in the live adapter, not in the flow engine: what the flow decides is who forwarded the call, to where and why. - A caller that has been answered is bridged, not connected. Every block that places a leg — ring, ring group, divert, dial out — reaches the far end the same way, and how the answer gets back to the caller depends on where the caller already is. One that is still waiting is connected: the far end's own answer answers it, so its own ringback reaches the caller and nothing is billed before anybody picks up. One that a prompt, a menu or a queue has already answered and anchored at the relay is bridged: the leg is placed as a call of its own, the caller hears a ringback while it alerts, and the two are joined when it answers. The adapter chooses from the caller's own state, so no block carries the decision and no flow shape is refused for it.
- Variables and data sources. A flow can set variables from static values, an HTTP lookup or built-in lookups (extension state, contact directory). Flows never run raw SQL; an administrator defines named data sources instead.
- The caller's number, three ways. Every call starts with
caller.number,caller.deliveredandcaller.national.caller.deliveredis the From header's user part exactly as delivered, which is also what the call record keeps.caller.numberis that number read into E.164 bynumbers::delivered_forms, the reading a voice bot's brief uses too: already+; the plan's international or national prefix; or a run of digits longer than an extension and not starting with0. Where none of those applies (an extension, a short code, a national number with no plan) it is the number as delivered.caller.nationalis the E.164 number in the organisation's own national form, absent for a caller abroad. A withheld caller's number is left as delivered in every form. The executor does the reading at the start of the call, from the plan the directory carries, so the flow crate stays sans-IO and the simulator, an inbound call, a transfer out and a call placed through the API all read a caller the same way. A Match case oncaller.numberwritten as bare digits that cannot be an extension is a validator warning, not an error, because a version published before the reading existed must still run. - One model for everything that routes a call. An extension's availability states (available, away, do not disturb, each with its forwarding rules) and every feature code are flows too. The UI presents the simple ones as forms that generate the flow, so there is a single engine and no second, hidden dialplan.
What that turned out to mean for feature codes, now that they are built. A code is not stored
as a flow's claimed number, and could not be: flow_numbers is keyed on the number alone across the
whole system, deliberately — a DID leads to one flow, so the number by itself settles which
organisation a call belongs to. A feature code is the opposite kind of thing, since every
organisation wants *72 to mean the same inside its own walls, so a global claim would hand *72 to
exactly one organisation on the deployment. The code therefore belongs to its organisation
(feature_codes, keyed on (tenant_id, code)), and the flow half of the promise is kept where it
matters: the resolver builds a flow from the ordinary blocks and the one executor runs it, exactly as
a directly-dialled extension is handled. So there is still one engine and no second dialplan — what
is per-organisation storage is which code means what, not how it runs.
A code enters through an Outbound block rather than an Inbound one, because that is what it is: a
call one of the organisation's own phones placed. The first attempt claimed the code on an Inbound
block and the validator refused it, which was right — *72 is not a number a flow may claim, and
that refusal is the same rule that keeps a code from ever shadowing an extension or a DID, read from
the other side.
A code is reached only by a registered phone of its own organisation. The registrar is the one thing on that path that has checked a credential; the Request-URI's host is spoofable, and a code reachable that way would let anybody on the internet put an office into night service.
Some codes carry a target in the digits after them, and only some may. *8 picks up whatever is
ringing and *8201 picks up 201's call: one stored row, and which call it takes comes from what was
dialled. So the lookup takes the exact code first and then the longest stored code that is a prefix of
what was dialled — but a prefix matches only for an action that says it takes an argument, and only
when the remainder is a number an extension could have. Without the first of those, *721 would find
*72 and put the office into night service on one mis-keyed digit; without the second, *8 would
answer for anything at all beginning with it.
Three more codes change the dialling phone's own extension, and name none. set_do_not_disturb
(on, off or flip), forward (always, busy or no answer, to the number dialled after the code) and
cancel_forward (one kind, or all three) run one Set call handling block. The block carries no
extension: the adapter applies it to the extension this call's own registration check named, through the
same pickup::verdict a pickup asks (a carrier, a phone of another organisation, a party the call dialled
and a Teams leg are all refused, taking failed), so one row serves every phone and a code cannot reach a
colleague's settings. A forward's argument is any run of 2 to 20 digits (accepts_argument, beside
takes_an_argument, since a pickup's is an extension number and a forward's may be a number outside). It is
read where it is stored, by extensions::change_handling_from_the_phone: an extension number as it is, a
+ number as it is, and any other run of digits is read with the organisation's dialling plan into
international form (a keypad sends no +). Every forward still goes through the one
validate_forward_target an administrator's goes through (emergency numbers refused on what was dialled,
the extension must exist and must not be itself), and a bare forward code carries an empty target, which that
check refuses, so it ends on failed rather than forwarding nowhere. One kind is changed under the row's
lock, so the others and the no-answer time are left alone, and a flip of do-not-disturb is a read and a write
of one locked row. No audit row is written, because the audit log's actors are accounts and widening it is a
contracting migration 0044 declines: the record is the call, which carries the extension and the code
dialled and a trace note of what changed. Migration 0097 stores the state and the kind in two columns of their
own and is contracting (compatible_from 93) by 0062's reasoning, since a release before it cannot read
these rows. The block is in the designer's palette like Pick up, and failed takes a call that is not from
one of the organisation's phones.
Executor, queues and the two clocks¶
Each call has an executor: a state machine that owns the call's flow state and variables. It is fed timestamped events (a key was pressed, a phone answered, a timer fired) and answers with commands (answer, play, ring, record, join a queue, start a timer, hang up). A call queue is shared by every call waiting in it, so it has its own engine of the same kind: callers in line, agents offered the caller at the front.
Live, that engine gets a host of its own — one task per organisation-and-queue, started when the first caller joins and retired once the line has been empty for a while. It drives no call. The engine answers with actions naming a caller, the host sends each to that caller's own actor, and the actor issues the verb and reports back what became of it: the actor stays the single owner of its call's state, and the queue's view of its agents follows what really happened on the wire. The one piece of arbitration that cannot live in the queue lives in the actor: a caller whose wait runs out while an agent's phone is ringing has its failover held until that ring has settled, so an agent who answers in the same instant gets the caller rather than talking into the voicemail the caller was about to reach.
A queue's periodic announcement plays its prompt; the caller's place in the line is recorded against the call and not read out, because speaking a number needs number audio this release does not have, and the validator warns at publish time wherever a queue asks for it. A dynamic member takes calls only while logged in to the queue, and there is no way to log in to one yet, so a queue of dynamic members rings nobody on a live call.
Call pickup is the other thing that reaches past one call, and it is built the same way. A phone
dialling *8 has to find a different call — one still ringing somewhere in the same organisation — stop
the phones that were rung for it, and be joined to the party on the other end. Nothing in a single call's
own state can answer "what else is ringing", so a registry sits beside the calls as a queue's host does: a
call registers the extensions it is ringing while it rings, and what it leaves behind is its own
mailbox and never its state. A pickup is then one message to that mailbox and one answer back, and every
verb is issued by the actor that owns the call it acts on.
The three things a pickup does are done in one act by the call being taken over, because none of them is useful alone: the phones are stopped first, then the caller is answered, then the two calls are joined with the picked-up call as the anchor — the leg that keeps its media session, so a recording or a transcript of the call somebody grabs survives the grab. A pickup that could not stop the phones is refused back to the phone that asked rather than pushed past: an agent picking up a moment later would otherwise be bridged onto a caller who is already somewhere else. The picked-up call then records exactly as a ring that extension answered, which is what makes the call log the answer to "who grabbed that call".
This registry is deliberately not the busy-lamp store. That one holds dialogs siphon-sip reports for the phones watching them, and a dialog cannot be commanded; it is also populated only on a deployment that can push a NOTIFY, and it never sees a call an extension places. Building pickup on it would make the feature depend on a subscription somebody's phone may or may not have made.
- the live adapter maps commands to control-plane verbs and control-plane events back to engine events;
- the simulator plays the same part against a scripted world on a logical clock: time of day, caller ID, keys pressed, how each phone behaves.
Neither engine reads the wall clock; time arrives with each event. That is what makes schedules, ring timeouts, queue behaviour and menu timeouts deterministic under test, and what lets the simulator answer "what happens if" questions exactly.
Test cases and the path trace¶
- Flow test cases are saved next to a flow: inputs and the expected path and outcome. They run in the simulator on every build, and publishing refuses a change that alters an outcome until the change is acknowledged.
- The same test case is rendered to a SIPp scenario and run against the real stack. A telephony feature is not done until its SIPp scenario passes, and a disagreement between the simulator and SIPp is a bug in one of them.
- Every live call records its path trace: each node it passed through, with timings. The call log shows it directly, for example: inbound trunk, 1 min 12 s in the sales queue, answered by extension 204, 4 min 3 s, hung up by the caller.
AI¶
- Flow copilot. Describe a call flow in plain language and get a draft: the model produces a graph against the flow schema, the validator checks it, the simulator runs the flow's test cases against it, and the result is shown as a diff on the canvas. A person publishes; the copilot never does, and AI-originated changes are recorded in the audit log.
- Questions answered by running the flow. "What happens when this number calls on Sunday at 18:05?" is answered by the simulator, not by the model's guess.
- Voice blocks. A voice-bot block hands the caller's audio to one of the organisation's bots (a pipecat bot, or the local GPU agent) over siphon-rtp's WebSocket bridge: the engine decodes the leg to linear PCM going up and encodes the bot's speech back into RTP coming down, so the bot never touches RTP, a codec or a jitter buffer. An organisation may have several bots, each with a name, and the block says which one it wants — by the bot's id, so renaming one leaves every published flow pointing at the same bot. A block that names none, which is every version published before it could, resolves to the organisation's bot while it has exactly one; the validator and the executor ask one function for that, so what the editor accepts is what the executor runs. An organisation with no bot of its own reaches the bot the operator provides, when there is one (see The voice bot the operator provides). The bot is a media peer and nothing else. It never joins siphon-sip's control plane — control-plane calls are owned per application, one application cannot touch another's call, and a media peer holding the authority to hang up or divert anything on the node is not a trade worth making. It reports what it made of the conversation to siphon-pbx over siphon-pbx's own API, naming the call by a per-call session token, and the flow acts on that report. A session belongs to one bot, so the secret that authorises a report is that bot's, and one bot's secret opens neither a sibling's session nor another organisation's.
- A Prepare bot block rings the caller while a bot gets ready. It tells the named bot about the call
without answering it, leaves by
readyonce the bot says so and byunavailableif the bot refuses, cannot be reached or is not ready within the block's wait (1 to 60 s), and a later voice block naming the same bot reuses what was prepared. See Preparing a bot before the call is answered. - A spoken menu is policed by the PBX, not by the prompt. The block declares its options, one output
port each; the bot is told what they are, and when it answers, the answer is checked against the ports
the block draws. Anything else takes
no_match. So an option a model invents, or one a caller talks it into naming, cannot route a call somewhere the flow was not drawn to send it. That check is what makes it an IVR rather than a conversation, and it lives in the executor because a prompt is advice and a port list is not. - Two kinds of bot, and neither is a fallback. An endpoint bot is a WebSocket somebody else serves:
an address and a secret, and the recognition, the model and the voice are that bot's own business. A
hosted bot is one this deployment runs, in the voice runtime the optional
docker-compose.voice.ymllayer adds; it has no address of its own, and names which of the organisation's own AI providers do each of the three jobs a conversation needs. A flow's voice block names a bot and cannot tell them apart, so one test definition covers both. - A hosted bot holds nothing. It names
ai_modelsandai_voicesrows that already exist, with the one sealed key per provider that an organisation already rotates, through composite references so a role can never be another organisation's. Those keys are opened in the request that serves one call's brief, handed to the runtime over loopback and dropped when that response is written; nothing new is stored and nothing new has to be rotated. The runtime is stateless by construction: nothing about a tenant is configured in it, and an organisation changing a prompt restarts nothing. - Which credential opens a brief is decided by the bot's kind. An endpoint bot's session is opened by that bot's own secret; a hosted bot's by the deployment's voice-runtime token, which is the only credential that reaches a brief carrying provider keys. So the runtime's token is not a master key over other people's bots, and a bot secret cannot reach this organisation's keys.
- A transcriber has the same two kinds, in the same runtime. An endpoint transcriber is a WebSocket somebody else serves, with its own address, its own secret and its own recognition. A hosted one runs in the same voice runtime a hosted bot does, has no address and no secret, and names one of the organisation's own recognisers — plus, optionally, a language model for summaries, because an organisation that wants only transcripts should not have to configure a provider it never reaches. A flow's Transcribe step names no transcriber at all, so nothing in a published flow version can tell the two apart, and the credential rule is the bot's: an endpoint transcriber's sessions are opened by its own secret and a hosted one's by the runtime token, which is the only credential a brief carrying provider keys is served to.
- What a transcribed call sends is said per kind, because the two differ in the way that matters. An endpoint transcriber takes both parties' audio off the machine. A hosted one takes it to the deployment's own runtime over loopback, and then to whichever recogniser was named — which may be across the internet or may be a model in the runtime's own process. The console is shown both halves before anything is chosen, and no two kinds, roles or capabilities may share a wording.
- What a bot is told about whose call it is is its own setting, and nothing at all until somebody sets it. See "What a voice bot is told about a call" below.
- Transcripts. Voicemail transcription and summaries, locally or through a configured provider.
- Keys. Provider keys are entered in the UI and sealed at rest with AES-256-GCM under a master key generated on first start.
What a voice bot is told about a call¶
A bot reads its brief at GET /voice/sessions/{token} with its own secret in Authorization: Bearer. The
brief carries call_id, instructions, options, deadline_secs and media (the bot's media setting,
below), and, depending on the bot's context setting, a context object saying whose call it is.
- The setting is per bot,
none,organisationorfull, andnoneby default. An organisation's administrator sets it on each of its own bots (contexton/api/v1/voice-bots); the operator sets it on the bot the deployment provides (/api/v1/operator/voice-bot, orcontext:invoice-bot.yaml). Left out of a change it keeps what it was, so a client written before it existed changes nothing. - What each setting sends is said by the server, as an AI provider's
sendsis:GET /api/v1/voice-bot-contexts(and/api/v1/operator/voice-bot-contextsat the operator address) lists each setting with its sentence, and every stored bot carries the one for its own setting ascontext_sends. The consoles print those sentences as they stand and write none of their own;web/src/api/voice-bot-contexts.fixture.jsonis the catalogue as this server emits it. nonesends nocontextkey at all, not even anull. The one key added to every brief since ismedia, which says nothing about the caller and which a parser reading only the keys it knows passes over.- An operator acting as an organisation cannot change it, either way, on an existing bot or by creating
one told anything (
disclosure_in_a_view). Who called and on which number is the organisation's to disclose to a third party, so it is its administrator's decision; the operator still sees the setting and can change everything else about a bot they may change at all. - The shape is versioned (
version: 1). Within a version a field may be added; none is renamed, retyped or given a new meaning without the version moving.deploy/e2e/voice-brief.fixture.jsonis afullbrief as this server emits it, held to the server by a test and checked against a real call's brief by the e2e.
"context": {
"version": 1,
"organisation": { "id": "<uuid>", "external_ref": "CUST-0042", "name": "Example Office",
"time_zone": "Europe/Amsterdam", "locale": "nl" },
"called": { "number": "+15550100", "national": "15550100",
"uri": "sip:+15550100@pbx.example.com;user=phone" },
"caller": { "number": "+15550142", "national": "15550142", "display_name": "Test Caller",
"asserted": "+15550142", "privacy": "none" },
"direction": "inbound",
"trunk": { "id": "<uuid>", "name": "Carrier" },
"destinations": [ { "name": "support", "description": "Problems with something already bought",
"modes": ["cold", "warm"] } ],
"any_number": false
}
organisationcarriesversion,organisation,destinationsandany_number.external_refandlocalearenulluntil set. The operator's bot is told the organisation of the call it is serving, never its own or another's.destinationsandany_numberare atorganisationandfullboth, and never atnone: the setting governs what a bot is told, and where a caller may be handed on is part of that. Added within version 1 (two new fields, nothing existing changed).destinationsis the call's own organisation's transfer destinations (see Transfer destinations), narrowed to the ones the voice block names, each byname,descriptionandmodes; never a target.any_numberis true when the organisation allows any number and the operator does not forbid it. Read on the call's path only for the call's own organisation, so one organisation's names never reach another's call; a test with two organisations and the one operator bot holds that, with each organisation's own brief as the control.fulladds the rest, each field only where the call really carried it:called.uriis the Request-URI exactly as it arrived;called.numberits user part, in E.164 where it reads as one without guessing (already+; the organisation's international or national prefix, read through its dialling plan; or a run of digits longer than an extension and not starting with0, which is a carrier's E.164 number with the+left off), otherwise as delivered. Absent when the Request-URI has no user part.caller.numberandcaller.display_nameare the From header's user part and display name, each absent when empty.caller.numberis read into E.164 exactly ascalled.numberis, by the same function, so a carrier that leaves the+off both delivers neither as bare digits; an extension caller stays as delivered. The stored call record keeps the number as it was delivered.caller.assertedis the number the network vouches for, where it does: the firstP-Asserted-Identityentry (RFC 3325 §9.1) of a call an S-CSCF handed over on ISC, read into E.164 by the same function asnumber.caller.numberstays the From, which the caller writes. It is sent only when the call's source is inisc.trusted_sourcesand the INVITE carries aP-Served-Userwith a session case (the same decision that runs the call as handed over), so the same headers from any other source tell the bot nothing. Absent too when there is noP-Asserted-Identity, and for a withheld caller. Added within version 1: optional, andnumberis unchanged. A bot that admits callers by identity goes by this and not bynumber.called.nationalandcaller.nationalare thatnumberthe way a caller in the organisation's own country says it: the national prefix of its dialling plan, then the national number (the national number alone where the plan has no national prefix). So a bot can read a domestic caller their own number back in the form they know rather than as+<country code>…. Present only wherenumberis E.164 and in the plan's country; absent for a number abroad, for one that is not E.164, for an organisation with no dialling plan, and always for a withheld caller. Added within version 1, as the contract allows: it is optional and changes nothing aboutnumber.directionis the direction of the flow the call entered, from its entry block.trunkis the one trunk of this organisation the call's source address belongs to, for a call that did not come from one of its own phones or through an S-CSCF. Absent when no trunk of its own is there, when two of them are, and while a trunk of its own known by a name could be there and is not yet resolved.- A withheld caller stays withheld at every setting. The caller is taken as having withheld their
identity when a
Privacyheader namesid,userorheader(RFC 3325, RFC 3323), or the From is anonymous (anonymoususer oranonymous.invalidhost, RFC 3323). Thencalleris{ "privacy": "id" }and holds no number and no name. - Left out of version 1 on purpose, because nothing real fills them: a label for the number called (a
flow claims numbers but names none of them), and whether the caller's identity is verified on a call from a trunk (no trunk is
configured as part of a trust domain, so a P-Asserted-Identity from one is the carrier's word and nothing
more; on a call an S-CSCF handed over,
caller.assertedis that identity). Each can be added within the version when there is something true to send. - A context that cannot be read takes the block's unavailable port rather than handing the bot a brief without one, since a bot set to be told whose call it is was built to rely on it.
Transfer destinations¶
Where an organisation's voice bot may hand a caller on, and how the bot does it (see "A voice bot transfers the caller" below).
- Per organisation, because one operator bot serves every organisation:
GET/PUT /api/v1/settings/transfer-destinations(an administrator's; the write replaces the whole list, so it takes the deleting extractor and an operator acting as the organisation uses its own route instead), andGET/PUT /api/v1/operator/organisations/{id}/transfer-destinationsat the operator address, withorganisations:read/organisations:writetokens, so a provisioning system can set them from its own records. Every write lands in the organisation's own audit log (transfer-destinations.replaced, the names and modes, never a target). - A destination is
{name, description, target, modes}.nameis 1-64 lowercase letters, digits,-and_, unique within the organisation: what the model chooses.descriptionis one line of up to 500 characters: what the model is told it is for.targetis one of{"extension": "201"},{"number": "+15550100"}(digits, an optional+),{"ring_group": ["201", "202"]}(rung together) or{"queue": "<id>"}, each checked against the organisation's own extensions and queues on every write.modesis a non-empty set ofcold,warmandrefer, kept in that order. At most 50 destinations. - What holds a target in place: deleting an extension or a queue a destination leads to is refused while it does, and a write that leaves out a destination a flow's voice block names (draft or live) is refused.
allow_any_numberis the organisation's, off by default. The operator can forbid it for every organisation (GET/PUT /api/v1/operator/transfer-policy,organisations_may_allow_any_number, session only, audited in the deployment's log). While forbidden an organisation cannot turn it on (409any_number_not_allowed), and one that had it on keeps it stored and is told it is off, as an organisation's own bots are simply not used while the operator lets organisations use only its own.- A voice block may narrow its bot to some of the organisation's names (
destinationsonvoice_botandvoice_menu). Absent is every one, including any added later; an empty list is none. A name the organisation does not list, or one named twice, is refused at publish. - A brief offers every mode a destination lists, warm included. A warm transfer consults one person, so a
destination ringing several extensions may not list
warm(refused at the write, and again at the call if a row ever says otherwise): a brief is a promise, and nothing is offered that the call then refuses. - The hold prompt (
hold_prompt, migration 0082, a column ontenantskeyed with the organisation as a mailbox greeting is) is one of the organisation's own prompts, played to the caller while its bot consults. Unset is silence. A prompt it names cannot be deleted under it.
Announcement endpoints¶
An organisation's announcement endpoint (/api/v1/announcement-endpoints) is an https address a remote
announcement asks, per call, for the audio to play. It is modelled on a voice bot: a name, the address, an
signing secret and a context (none, organisation or full, default full, with context_sends
saying what the setting sends).
- Requests are signed, with a secret the PBX makes.
X-Siphon-Timestamp(Unix seconds) andX-Siphon-Signaturecarry the lowercase hex HMAC-SHA256 oftimestamp + "." + bodyover the exact bytes sent, keyed by the secret's UTF-8 bytes:recording_delivery::sign, the scheme a recording upload uses, so one receiver verifies both. There is no bearer token. The secret is 32 random bytes as hex, sealed under the master key to its own row and column (a deployment with no master key refuses to make one), and shown once assigning_secretin the answer to the create or toPOST /announcement-endpoints/{id}/signing-secret(rotation, audited asannouncement_endpoint.rotate_signing_secret, the old secret stops verifying). Every other answer says onlyhas_signing_secret, and a change never touches it. An operator acting as the organisation can neither make one nor move an endpoint that holds one. An endpoint that predates signing has none (migration 90 dropped the token, a contracting change) and is never called unsigned: a call's block takesunavailablewith an error naming the call, the endpoint and its host, and the test says it needs a signing secret, until one is rotated for it. - The address is https with no user name or password, checked on save and again on every request. Where it
may point is the operator's: every request is screened against
remote_announcementsin the YAML configuration (allow_private_networks, default false, andtrust_anchors_file), built once at start. POST /announcement-endpoints/{id}/testsends one real request under that policy, with atest-call id and the organisation as context at the endpoint's level, checks the bytes the way a call does (a WAV through the prompt normaliser, an Ogg Opus file decoded to a WAV), and answers200 {ok, status_code?, duration_ms?, sample_rate?, channels?, error?}.errornames the host at most, never the signing secret or the whole address.
The remote announcement block¶
A remote_announcement block ({ endpoint }, family prompts, not instant) answers the call as an announcement
does, asks the named endpoint for audio, and plays it. Ports: next when the audio played to the end, and
unavailable for anything else, which a flow must wire. The endpoint is named by id and read for the call's own
organisation when the call reaches the block, so one deleted since the call began takes unavailable.
- What leaves the machine: one signed HTTPS POST per call to the endpoint:
{call_id, context?}.call_idis the SIP Call-ID.contextis built exactly as a voice bot's is, at the endpoint's own level (noneleaves the key out entirely and reads nothing;organisationis the organisation alone;fulladds the number called, the caller and the direction, and a withheld caller stays withheld), but without the organisation's transfer destinations, since an endpoint transfers nobody. No call audio is sent. - What comes back is a WAV or an Ogg Opus file, told apart by its bytes and never by its
Content-Type(the request saysAccept: audio/wav, audio/ogg). A WAV goes through the normaliser an uploaded prompt goes through. An Ogg Opus file must be one Opus stream (Vorbis, FLAC, a chained or multiplexed file and channel mapping other than family 0 are refused); it is decoded in the controller by siphon-rtp's pure-Rust RFC 6716 decoder (the codec crate only, linked for this: the control plane is still the only interface to siphon-sip), with the pre-skip and the end trimmed by the final granule position (RFC 7845 section 4), stereo folded to mono, at 48 kHz and no resampling, and written as the same kind of WAV a prompt is, because the media engine plays WAV only. The limit is a prompt's: a stream whose own length says its WAV would pass 20 MiB (about 3.6 minutes) is refused before it is decoded, and decoding stops if it would pass it anyway. Either way it is played from a file of its own underremote/in the prompt store. The file belongs to the call: it is removed when the next remote announcement is asked for and when the call ends, and files a crashed controller left are swept at start once they are an hour old. - Every failure takes
unavailableand logs an error with the SIP Call-ID, the endpoint id and the error, which names the host at most: the endpoint deleted, its signing secret not opening or never made, an address the operator's policy refuses, TLS, the 5 second deadline, a status other than 200, an empty body, something that is neither a WAV nor Ogg Opus (an Ogg Vorbis file, a corrupt or cut short Ogg file), audio over the prompt ceiling, the file not writable, the media engine refusing it. A call is never left waiting. - Deleting an endpoint is refused while a draft or live flow names it, as for a prompt or a voice bot.
The simulator takes a scenario's
remote_announcement({answer: "plays", duration_ms}or{answer: "unavailable", reason}; nothing said is an endpoint that does not answer).
The go-to-flow block¶
A go_to_flow block ({ flow }, family routing, not instant) hands the call to another flow of the same
organisation, which carries on from its entry. It exists to split a big flow (languages, departments) into
smaller ones. The only port is unavailable, which a flow must wire: the target was deleted, has no live
version, has no entry, or turned out to go the other way.
- The target is its live version, read when the call reaches the block and pinned from then on: a flow
published a moment later does not change what an answered call does. The executor emits
GoToFlow {flow}and is answered withFlowLoaded {flow, version, document}orFlowUnavailable {reason}; the live adapter reads the document for the call's own organisation (LiveFlows::live_flow), so another organisation's flow id is a flow that does not exist. The call keeps its directory, its variables and everything it has already done (answered, rung, played); the target's inbound block passes through as it does at the start of a call. - Same direction only. The validator refuses a target that does not exist (
unknown_flow), goes the other way (wrong_flow_direction) or is the flow itself (goes_to_itself, which needs the flow's id and so is checked wherever the flow has one: publish, make live, the validate endpoint'sflow_id). A target with no live version is a warning (flow_not_live). The executor checks direction again on load, because a flow can change after another was published against it. - Loops between flows are cut. One flow's cycles are the validator's; flows handing a call back and forth
are not visible to it, so a call may be handed over at most 16 times (
MAX_FLOW_HANDOFFS). The next hand-over ends the call as a flow error naming the block, logged with the call's flow and version. - An inbound flow that claims no number now publishes with a
no_numberswarning ("reached only from other flows") instead of an error, since a go-to-flow block is how a call reaches it. - The trace names where the call went. A
entered_flow {flow, version}line is written at the hand-over; lines after it, until the next one, name blocks of that flow, and a call never handed over has none, so records from before read as they did.calls.flow_id/flow_versionstay the flow the call entered. The call log reads each flow version the trace names and draws the path across them. - Following a hand-over is the routing's job too. The organisation's outbound flow, run for a call out
placed through the API or a transfer to a number outside, follows a hand-over exactly as a live call does
(
transfer_route), so an outbound flow split by destination routes the same either way. - Deleting a flow another flow's draft or live version names is refused (409), naming those flows. A flow naming only itself in its draft does not block its own deletion.
- Simulation loads the live version of every flow the simulated flow names, transitively, and nothing else
(
Scenario.flows); a flow not live is a target that is unavailable. The copilot's directory andlist_directorylist the organisation's flows (id, name, direction).
In the console and the flow designer¶
- Announcement endpoints is an administrator's page in the System section, beside Voice bots, built from the
same parts: a table (name, host, signing secret set or needed, what the endpoint is told), an add/change dialog with
the shared context picker, a New secret (or Make a secret) action that shows the secret once,
that prints the server's
context_sendssentence, and a Remove that shows the API's refusal when a flow still names the endpoint. Test calls/testand prints the outcome: what plays (length, rate, channels) or why it does not. It uses the public API only, and a write refreshes the directory so the designer's picker sees it at once. Its context catalogue is the voice bots' (/voice-bot-contexts). - The block's inspector is a picker over the organisation's endpoints, naming each by name and storing the id. A block naming none shows the empty option chosen, one naming an endpoint that is gone stays chosen and says so, and an organisation with none is sent to the page. The card shows the endpoint's name. The block sits in the prompts family with the announcement's icon and tint.
- The planning copilot is told the endpoints by id and name beside the voice bots, so it can draft a flow naming one. Never the address or the signing secret. Without the directory it is told it was not given them and writes a placeholder.
- The console's types are held to the server's JSON:
web/src/api/announcement-endpoints.fixture.jsonis written by a Rust test over the same serialisers the routes use, and the console's tests read that file.
A voice bot transfers the caller¶
POST /voice/sessions/{token}/transfer {destination | number, mode, summary}, authenticated exactly as a
report is (the session token, that session's bot's own secret; any miss is the same bare 404), and valid
only while the call is at the voice block the session was opened for.
- Answered once the transfer is settled, as a long request:
200 {outcome, reason?}withoutcomeone ofcompleted,declined,no_answer,busy,refused,failed. Held for at most 210 s, which clears the call's own bounds (a cold transfer rings at most 120 s, a REFER waits at most 60 s for a verdict, a warm one rings at most 120 s and then consults for at most 60 s, on one timer), so the verdict always arrives first; a bot's client has to allow that long. Every outcome butcompletedleaves the caller with the bot, which can say so and carry on. 403 {reason, message}when it is not allowed, with nothing placed:unknown_destination(not listed, or outside the block's subset, worded the same),mode_not_allowed,any_number_not_allowed,not_a_number,outbound_flow_refuses/no_outbound_flow(a number the organisation's outbound flow will not place),call_limit(the organisation's cap on calls this PBX places, shared withPOST /api/v1/calls),queue_not_yet_supported(a queue is a block in a flow, and a destination draws no failover for it),not_referable(a REFER names one address; a ring of several has none),not_consultable(a warm transfer to a ring of several),transfer_under_wayandnot_on_a_consult(a consult's own bot asking to transfer).400 {reason: "bad_request"}for a body naming both or neither ofdestinationandnumber.- The check is the call actor's (
siphon_pbx_control::bot_transfer::authorise, pure), against the call's own organisation's destinations read when the bot asks, never against what the bot was told. A number goes throughtransfer_route::route_a_transfer_out, the organisation's own outbound flow, as a phone's transfer out does, so the trunk, the number shown and whether the number is called at all are the flow's. coldrings the destination beside the bot (RingBesideTheBot/DialOutBesideTheBot): a bridging dial with no ringback, so the caller goes on talking to the bot while it rings. siphon-sip takes the bot off the caller's leg as the bridge forms (its bridge plan detaches a takeover before it re-offers), so the bot's stream closes on the answer and on nothing else. The bot's deadline is called off while the transfer runs and restarts in full if it does not happen.refersends a REFER on the caller's own dialog (siphon-sip'sreferverb), naming the extension at the organisation's SIP domain or the number as atel:URI. Its verdict is theTransferCompleted/TransferFailedthat follows (RFC 3515's NOTIFY, read by siphon-sip): the far side refusing the REFER itself isrefused; a failure it reports after trying is read by its status. A completed REFER hangs this leg up, since the caller's side has placed the call itself.warmis consult, then connect, and every step of it is the executor's (TransferLeg::Consult), so the simulator runs it on its logical clock:- The bot is taken off the caller (
DetachVoiceBot) and the organisation's hold prompt loops on the caller's own anchor (PlayOnHold, siphon-sip'splay {repeat: "inf"}, the verb a queue's music uses). Never siphon-sip'sholdverb, which to 1.13 at least silenced the whole call both ways and sent no SIP, so it would have muted the music too. - The consult is placed (
PlaceConsult): anoriginateon the caller's own control connection, throughServices::placer, to the destination's extension at every phone registered for it ({aor}), or to a number through the first of the outbound flow's trunks that resolves, under the same cap a cold transfer to a number counts against. The engine dials the same bot when it answers, on a new consult session whose brief sayskind: consult, carries the asking bot'ssummaryand the caller facts its context setting allows, and no destinations. - The consult's bot reports
{outcome: "accept"}or{outcome: "decline", reason?}on its session's report route. Those two are taken on a consult only, and a consult takes nochoseand no transfer (SessionKind, checked inVoiceSessions::report, so a stranger learns nothing about what a session is for). - Accepted: the music stops, the consult's bot is detached from its leg, and the caller's channel is
bridged to the consult's (
bridge {with}, the caller the anchor so its recording and tee are re-applied). Both legs are this application's own channels, so siphon-sip'sReplacesgap does not arise. Only the join settles itcompleted: a bridge refused, or a destination that hangs up between its accept and the join, is a transfer that did not go through. - Anything else — declined, busy, nobody answered, the destination hanging up, its bot ending without a
verdict, the consult not placeable — hangs the consult up, stops the music and gives the caller back to
the bot on the session it already has (
ReattachVoiceBot, the same address, so the bot that asked carries on), and only then answers the bot. A bot whose pipeline ends with its socket must keep its transfer request open across the hold: it is answered on the HTTP request, not on the socket. - Bounded by one timer, the ring time plus
CONSULT_MS(60 s) from the moment the consult is placed. Its firing hangs the consult up and gives the caller back, so a caller is never left on hold with nothing driving the call. A caller who hangs up mid-consult has the consult hung up and the bot answeredfailed. - The record's
transferline carriesconsult {answered, accepted}, and the consult's leg is on the call's legs against the extension it rang. - The call leaves the block by
transferred, a port ofvoice_botandvoice_menuthat leads nowhere: the validator refuses a cable from it (transferred_port_connected) and an option namedtransferred, because a caller who was put through is no longer the flow's. The outcome istransferred {to, mode}. - Recorded on the call, every attempt including refused ones, as a
transfer {to, mode, verdict, reason?, consult?}line of its path, plus the legs a cold or warm transfer placed. - And in the organisation's audit log, one entry per attempt with the bot as the actor:
actor_kind: voice_bot, the bot's id, and its name as it was then (the organisation's own bot, or the operator's deployment bot; a bot of another organisation lends nothing, not even its name). The action istransfer.<verdict>(completed,refused,declined,busy,no_answer,failed), so one entry says both that it was asked for and what came of it, and a call that ends between "asked" and "settled" cannot leave half a pair. The subject is<to> (<mode>) on call <SIP Call-ID>[: <reason>], wheretois the destination's name or the number the bot asked for, never where a named destination leads. - Written in the one place a bot's transfer request is answered (
answer_a_transferin the call's actor): a refusal before anything was placed, and every settlement after, a caller hanging up mid-transfer included. On a task of its own, so a slow or refusing audit log never holds the call up or changes it; a failed write is anerror!and the call goes on. - Migration 0083 is contracting. It widens 0009's
actor_kindCHECK, and the release before it reads an unknown kind asError::Corrupt, failing the whole audit page on one such entry (the reason 0044 and 0062 declined to add a kind). Rolling back below 83 is a dump restore. A bot is anActorKind, never anaudit::Actor: it changes no configuration, so it has no say in what an account may change. - A call placed through the API (
destination.voice_bot) is driven byoriginate.rsuntil its far end answers, and from then on by the same actor and executor as a call that rang in:actor::run_adoptedruns a flow made for it (an outbound entry, one voice block on the bot that holds the call, and a hang-up after it), with the bot's session and its reports taken over rather than opened again, since the engine already dialled the bot on the originate. A bot on it therefore transfers (cold, warm, REFER) and places a call back by the one implementation, under the same checks, with the same rows in the call's record and the audit log. The block names no destinations, which is every one the organisation lists (None, where an empty subset is none); the control follows the call to its new handle if the control connection drops and hands it back (reattachable.rs).Chose,Finishedand a failed conversation hang the call up as before; a conversation that reaches the longest a bot may hold a call is now a failure of the bot (the block's own deadline) rather than an ordinary end.
A voice bot places a call back¶
POST /voice/sessions/{token}/originate {destination | number, instructions}: the bot, on a caller's call,
asks the PBX to place a new call ("I will call them for you"). Authenticated exactly as a report and a transfer
are (the session token and that session's bot's own secret; any miss, and a session that is no longer live, is
the same bare 404). Answered at once, never held open, and the call it was asked from is untouched
whichever way it is answered: nothing is sent to it.
- Authorised by the transfer's own check,
bot_transfer::authorise, in the call's actor, against the organisation's destinations read when the bot asks and the voice block's subset of them, and a number againstallow_any_numberand the organisation's outbound flow (bot_transfer::route_a_number_out, the one function a transfer to a number uses too). It asks for the modecold: a callback is a call the PBX places itself through the organisation's trunks, which is whatcoldalready says an administrator allows for a destination, and the model has no mode of its own for it. So a destination that lists onlywarmorrefermay not be rung back, and one that is an extension, a ring or a queue is refusednot_a_numberbecause the originator calls a number out. The emergency services are refused whatever the flow says. - Placed by the one originator the API places calls with (
Originate::place), so the same limits count it (five at once and twenty a minute by default, shared withPOST /api/v1/callsand with a bot's transfer to a number). The new call is adestination.voice_botcall of the same bot, withinstructionsas its brief's instructions and the organisation's destinations in its context as any API-placed bot call has them, on a voice session of its own. A call placed through the API asks for a call back and for a transfer the same way a call that rang in does. - Answers:
202 {placed: <call id>}, the id the new call's record is written under.403 {refused, message}for what the organisation does not allow (unknown_destination,mode_not_allowed,any_number_not_allowed,not_a_number,outbound_flow_refuses,no_outbound_flow,emergency_number,not_on_a_consult), as the transfer route answers403.429 {refused: at_capacity | rate_limited, retry_after_secs}withRetry-After, asPOST /api/v1/callsanswers its limits.422 {refused: invalid}for a body that cannot be read (both or neither ofdestinationandnumber, instructions over the longest a block may give).503 {refused}where this PBX cannot place a call just now. The route is the bot's and is not in the OpenAPI document, as the other session routes are not. - Recorded: the new call's record is written under that id as a call placed through the API, with no token
and the name
voice bot on call <SIP Call-ID of the call that asked>, and its path opens with a note naming the call. The calls table has no parent-call column, so that name and the note are the link. The organisation's audit log has one entry per request with the bot as the actor:call.originatedfor one that was placed andcall.originate_refusedfor one that was not, subject<name or number> asked by the voice bot on call <SIP Call-ID>[: <reason>], never where a named destination leads.
TURN for browser phones¶
A browser behind a network that blocks UDP media needs a relay, and siphon-rtp ships one. The turn compose layer
starts it (--turn-udp and --turn-tcp on 3478, --turn-relay-ip the advertised media address, never
--turn-permit-private-peers) and points siphon-pbx and siphon-rtp at one secret file, turn_secret, which
init-secrets creates. Credentials are coturn's REST profile: the username is <unix expiry>:<tag> and the
credential is the standard base64 of the HMAC-SHA-1 of it under the secret (turn_credentials.rs). siphon-rtp keeps
no per-user state, so siphon-pbx mints them with an injected clock and nothing is stored. Both sides trim the secret
file the same way, so the HMACs agree.
Each node writes the URIs of its own relay (SIPHON_PBX_TURN_URIS) into instances.turn_uris with every heartbeat,
so a node that stops beating takes its URIs out of the answer with it. GET /api/v1/webrtc/ice-servers serves any
signed-in user: it reads the live nodes' lists, drops the duplicates and gives one iceServers entry per distinct
list under one credential tagged m-<user id>. Without a configured relay it answers an empty list. A relayed
candidate draws its port from the media window, so a relayed call takes more of it. turns: on 443 is served through the TLS
proxy on each organisation's own host (SIPHON_PBX_TURN_TLS): the node registers a placeholder URI that each answer
fills in with the host the browser opened its WebSocket on, and the render makes Caddy's 443 a layer4 server that
terminates the TLS with that host's certificate, sends a STUN stream (told by its first eight bytes) to siphon-rtp's
TURN TCP listener behind a PROXY v2 header naming the browser (siphon-rtp 0.30.3 reads it from the proxy address only), and everything else to the HTTPS site on loopback behind a PROXY v2
header. The turns-only layer starts no UDP listener and publishes nothing on 3478.
Web calls: a browser calling in on a single-use token¶
An organisation's website can let a visitor call into one of its flows without the visitor registering. The
organisation's backend asks for a web-call token (POST /api/v1/web-calls, scope calls:web; or the operator's
route) and hands it to the page, which opens a WebSocket to the organisation's hostname and calls
sip:web-call@<its SIP domain> with the token in X-Siphon-Web-Call-Token. The API contract is in
integrator-api.md; this is how the call path works.
- The token is the caller's whole standing.
web_call_tokenskeeps its SHA-256, the organisation, one target (a flow, entered at its live version, or a number whose flow it is), an optional marker and caller name, and a state:issued,usedwhile the call is up,releasedonce it is over. siphon-sip hands the INVITE's headers to the controller, so the header is read from the handover, only when it arrived overwsorwss(incoming.rs); over any other transport it is not read at all. - Spending it is one transaction (
web_calls::consume): the token's row is locked (two INVITEs presenting one token take turns), then the organisation's advisory lock, then the web calls it already has up are counted against its limit, then the target is checked to be live, and only then is the row updated. A call refused for the limit or an unpublished flow does not spend the token. The count is the table itself, so the limit holds across nodes. The organisation's disabled, geo and access-rule gates run first, for the organisation the token was issued to (FlowResolver::web_call, sharing the gate every number's call passes), and a refusal there spends nothing either. The INVITE's Request-URI domain has to be the token's organisation's SIP domain. - It never reaches number routing.
actor::runhands a call carrying a token toweb_call::serve, which runs the flow asCallerOrigin::WebCall: a browser's media profiles (ICE and DTLS-SRTP), not a registered client, so nothing reserved for one (a call out, a feature code, a transfer or a pickup) is open to it. The calls row keepsweb_call_idandweb_call_marker,sip_call_idis the browser's own Call-ID, and a voice bot's brief carriesweb_call {id, marker}at its top level, besidecontext(CONTEXT_VERSIONstays 1: an added optional field). - A token is released when the actor ends, whatever the way, so the concurrency count falls. The release is
retried (three attempts over four seconds, in the call's own task) and logs an error with the token and Call-ID
only when all three fail. What the actor cannot release is caught three ways, all by process, never by node
id: a spent token records the instance id of the process that spent it (
web_call_tokens.instance_id, the process's own row ininstances), beside the node id kept for display. Each process, each minute, releases its ownusedrows that no call in its live-call registry answers to (lost, counted onsiphon_pbx_web_calls_reconciled_total), skipping any row spent less than 60 s ago, which is the time a call needs to get from consuming its token to registering. A starting process, and the leader's sweep, release the rows whose process is no longer a live member (lostat startup,node_lostin the sweep), which for a crashed process is once its heartbeat has stopped for the liveness window. A row spent by a release that recorded no instance is judged by its node id, as before. Because of this, the old and the new release of a rolling upgrade can share a node id without the new one releasing the old one's live calls. - A node id is still one node's identity at the media engine and in the registrar, so two real nodes need
distinct
SIPHON_PBX_NODE_IDvalues. Sharing is allowed (an upgrade in place does it while the old release drains) but a process that has had another beating under its node id for longer than 15 minutes logs a warning namingSIPHON_PBX_NODE_IDevery minute and setssiphon_pbx_processes_sharing_node_id; a rolling upgrade drains and clears it, two misconfigured nodes would not. - Over WebSocket, only a registered browser or a valid token reaches a flow-claimed number. A browser that has not registered and presents no token is a stranger there, and is dropped like any other source with no relationship to an organisation. Carriers over UDP, TCP and TLS are unchanged: a DID is still theirs to call.
- Every B-leg a web call's flow places is built under
sip-trunk-edge@2026, which stripsX-*, so the token never crosses to a carrier or a phone.siphon_pbx_web_calls_refused_total{reason}counts every refusal.
Data¶
- Postgres holds configuration, flows and their versions, CDRs with path traces, voicemail metadata and the audit log. Every table carries the organisation a row belongs to, and references between rows are composite keys that include it, so the database itself refuses a row that names another organisation's data.
- No Redis. Live state (calls, queue positions, agent states, the event fan-out to connected UI sessions) is in the process, and the registrations each node holds are in Postgres, keyed by the node. siphon-sip can keep its own registrar in a Redis or Valkey outside the node; siphon-pbx renders that and never connects to it (see "siphon-sip's registrar on Redis or Valkey").
- Migrations are numbered SQL files embedded in the binary and applied in a transaction at start.
The database¶
siphon-pbx runs on one Postgres server in the compose stack, and on a highly available one (a primary and hot standbys, failover by promotion, often a managed service) with nothing but configuration.
A node that never runs Postgres. deploy/docker-compose.external-database.yml is the compose layer for
it: added after the layers the node uses, it puts the postgres service behind a profile nothing activates,
removes every depends_on: postgres, and requires SIPHON_PBX_DATABASE_URL instead of defaulting it to the
compose service. Its telephony and TLS halves (docker-compose.external-database-telephony.yml,
docker-compose.external-database-tls.yml) go with the layers they adjust; the telephony half also requires
SIPHON_PBX_SIP_CREDENTIALS_DATABASE, where siphon-sip reads credentials. The compose-only backup in
deploy/deploy-remote.sh and the psql steps in deploy/e2e assume the container and do not apply: back
the database up where it lives, or with pg_dump against the URL, and keep the master key with the dump.
Who sets up the roles. Two roles belong to the whole server rather than to siphon-pbx's database:
siphon_sip_auth, which may read the sip_credentials view and nothing else, and siphon_sip, the login
role siphon-sip's credential backend connects as, a member of it. Making or changing either takes
CREATEROLE. On a single box siphon-pbx's role is the database's superuser and siphon-pbx does all of it
at every start, as it always has. On a managed Postgres siphon-pbx's role is an ordinary one, so the
one-shot siphon-pbx init-database does it, connected with SIPHON_PBX_DATABASE_ADMIN_URL (compose runs
it before siphon-pbx when the init-database profile is active). siphon-pbx tells the two apart from the
server, not from a setting: it tries what it always did, and when the server refuses for want of
privilege it checks the roles are in place and carries on, or stops naming init-database when they are
not. It checks the same before migrating, so a missing role is never a bare "permission denied" out of
migration 8.
| Role | Needs | Granted by |
|---|---|---|
The admin role (SIPHON_PBX_DATABASE_ADMIN_URL) |
CREATEROLE; GRANT on siphon-pbx's database (its owner, or the managed service's administrator). Setting the runtime role's search_path needs ADMIN on that role; without it init-database says so and carries on |
the deployment |
siphon-pbx's role (SIPHON_PBX_DATABASE_URL) |
LOGIN; CONNECT, CREATE, TEMPORARY on the database, and nothing in public. Not CREATEROLE, not superuser: it makes and owns the schema siphon_pbx and everything in it, which is how it grants USAGE on the schema and SELECT on the view |
init-database (the role itself is the deployment's to create) |
siphon_sip_auth |
NOLOGIN; CONNECT on the database; USAGE on siphon_pbx and SELECT on siphon_pbx.sip_credentials |
init-database; the rest by migrations 8 and 106 |
siphon_sip |
LOGIN with the sip_auth_password secret; member of siphon_sip_auth |
init-database |
Where init-database sets the roles up, it also sets siphon_sip's password, so a rotated
sip_auth_password takes effect when it next runs (compose runs it on every up), not when siphon-pbx
restarts. Migration 8 creates siphon_sip_auth only when it is missing, so it runs as the ordinary role
once init-database has made it.
Where the tables are. Every table, view and sequence of siphon-pbx, the migration bookkeeping
included, is in the Postgres schema siphon_pbx, so the database can be shared with other applications
(Caddy's certificate storage keeps its own caddy schema beside it, and is never touched). Nothing is
created in public. Each connection the pool makes sets search_path = siphon_pbx itself, so the SQL
stays unqualified; init-database also sets the runtime role's to siphon_pbx, public where the server
lets it, which only matters to tools that connect as that role. siphon-sip's credential query names
siphon_pbx.sip_credentials outright, since its login role has no search path of ours.
The migration runner always names its bookkeeping table by schema. A database made by this release gets
the schema first and every migration runs in it. A database an earlier release migrated has everything in
public; its migrations run there as before until migration 106 moves the lot (metadata only, no row is
rewritten) and leaves one view, public.schema_migrations, over the moved bookkeeping. That view is what
makes a release from before the move, started by mistake against the upgraded database, find migration 106
with a compatible_from above what it knows and refuse, where it would otherwise find no bookkeeping,
conclude the database is empty and build every table again in public. A schema_migrations or any
other table that another application keeps in public is never mistaken for ours (the runner takes the
bookkeeping for ours only when it is a table with our columns holding migration 1, initial) and never
moved. Migration 106 is contracting: stop the older nodes first, as for any contracting migration.
Failover. SIPHON_PBX_DATABASE_URL names every server and asks for the primary,
postgresql://siphon_pbx@db-1:5432,db-2:5432/siphon_pbx?target_session_attrs=read-write, so every new
connection finds the primary at connect time. What a failover leaves behind is the connections already
pooled: to a primary that is gone, or one that is now a standby and refuses every write with SQLSTATE
25006 while staying open. The pool (db.rs) handles both in one place, beneath every query siphon-pbx
makes:
- a statement refused with 25006 runs again, once, on a fresh connection: the server refused it before it did anything, so nothing can happen twice;
- a statement that lost its connection runs again only when it is a read (a
SELECT,WITH,SHOWorVALUESnaming nothing that writes or locks). A write that lost its connection may have committed, so it fails, and the request with it; - a transaction begins
READ WRITE, which a standby refuses at once, so a pooled connection to a demoted primary is found before any of the transaction's writes and the transaction begins on a fresh connection instead. A transaction that loses its connection part-way fails: only the code that wrote it could run it again.
A connection that met a failover is never pooled again, and once one has, every other connection the pool
made before it is retired too. The operator console's System view shows which server siphon-pbx writes to
(as that server sees itself, inet_server_addr()) and how many statements it has retried. The one-shots,
init-telephony and init-proxy read the same SIPHON_PBX_DATABASE_URL, so they find the primary the same way.
siphon-sip's credential lookup is separate: it reads SIPHON_PBX_SIP_CREDENTIALS_DATABASE, one
host:port/database, which can be a standby, since it only reads.
TLS. A database reached over a network takes sslmode=require&channel_binding=require in its URL
(and in SIPHON_PBX_DATABASE_ADMIN_URL). sslmode=require makes every connection the pool, init-database
and the one-shots open use TLS (rustls, db/tls.rs), and verifies the server's certificate against the
roots and against the host connected to: libpq's verify-full, under the one name tokio-postgres accepts.
The roots are SIPHON_PBX_DATABASE_CA_FILE (a PEM file, several certificates allowed) for a private CA,
or the compiled-in web roots without it. channel_binding=require makes the password exchange
SCRAM-SHA-256-PLUS, which binds it to the certificate's tls-server-end-point hash (RFC 5929), so a
party in the middle holding some other valid certificate cannot relay the login. Every other sslmode,
the default prefer included, connects in plaintext and never asks the server for TLS, which is what the
compose stack, with its database on the network next to siphon-pbx, has always done. A CA file with no
sslmode=require beside it stops startup rather than being quietly ignored. Client certificates are not
supported. siphon-sip's credential lookup is separate and keeps its own settings.
Organisations¶
One siphon-pbx serves several organisations, each with its own configuration, flows, calls and people, and its own hostnames.
- Sites. Every API request is served for the site its host names: the operator address (the
host of
SIPHON_PBX_PUBLIC_URL), where operators create organisations and give them hostnames; one of an organisation's hostnames, where its people work; or neither, which is told nothing but that. The host is looked up on every request, so a hostname given or taken away counts at once on every instance. A reverse proxy must pass the Host header through. - Certificates. The TLS overlay's Caddy issues a certificate on demand, on a name's first visit,
and asks siphon-pbx before each issuance, on the internal listener next to
/metrics(/tls/allowed). Only the operator address and a hostname some organisation has are allowed, looked up live like the site, so a hostname given in the console is served over HTTPS without touching the proxy, and a name pointed at the machine by anyone else gets no certificate. - Accounts and sessions. Operators and an organisation's users are separate accounts, with separate sessions and cookies. An e-mail address is one account within an organisation and can have another in a second one. A user's session is found only on its own organisation's hostnames, an operator's only at the operator address. The Host header is not what enforces this: the session lookup filters on the organisation the host belongs to, so a session carried to another host is simply not there.
- Operators. All operators are equal. The first is created with the one-time code from the log; every later one is invited by an operator already there, through a link to the operator address that works once, for 48 hours, and only a hash of which is stored. Inviting an address again voids the earlier link, and an invite goes with the operator who issued it. Any operator removes another, never themselves; that refusal and a check that the remover still exists are taken under the same advisory lock as creating the first operator, so two operators removing each other at once leave one, never none. Removing an operator ends their sessions, and their second factor and passkeys go with them.
- External reference. An operator may give an organisation an identifier of their own systems'
(
PUT /api/v1/operator/organisations/{id}/external-ref, body{ "external_ref": "CUST-0042" }; the console's organisation page). Printable ASCII, 1 to 128 characters once trimmed, unique across the deployment (another organisation's is a 409), and recorded in the organisation's audit log against the operator. It is set once: the same value again changes nothing, and any other value ornullis a 409, because other systems find the organisation by it and a reference that moved would make that lookup name a different organisation. A voice bot set to be told whose call it is receives it. - Creating an organisation takes its dialling plan. The create body of
POST /api/v1/operator/organisationsis{ name, time_zone, dialling_plan }, wheredialling_planis the planPUT /api/v1/organisation/dialling-plantakes (country_code,national_prefix,international_prefix,emergency_numbers,premium_prefixes), and it is required: a body without one is a 422 namingdialling_plan, and one the plan check refuses is a 422invalidwhose message startsdialling_plan:, with nothing created. Without a plan an organisation cannot tell a number at home from one abroad, so a flow that diverts to or dials an E.164 number fails every call. The plan is stored with the organisation and recorded in its audit log beside the creation (organisation.dialling_plan_updated), and the organisation as the operator reads it carriesdialling_plan, which isnullonly for one created before this was required.GET /api/v1/operator/dialling-plans(theorganisations:readscope for a token) and, for an organisation,GET /api/v1/organisation/dialling-planslist a built-in plan per common country,{ code, name, plan, time_zones }, from one table insiphon_pbx_flow::countries; the console's create form starts from it and suggests the country from the time zone. Premium prefixes are left empty there. A plan is replaced, never removed.PUT /api/v1/organisation/dialling-planwith{ "plan": null }, or with noplan, is a 422invalidwhose message startsplan:, and the stored plan stays; another usable plan replaces it. Core has no call that clears one (organisation::set_dialling_plantakes a plan, not an option). An organisation created before a plan was required has none until it is given one this way. No database constraint backs this: a CHECK cannot compare a row with its previous value, andNOT NULLwould refuse those older rows. - The plan says how long an extension is, and a short number nobody owns is a wrong extension. The plan's
extension_digits(2 to 6, default 6, so a plan stored without it reads numbers as it always did) is the longest extension number. A bare number of two digits up to that length, not starting with0, classifies asinternal; a longer one is a number to dial. When one of an organisation's registered phones dials a number that classifies asinternaland nothing claimed it (no feature code, no emergency number, no flow, no extension),DatabaseResolver::is_a_wrong_extensionrefuses it 404 instead of letting it fall through to the outbound flow and a trunk. Settingextension_digitsbelow the length of an extension the organisation has is a 422 naming that extension. Creating an extension longer thanextension_digitsis a 422 naming the limit too, since its number would be read as a number to dial and could never be reached. - A trunk can carry extensions, for linking to another phone system.
trunks.carries_extensions(default off, refused on an inbound-only trunk) is the one relaxation of the wrong-extension rule. While any trunk of the organisation has it,is_a_wrong_extensionanswersfalse, so an unclaimed short number reaches the outbound flow. The flowDirectoryexposes it (trunk_carries_extensions), and the executor places a dial out or divert of aninternalnumber only over the named trunks that carry extensions, takingno_route(a divert: a flow error) when none does: the simulator and the live adapter share that one decision. - The operator sets an organisation's plan too.
GETandPUT /api/v1/operator/organisations/{id}/dialling-planread and write the same{ "plan": … }the organisation's own route does, refused the same way (oneDiallingPlanState::into_planreads the body for both, andorganisation::set_dialling_planchecks the plan for both, so a null plan is a 422 there too), for an operator session or a token withorganisations:read/organisations:write. It is recorded in the organisation's own audit log asorganisation.dialling_plan_updatedwith the country code as its subject,actor_kindoperator, and the token's name when one was used. This is how an organisation created before a plan was required gets one without the operator entering it. The console's organisation list flags one without a plan (dialling_plan: nullin the list), and its organisation page warns and edits it. When a voice bot set tofullis briefed on a call for such an organisation, siphon-pbx logs onewarn!per organisation per process naming it and saying the national number forms were left out; the call and the context are otherwise unchanged. - An emergency number is never an extension. A phone's dialled number is matched, in order, against
the organisation's feature codes, then a stored flow's number, then its own extensions (rung directly), and
only then handed to the outbound flow, whose
emergencyport is where112should go. So an extension numbered like an emergency number would take that call. Creating an extension (number) or the setup's range (extensions) is refused with a 422 when a number is one of the plan'semergency_numbers; setting a plan whose emergency numbers include an existing extension is refused naming the extension. Both checks run with the organisation's row locked, so a plan change and an extension created at the same moment cannot pass each other. Feature codes cannot collide: they start with*or#. - An organisation's own emergency number goes out before any claim. For a call from a registered phone,
an IMS line (originating) or a Teams user, a dialled number whose digits (a leading
+ignored) are one of the caller's own organisation'semergency_numbersis sent to that organisation's published outbound flow straight after the feature codes, beforeflows::live_for_numberand before its own extensions (DatabaseResolver::emergency_call_out). A number a flow claims is matched for every organisation's callers, so this is what stops a claim on 112 anywhere, including one published before publishing refused it, from taking another organisation's emergency calls. With no plan, a number the plan does not list, or no published outbound flow, the call routes as before (the last is logged as a warning). Publishing also refuses, asemergency_number_claimed, an inbound number that is 112, 911 or one of the organisation's own emergency numbers, and a block holding one of the latter; other countries' short numbers (100, 101, 110) stay claimable, since they are ordinary numbers for an organisation whose plan does not list them. A version already live with such a claim keeps it, but cannot be made live again. - Provisioning by reference.
PUT /api/v1/operator/organisations/by-ref/{external_ref}makes sure an organisation with that reference exists: it creates one (201) unless an organisation has it already, and then answers that organisation as it is (200) without reading the body any further than to check it. It never updates, so a provisioning system can send it on every run. The reference's unique index is what makes it race-safe: of two requests creating one reference, one commits and the other finds it.GET /api/v1/operator/organisations?external_ref=answers that one organisation, or[]. The body is the create body ofPOST /api/v1/operator/organisations, which may also carry the organisation's firsthostname, itssip_domainandims_domain, andinvite: { email, locale }; every part goes through the function its own route uses, in one transaction, so a part that fails creates nothing. The invite's link carries a token that is not kept, so it is in the 201 answer'sinvitationand nowhere else: not in a log, not in a 200 replay, and a replay issues no invite. An invite'slocalebecomes the administrator's own language when they accept it. After the organisation is deleted the reference is free, and the same request creates a new organisation. - Disabling and deleting.
POST /api/v1/operator/organisations/{id}/disableand/enableare idempotent and keep every row. A disabled organisation's calls are refused in the resolver, the one place every call comes out of naming the organisation it reached (and, for a registered phone, the one it is from):403 Forbidden, final, in both directions. A call already up is not torn down; a transfer out of it finds no outbound flow. Its hostnames are closed insite::resolve, which every request to them passes first, so a session, a sign-in, a passkey, an API token,/mcpand a provisioning link are all refused with403 organisation_disabled, and only/status(which saysdisabled: true) and the brand's files answer. REGISTER is not refused: siphon-sip's digest failures would score the office's address toward a ban that outlasts enabling it.DELETE /api/v1/operator/organisations/{id}deletes a disabled one through theON DELETE CASCADEevery organisation-scoped table has, and is a 409 naming them while it has a number, block or catch-all a flow claims, a trunk or an IMS line, or a call in progress. A call in progress is acapture_claimsrow from the last four hours with nocallsorcall_legsrow of its Call-ID (shared database, so every instance's calls count; an unrecorded call counts until it ages out, erring toward refusing), plus the originator's per-process count of calls placed through the API, which another instance's placed calls do not reach. The deletion is in the operator's audit log; the organisation's own goes with it. - Onboarding. An operator creates an organisation, gives it a hostname and issues an invite for its first administrator. The invite works once, for seven days, on the organisation's own hostname; only a hash of it is stored, and issuing another voids it.
- An organisation's people. An organisation has several users, each an administrator or a
member. An administrator adds somebody through a one-time link to the organisation's own hostname
(
/join?invite=), shown once and emailed when a mail server is set up (see Invites by email), working once for seven days, stored only as a hash; inviting the same address again voids the earlier link. An administrator sets the organisation up; a member reaches the voicemail of the extensions they hold and of the shared mailboxes an administrator gives them, their own calls, and their own account, nothing else. An extension has at most one holder and a user may hold several. The organisation always keeps an administrator: a role change or a removal that would take the last one away is refused, counted under an advisory lock of the organisation's own, and the one asking is checked to still be an administrator under the same lock, so two administrators demoting each other at once leave one. Removing a user ends their sessions and leaves the extensions they held in place, held by nobody. - The organisation's numbers. The numbers an organisation owns are a list of their own
(
organisation_numbers, migration 100), one entry per number or per block of consecutive numbers, held as the span modelflow_number_rangesuses (7 to 15 digits, none starting with0, an exclusion constraint so no number is held twice on the system), each with an optional label and an optional trunk.GETandPOST /trunks/numbers,PUT(assign to a trunk or none) andDELETE /trunks/numbers/{id}are the Trunks section's;GET /directorycarries the numbers alone for a member holding onlyflows. The migration backfills the list from what the flows claim, assigned to the organisation's only trunk when it has exactly one. A flow may claim only numbers in the list: the shared validator saysnumber_not_owned(so the editor, the simulator and the copilot agree) andclaim_numberschecks again inside the publish's transaction. A number the list cannot hold (under 7 digits, or a leading0) is not held to it. Removing an entry is refused while a live flow claims a number in it or an extension shows one as its caller ID; deleting an organisation is refused while it still owns numbers. - A trunk's number to present.
PUT /trunks/{id}/presented-numbernames one of the numbers assigned to the trunk, refused otherwise. A dial-out block whose caller ID is "the trunk's own number" then presents it, in theFromand asserted beside it exactly as a fixed number is; a trunk with none leaves the number to its carrier, as before. Taking the number from the trunk (reassigning or removing its entry) clears the setting in the same transaction and records that in the audit log. - An extension's outbound caller ID. An extension may be given one of the organisation's own numbers
(
PUT /extensions/{number}/outbound-caller-id), refused unless the number is in the organisation's list (whether or not a flow claims it). A dial-out block that shows "whoever is calling" presents that number, in theFromand asserted beside it, for a call placed by one of the organisation's extensions; an extension with none presents the trunk's own number (the one the trunk is set to present, when it has one), never the bare extension. A call a carrier delivered and a flow sends back out, and a diverted call, keep presenting the original caller. The number reaches the call through the directory snapshot the call runs against, which holds it only while the organisation still owns it, so a number given up, or handed to another organisation, is not presented from then on. - An extension's own outbound flow. An extension may name an outbound flow of its organisation
(
PUT /extensions/{number}/outbound-flow, a composite key so never another organisation's, an inbound flow refused) that runs for its calls out in place oftenants.outbound_flow_id; a restricted flow (a Destination block sending international to Reject) is how "no international for this extension" is said, so there is no second rules engine.organisation::outbound_flow_forpicks the extension's flow, else the organisation's, for a registered phone, a bound Teams user, an IMS line, a call the API places from an extension, and a transfer out that an extension asked for; a flow-initiated or voice-bot transfer has no extension and keeps the organisation's. A named flow that was never published refuses the call, never falls back, since that would lift the restriction. An emergency number takes the organisation's flow whoever dials it, so a restriction cannot stand between a caller and the emergency services. Deleting the flow nulls the column (ON DELETE SET NULL), as it does for the organisation's own setting. - Registration off for an extension.
extensions.registration_allowed(default true) is set withPUT /extensions/{number}/registration. Thesip_credentialsview, which siphon-sip authenticates a REGISTER against, leaves out the credential of an extension with it off, so the phone is challenged and refused; the credential row stays, so switching it on restores the same password. The write records a credential change withdrops_registrationset, so every node flushes siphon-sip's cached hash and then removes the bindings its own siphon-sip holds for the extension (the admin API's registrations list, then a DELETE of each address of record by the key the registrar printed): a registrar is a node's own, and so is the drop. A node that could not say what changed does not guess and lets the binding lapse. Independently of that drop, the readers ofextension_registrations(the ring's address and targets, the connection a call is tied to, the registrations list and so the directory snapshot's available/unavailable state) leave an extension with registration off out, so a binding that outlives the switch counts for nothing and the extension is simply unavailable to a flow. - An IMS line's diversions as a simservs document (
simservs::store, migration 0118). The document is never stored: it is rendered from the forward columns on each request, andsimservs_rules/simservs_serviceskeep only what a client wrote that a column cannot say (rule ids, targets as written, a rule or the service switched off), believed only while the column agrees, so a console or feature-code change renders canonically. A request is one transaction with the extension row locked: render, ETag (hex SHA-256), preconditions, apply, write, re-render and compare canonically with what was put (any difference is a 409 and a rollback). A target that is a colleague's IMS line becomes that extension. - A default caller ID restriction, per extension (TS 24.607 OIR, migration 0119).
extensions.withhold_caller_id, set byextensions::set_withhold_caller_id(console and API,PUT /extensions/{number}/withhold-caller-id, an audit row when it changes; an administrator for any extension, a member for the ones they hold) and by an XCAP client asdefault-behaviouroforiginating-identity-presentation-restriction(presentation-restrictedis on,presentation-not-restrictedoff, both ways; the service switched off withactive="false"is a 409, because no column holds it). It is folded into the one fact every leg reads. After the call resolves, a call the extension places (a registered phone's, a Teams user's, an IMS line's originating session; not an IMS terminating session) is treated ascaller_withheldunless its INVITE carriesPrivacy: none(call_context::presents, TS 24.607 temporary presentation) or the number dialled is one of the organisation's emergency numbers, which always present. Every leg builder then does what it does for a caller who asked per call: an anonymous From andPrivacy: id, the real identity kept asserted for the trust domain, and the call's record sayscaller_withheld. A caller who asked per call (Privacy: id, an anonymous From) stays withheld whatever the default, and an emergency call that asks to be withheld is the caller's own request and is left as asked. The setting reaches the call through the directory snapshot (withholds_caller_id), beside do-not-disturb. - Anonymous communication rejection, per extension (TS 24.611 ACR, migration 0120).
extensions.reject_anonymous, set byextensions::set_reject_anonymous(console and API,PUT /extensions/{number}/reject-anonymous, an audit row when it changes; an administrator for any extension, a member for the ones they hold) and by an XCAP client as anincoming-communication-barringrule with the one condition<anonymous/>(and optionally<rule-deactivated/>) and the one action<allow>false</allow>, both ways. Any other incoming barring rule, and all outgoing barring, stays a 409cannot-insertwith its phrase. The rule id, a deactivated rule and the service switched off (active="false") are kept insimservs_barringand believed only while the column agrees; a column changed from the console renders the rule with the idacr. The canonical compare of every write is unchanged, so nothing is accepted and then ignored. The refusal is the flow executor's, so the simulator and a live call cannot differ. A call whose caller withheld their identity (call_context::withheld, after the calling extension's own default is folded in) that would ring an extension which rejects anonymous callers endsCommand::Hangup { AnonymityDisallowed }withOutcome::AnonymousRejected, answered433 Anonymity Disallowed(RFC 5079) before anything is rung, a mailbox taken or a forward read, so an anonymous call to a forward-always or do-not-disturb extension is refused and not forwarded or sent to voicemail. It is read inring_one_extension(the one place a call placed to an extension is read: a direct dial, a terminating IMS call, a claimed number, a Ring extension block) and where a forward lands on an extension, so a forward chain ending at one is refused there. A ring group skips that member only and rings the rest (all of them rejecting takes the group'sunavailableport); a queue is not read. No exemption applies on the terminating side (an emergency callback that withholds its number is refused like any other anonymous call; the setting is the extension's own). A call a flow already answered (an announcement or menu first) has no response left to refuse with and is ended with a BYE as any other ending is. The setting reaches the call through the directory snapshot (extension_rejects_anonymous). - Do-not-disturb and forwards, per extension.
extensions.do_not_disturbandforward_always,forward_busy,forward_no_answerwithforward_no_answer_seconds(5 to 180, default 20; migration 0096, widened by 0118). A forward's target is one text value, an extension number of the same organisation or a number outside in international form (+and 6 to 15 digits); the two cannot be mistaken for each other, and the shape is aCHECKas well as validated where it is set.extensions::set_do_not_disturbandextensions::set_forwardingare one core call each (so a feature code can set them from the phone); the latter refuses an emergency number (on what was typed, before its shape), the extension itself and an extension that is not the organisation's, locking the targetFOR SHARE, andextensions::deleteholds back an extension another forwards to. The directory snapshot carries both beside the registration:extension_statereads do-not-disturb as unavailable for every reader, andextension_do_not_disturblets a ring of one extension tell it from "not registered". The executor is the one place a forward is read (ring_one_extensionandforwardinsiphon-pbx-flow), for a call placed to one extension, so a direct dial, a Ring extension block and the simulator behave alike: do-not-disturb takes the block'sunavailableport without ringing; a forward of every call diverts at once; otherwise the phone rings (for its no-answer time when it has a no-answer forward) and busy, no answer and unreachable (the no-answer forward too, with reasonunavailable) divert. A divert is the sameCommand::Diverta Divert block issues, so the live adapter builds the sameDiversionandHistory-Info, naming the forwarding extension; to a number it goes out through the organisation's outbound-capable trunks in name order (forwarding_trunks), shown as the caller (or, for a caller that is one of our extensions, as that extension's outbound caller ID, else the trunk's own number). An extension reached by a forward applies its own settings in turn, bounded byMAX_FORWARD_HOPS(5), after which the call leaves by the port the refused forward answers (busy, no answer, else unavailable). A call whose forward fails leaves by the ring block's ports, and the mailbox it falls to is the dialled extension's. Ring groups drop a do-not-disturb member and ignore forwards; queues see do-not-disturb as unavailable. A member may set both for the extensions they hold (MembersToo,extensions::ensure_visible), andGET /extensionsshows a member only those. - Default-deny, by type. Who reaches a handler is decided by the extractor it takes
(
crates/siphon-pbx-api/src/session.rs). Every organisation extractor refuses a member with 403 (admin_only, orsection_requiredwhere a permission group could grant it), so a handler, including one added later, is an administrator's unless its extractor is wrapped inMembersToo. The handlers about the signed-in account's own way in takeSignedIn, which admits either role. A handler opted in reads through aViewer(access.rs): everything for an administrator or an operator acting as the organisation, only their own for a member, and the filter is in the SQL of the core query, next to what it guards. The member routes today are listing mailboxes, listing a mailbox's messages, playing one and deleting one, listing calls and reading a call's transcript; a mailbox, call or transcript the member may not see is answered 404, exactly as one that does not exist. - What is a member's. Ownership is who holds an extension now, read on every request, so handing an extension over hands over its mailbox and its call history with it. A member sees:
- the mailbox of every extension they hold, and every shared mailbox (one with no extension) an
administrator gave them (
mailbox_members). A personal mailbox takes no members, refused where members are set and ignored by the read, so there is one answer to whose it is; - a call their extension placed (
calls.caller_extension, settled from the connection the INVITE arrived on and only for the resolved organisation's own phone, never from theFrom), a call a leg of which rang one of their extensions (call_legs.extension_number), and a call that ended in a mailbox they may see. A call that rang them and that none of their phones answered is markedmissed; - of those, what was said (transcript and summary) only where the conversation was theirs: they placed the call, their phone answered it (read from the legs, never from the call's outcome, which names the first phone rung when the control plane did not say who answered), or it ended in a mailbox they may see. A ring-group member who only rang gets 404 for the transcript;
- only the legs that rang their own extensions, since a leg to somebody else's phone names where it is.
- Permission groups: letting a member manage part of the console. A member can be given console
sections beyond what is theirs, without being made an administrator. A group
(
permission_groups,permission_group_members, migration 98) names a set of sections and has members; a member holds the union of their groups' sections, read afresh on every request so a change to a group applies to the next one. An administrator holds every section already, so being in a group gives them nothing. Groups, not individual grants, are the unit so that mapping an identity provider's groups onto them later needs no new concept. - Sections (
siphon_pbx_core::permissions::Section, the names in the CHECK on the table):flows(flows, simulator, copilot, and the read-only/directorythe designer picks from),schedules(schedules, toggles),prompts,queues,extensions(extensions, credentials, provisioning links, registrations),mailboxes(every mailbox and its messages, not only the member's own),calls(every call in the call log, its path trace and transcript, not only the member's own),recordings(every recording: list, play, download, delete; a transcript lives with its call, so it followscalls),feature_codes,trunks,settings(organisation settings, languages, dialling plan, outbound flow, mail server, version information),integrations(Teams, transfer destinations) anddata_sharing(where caller data and audio can go: AI providers, the transcriber, recording delivery, announcement endpoints and voice bots, whose address is where a live call's audio is streamed).data_sharingis its own section so that managing flows or trunks never carries the power to point recordings or transcripts at an address of the member's choosing. flowsimplies one read, not many. A designer needs the names of prompts, queues, trunks and so on, which sit behind other sections.GET /api/v1/directoryanswers with ids, names and the few figures a block's card shows (opening hours in words, who staffs a queue), gated onflows, with no setting, address or secret. The per-resource lists stay closed toflows.- Never grantable (an
admin_onlyroute, no name in the list, refused by the database too): users, invitations and roles, the permission groups themselves, API tokens, the organisation's access rules, the audit log and packet captures. A grant over any of them is a way to become an administrator, or to undo the record of having done so. - Named at compile time. Every organisation extractor takes a marker from
crates/siphon-pbx-api/src/section.rs(Acting<section::Flows>,Destroying<section::Trunks>,HandlingASecret<section::Extensions>, orsection::AdminOnly), with no default, so a handler cannot be written without saying which section it belongs to; that file's table is the full route mapping.admitinsession.rsis still the one place a member is kept out: an administrator or an operator acting as the organisation passes, a member passes only a grantable section one of their groups grants, and is otherwise answered 403section_required(grantable, not held) oradmin_only(never grantable). - Widening, not opening. A member always reaches their own mailboxes and calls. With the
mailboxesorcallssection the same routes read throughViewer::for_user_in, which returns everything of that section instead of their own; the filter stays in the core query. - Secrets. A member granted a section may handle the secrets in it (a trunk's password, a phone's SIP
password with
extensions, an AI key withdata_sharing), as an administrator may: refusing them would make the grant decorative. An operator acting as the organisation is still refused them. - API.
/api/v1/permission-groups(list, create),/{id}(get, change name and sections, delete),/{id}/members(replace the members) and/permission-groups/sections, all an administrator's, each change in the audit log./sessioncarriesuser.sections: every section for an administrator. - Numbers. An inbound number leads to one flow on the whole system, so the number decides which organisation a call from a trunk belongs to, whatever hostnames the organisation has. A flow claims numbers three ways and a call takes the most specific claim that matches it: a number named outright, then a block of consecutive numbers, then the organisation's catch-all. The first two are keyed on the number alone and ordered in one query. The catch-all has no number to be keyed on, so the organisation is settled first, and only the trunk the call arrived over settles it: it is read for a call that came in over a trunk exactly one organisation has configured at that source, and for nothing else. A Request-URI host decides nothing, a shared or unresolved carrier address settles nothing, and a source with no relationship to any organisation is refused exactly as it was before — so a catch-all never widens who can reach an organisation, only which of its own numbers reach a flow.
- Blocks of numbers. Stored as the span of the numbers' own values, so both E.164 spellings of one
number land in the same block. An end may not start with
0, which is what makes a value name one number, and must be longer than any extension, so a block can never shadow the internal ring an extension resolves to. Two blocks may not hold the same number anywhere on the system: the overlap is refused when it is written, by a check that names the other flow and by an exclusion constraint behind it. A number named outright inside somebody's block is allowed and wins, because that is how a direct line inside a department's block is expressed. - Capture. A call's captured traffic belongs to the organisation whose flow took it (see capture above).
- An operator acting as an organisation. The console makes a one-time link into an organisation; it is
opened on that organisation's own hostname and exchanged there for a 30-minute session in a cookie of its
own. The session reads and changes the organisation as its own user would, and every change it makes is
recorded in that organisation's audit log against the operator, never against one of its users. Four
things are refused even so, each with its own error code: deleting anything, touching a credential or a
secret (which would outlive the session), opening a voicemail recording, a transcript or a summary, and
changing what a voice bot is told about the organisation's calls (
disclosure_in_a_view, decided in the core write against the bot's stored setting). Which handlers such a session can reach is decided by the extractor each one takes:Actingresolves either one of the organisation's administrators or an operator acting as it and says which, whileDestroying,HandlingASecretandReachingCallContentresolve the organisation's own administrator only. An operator acting as the organisation is never taken for a member: it reads what an administrator reads, and the carve-outs still apply on the routes a member is let into. A trunk, an AI provider and a voice bot are not carved out whole, because only part of each is a secret; those handlers takeActingand callActing::may_set_a_secretwhen the body they were sent really changes one. Link and session are both tied by foreign key to the operator session they were made in, so signing out of the console ends them.SECURITY.mdhas the rest.
Signing in through an identity provider¶
An organisation may let its people sign in through its own OpenID Connect provider, instead of or beside a
password and a passkey (siphon_pbx_core::identity_providers, oidc, jose; migration 99). No new crates:
the JWS and JWK handling is jose (RS256 and ES256 over ring, checked against RFC 7515 appendix A.2 and
A.3 and RFC 7517 appendix A), the protocol is oidc, and every request to a provider goes through
https::send like any other outbound call.
- One provider per organisation (
identity_providers), configured by an administrator and not grantable (AdminOnly; saving takes the organisation's own administrator, since the record decides where the stored client secret is sent). The issuer, the client id, a client secret sealed under the master key (bound to the organisation, write-only: the API sayshas_client_secret; none means a public client that proves itself by PKCE alone),methods,auto_create_users, the groups claim and the group mappings.GET/PUT/DELETE /api/v1/identity-provideris one document: a save replaces the mappings with it, and carries the redirect URI each hostname has to be registered under at the provider. A save fetches the provider's metadata first through the policy below and is refused, storing nothing, when it cannot be used. methodsispassword_and_passkey,oidcorall, an enum so that none of its values leaves nobody able to sign in. Withoidcthe password sign-in, a password change and the passkey sign-in answer 403sign_in_method_not_allowed; withpassword_and_passkeythe provider is configured but not offered.GET /api/v1/session/methods(no session) tells the sign-in page which to show. An account an identity provider made has no password (users.password_hashis nullable, which is why migration 99 is contracting), so no password opens it whatever the methods are. The console warns thatoidcalone locks everybody out when the provider is down and recommendsalluntil the provider is trusted.- The way back for an organisation locked out that way is the operator's, never the organisation's
(
identity_providers::allow_every_way_in):POST /api/v1/operator/organisations/{id}/sign-in-methods/reset(the button on the operator's organisation page;GET .../sign-in-methodssays what the page offers) andsiphon-pbx reset-sign-in-methods --organisation <hostname> --as <operator email>. Both setmethodsfromoidctoalland nothing else: the client secret and the mappings are neither read nor written, and an organisation onallorpassword_and_passkeyis left as it was, so the provider is never switched on where an administrator had it off. Each change is recorded in the organisation's audit log (identity_provider.sign_in_methods_reset) against the operator,--asnaming which; an organisation's own user is refused (the route is the operator site's), and the answer says whether anything changed. - The console. Settings has the administrator's Identity provider card (issuer, client id, write-only
secret, the redirect URIs to register, the ways in with the lock-out warning, account creation, groups claim,
administrator groups and the mapping editor; a refused save shows the server's reason), beside Access, which
is the other sign-in policy. The sign-in page reads
/session/methods: a button for the provider where it is offered (a navigation to/session/oidc/start, the primary action only where it is the one way in), no password or passkey where the organisation allows the provider only, and one sentence for eachoidc_errorcode. The Users page marks who is linked to the provider and which administrator role and permission groups it gave, asidentity_provider,admin_from_identity_providerandidentity_provider_groupsin the users API. - Where a provider may be is the operator's to say (
identity_providers.allow_private_networksandtrust_anchors_filein the YAML, the same two keys asremote_announcementsand a setting of their own). Every request (metadata, keys, token endpoint) is screened by it, redirects are not followed, and the default is public addresses only. - The ceremony.
GET /api/v1/session/oidc/start?return=/pathmakes a state, a nonce and a PKCE verifier (S256), keeps them server-side for ten minutes (oidc_sign_ins: the state and nonce as SHA-256 hashes, the verifier sealed to its row, so reading the table completes no sign-in), and redirects to the provider. At most 1000 wait per organisation. The ceremony records the hostname it started on and the callback must arrive on it: the redirect URI is that hostname's origin, so one registered at the provider per hostname. State lives in the database because the redirect back is cross-site and aSameSite=Strictcookie would not be sent with it.GET /api/v1/session/oidc/callbackends the ceremony first (it works once, whatever follows), exchanges the code (client_secret_basic, or client_secret_post when that is all the provider offers), verifies the ID token and starts the session; every outcome is a redirect, success to the return path (a path on the site and nothing else, otherwise/) with the cookie set, failure to/?oidc_error=<code>(oidc_expired,oidc_denied,oidc_failed,oidc_unavailable,oidc_not_allowed,oidc_no_account,oidc_unverified_email,oidc_email_missing,oidc_linked_elsewhere,oidc_busy) with the reason in the log. Both routes count against the sign-in throttle like a password sign-in. - The ID token is checked as OpenID Connect Core 3.1.3.7 says: the signature by a key of the provider's own
key set matching
kid(an unknownkidfetches the set again once; metadata and keys are otherwise kept ten minutes per organisation),algone of RS256 and ES256 (nevernone, never HMAC,critrefused),issthe exact issuer the metadata names (which must be the configured one),audholds the client andazpis the client where there are several audiences or where it is present,exp,iatandnbfwithin a 60 second skew andiatnot older than 15 minutes, andnoncethis sign-in's. The userinfo endpoint is not called: what is needed has to be in the token. - Who the token is. Linked by (issuer, subject) signs in. Otherwise an existing account with the same
address is linked, only when
email_verifiedis true; an account linked to another subject is refused. Otherwise, withauto_create_users, a member is created with no password. Otherwise it is refused. A disabled organisation signs nobody in this way. No authenticator-app code is asked for: the provider owns the person's authentication, multi-factor included. - Groups. On every sign-in the groups claim (an array of strings or one string) is mapped:
admin_groupsmake an administrator, and each mapping adds a permission group. What the provider gave is marked (permission_group_members.from_identity_provider,users.admin_from_identity_provider) and is all the next sign-in takes back; a membership or a role an administrator set by hand, a role confirmed by hand included, is never touched. The organisation's last administrator is never demoted: the demotion is refused, logged, and the sign-in goes on. When anything is mapped thegroupsscope is asked for as well. - Removing the provider keeps the accounts linked (putting the same provider back lets them in again) and ends the sign-ins waiting on it; an account with no password has no way in meanwhile.
Recordings across calls¶
A call is recorded where its flow has a Record step, and its audio is kept in call_recordings, one row per
part (bridging a second party replaces the media engine's session, so the recording carries on as a new
part). Each part is also a recording of its own, with an id, a source (own for a Record step;
siprec is reserved for sessions another PBX sends), a format (wav today; ogg_opus is what the engine
can also write) and a channel count read from the file.
GET /recordingslists an organisation's recordings across calls, newest first, a page at a time (limitup to 200, 50 by default), withfrom(inclusive) andto(exclusive) on when the recording started andsource. Each item carries its call: id, SIP Call-ID, caller, called number, direction, start, end and length. The page'snextis a cursor on(started_at, id), a position rather than an offset, so a recording stored or swept while somebody pages neither repeats nor skips one.GET /recordings/{id}is one recording and its call;GET /recordings/{id}/audioits bytes, served asaudio/wavoraudio/ogg; codecs=opusby its format.GET /calls/{id}/recordingand/calls/{id}/recording/{position}keep working, and serve by format too.- Direction is worked out from the call's record, not stored: placed through the API, or by one of the
organisation's phones with a leg dialled to a URI as written (a carrier), is
outbound; one of its phones calling something that stayed inside the PBX isinternal; anything else isinbound. - The facts a call keeps for whoever receives its recording are on the call itself (
GET /calls, and the console's call detail), each null where a call recorded before they were kept has none, which is not a default: answered_at, the instant the caller was answered, taken from the one place every pass of the call's loop starts, so a sixth way of answering would not leave it unset;direction(inboundoroutbound), the direction of the flow the call entered. A different question from the recordings' derived direction above, which also tells an internal call apart;caller_withheld, from the INVITE'sPrivacyheader or an anonymous From;trunk_idfor a call that arrived over SIP: the one trunk of the organisation that owns its source address, settled by the resolution a voice bot's call context uses, and looked up when the call ends so it costs the caller nothing. The column is the one an API-placed call names its outgoing trunk in;originsays which it is, since a call cannot be both;ended_by:caller(a BYE or CANCEL while the call was with this PBX),bridged_party(a BYE on a call the caller was bridged onto a phone or carrier for),bot(the voice bot's report was the last thing the flow heard and it hung up on it),flow(this PBX ended it, or siphon-sip tore it down for a reason of its own) ortransfer(a bot's transfer took the caller out of the flow). siphon-sip reports every BYE asbyewhichever leg sent it, so a bridged call's two parties are not told apart;voice_bots, every bot the call was handed to in order, each{id, name, report}:nameis read when the record is written (null once the bot is gone), andreportischose(with the option),finished,failed(with the reason) ortransferred(with where and how), or null when the call left the bot without one. A block that found no bot to hand the call to is not a visit.- Who reads them is the call's own rule (
call_content_visible): an administrator everything, a member the recordings of calls whose content is theirs. An operator acting as the organisation reads the list and each recording's metadata, and is refused the audio (call_content_in_a_view), as a call's own recording audio is. - A program reads them with an organisation API token carrying
recordings:read, which reads every recording of that organisation: listing, by id and the audio. A request presentingAuthorizationis decided by it alone; a token without the scope is 403insufficient_scope, another organisation's or an unknown one 401, and one sent with anOrigin403. Likecalls:originate, no other scope implies it. - Retention (
SIPHON_PBX_RECORDING_RETENTION_DAYS) sweeps these same rows, so a swept recording leaves the list with its audio.
Operator tokens¶
A program, such as a provisioning system, works with the operator address through an operator token rather than a session. A token is issued on the console's API tokens page, or once from configuration management:
siphon-pbx operator-token issue --as operator@example.com \
--scope organisations:read --scope organisations:write --expires 90 --out /run/secrets/pbx-token
# the compose stack's one-shot, writing into SIPHON_PBX_OPERATOR_TOKEN_DIR:
SIPHON_PBX_OPERATOR_TOKEN_OPERATOR=operator@example.com \
SIPHON_PBX_OPERATOR_TOKEN_SCOPES=organisations:read,organisations:write \
docker compose run --rm operator-token
The command writes the token to a file it creates new with mode 0600, refuses an existing file, and never
prints the token; its last line names it by its last four characters. Made like an organisation's API token
(spbx_op_ and 64 hex characters, kept only as a SHA-256 and a four-character hint, 1 to 365 days, 90 by
default), it acts as the operator who issued it: sent as Authorization: Bearer <token>, it reaches the
same handlers through the same extractor (CurrentOperator) and gets the same answers the console does.
Removing an operator removes their tokens. Revoking one keeps it listed, marked, so a later use of it is
still recorded as that token's.
The machine-readable description of every route a token may use, with its parameters, bodies, errors and
scope, is GET /api/v1/openapi.json (OpenAPI 3.1, no token needed, kept in
crates/siphon-pbx-api/openapi/api.json). It also describes POST /api/v1/calls, which takes an organisation API
token (ORGANISATION_TOKEN_ROUTES holds that route and its scope). A test holds it to ROUTES both ways, to that table, to the request types
and to real answers; the table below is the summary.
Which route a token may use is one table, ROUTES in crates/siphon-pbx-api/src/operator_access.rs, looked
up by the route the request matched. A test reads the router's own source and fails on any /operator route
the table does not name, and a route missing from it is closed to tokens.
| Scope | Routes |
|---|---|
organisations:read |
GET /operator/organisations, GET /operator/organisations/{id}, GET …/{id}/ims-lines, GET …/{id}/access, GET …/{id}/dialling-plan, GET …/{id}/transfer-destinations, GET /operator/dialling-plans |
organisations:write |
POST /operator/organisations, PUT …/by-ref/{external_ref}, PUT …/{id}, DELETE …/{id}, …/{id}/disable, …/{id}/enable, hostnames, sip-domain, external-ref, dialling-plan, ims-domain, ims-pcscf, ims-lines/{extension}, DELETE …/{id}/access, PUT …/{id}/transfer-destinations, invite |
voice-bot:write |
GET/PUT/DELETE /operator/voice-bot, GET /operator/voice-bot-contexts, GET /operator/voice-bot-media, GET /operator/voice-bot-audio |
organisations:bots |
GET …/{id}/voice-bots, PUT …/{id}/voice-bots/by-name/{name}, DELETE …/{id}/voice-bots/{bot_id}: an organisation's OWN bots (voice_bots::put_by_name, the organisation route's create and update composed, with the scope's holder as SecretAuthority::Granted and a console session as ClosedInAView); a second bot of another name is a 409, so a voice block naming none keeps meaning the one bot; never the deployment's bot (voice-bot:write), never a flow |
trunks:read |
GET …/{id}/trunks, GET …/{id}/trunks/{trunk_id} |
trunks:write |
PUT …/{id}/trunks/by-name/{name}, DELETE …/{id}/trunks/{trunk_id} |
trunks:secrets |
no route of its own: checked beside trunks:write in the write, for a body that sets a password and for a change that moves, or clears the password of, a trunk that holds one |
extensions:read |
GET …/{id}/extensions, GET …/{id}/extensions/{number} |
extensions:write |
PUT/DELETE …/{id}/extensions/{number}, PUT …/{number}/registration, …/outbound-caller-id, …/outbound-flow, POST …/{number}/mailbox |
extensions:credentials |
POST/DELETE …/{id}/extensions/{number}/credential: a row's scope, and checked again in the write as a secret scope |
numbers:read |
GET …/{id}/owned-numbers (numbers::list, the organisation's own list), and GET …/{id}/numbers: every number, block and catch-all of the live flows, read from flow_numbers, flow_number_ranges and flow_catch_all |
numbers:write |
POST …/{id}/owned-numbers and DELETE …/{id}/owned-numbers/{entry} (numbers::add / numbers::remove, the functions behind /trunks/numbers), and PUT/DELETE …/{id}/numbers/{number} and …/{id}/number-ranges/{from}-{to}: flows::amend_inbound, one transaction that edits the flow's live version and publishes it through publish_in |
flows:write |
POST …/{id}/default-flow: new_organisation_flow::apply_to_existing, the new-organisation flow made for one that exists |
| no token, ever | the operator's own session and account, the other operators, the tokens themselves, …/{id}/view, the mail server, the brand, the transfer policy, the System view, the audit log, the captures |
IMS routes take the organisations scopes: they are how the operator sets an organisation up, like its SIP
domain. A number leads to a flow because the flow's inbound block claims it, so the numbers scopes change a flow:
flows::amend_inbound reads the flow's row under a lock, edits the inbound block of its live version, writes
that as the draft and publishes it with publish_in, which validates it and claims its numbers, all in one
transaction. It refuses with 409 draft_pending when the draft differs from the live version, so an
administrator's unpublished edit is never published or overwritten, and answers a number the live version already
names without writing. No scope reads a flow's blocks: there is no operator flows:read. On an
organisation's own hostname a token is nobody: those routes resolve who is asking from the organisation's
sessions only, so a token reads none of its calls, recordings, transcripts or voicemail there. A token
reaches an organisation's secrets never, unless it carries a secret scope (trunks:secrets and
extensions:credentials): the API layer turns how the request was authenticated into a SecretAuthority (Granted for the
organisation's own users and for a token holding the scope, ClosedInAView for an operator in a console
session, WithoutTheScope for a token without it) and hands it to the core write, which decides against
the row it has locked. Without the scope a token may change a trunk that holds a password, but not set or
clear the password, nor change its host, port or transport, which would send the stored password
elsewhere: 403 missing_scope, recorded in the deployment's audit log against the token. Issuing, rotating
and revoking a credential (sip_credentials::issue and revoke) take the SecretAuthority as an argument and
refuse anything but Granted before they touch a row, so extensions:write alone has no route to one and the
console's operator session, which holds no token, is refused as a view is. The integrator
contract for these routes is docs/integrator-api.md.
A request presenting an Authorization header is decided by it alone; the session cookie beside it is never
read. A missing scope is 403 missing_scope, a route no token may use 403 session_only, a token sent with an
Origin 403 token_from_a_browser, and an unknown, revoked or expired token 401 invalid_token, one answer
for all three. A token request with no cookie and no Origin needs no X-Requested-With: that header stops a
cookie a browser attaches by itself from making a change from another site, and such a request carries none,
while a page on another site cannot add an Authorization header without the browser asking this server
first. With either header present the request is treated as a browser's and needs it as before.
Every change made with a token is in the audit log as the operator (actor_kind stays operator, so an
older release still reads the entry) with the token's name in token. Every refusal of a token that exists,
whether revoked, expired, missing a scope or on a route no token may use, is an operator_token.refused entry
in the deployment's own log naming the route and why. A read changes nothing and is not an entry; it is
stamped on the token as its last use.
Branding¶
A deployment has one brand, set by an operator at runtime (/api/v1/operator/branding), with no rebuild:
the product name, an accent, the two ends of the brand gradient, an optional mark (PNG, WebP or SVG), the
SIP product string, and whether an organisation's pages show the release. It is one row
(branding.rs); while there is none the stock brand applies, and the stock brand is the stock look, held
to the stylesheet and page it comes from by a test.
- Checked before it is stored, and again by the table. The name is 1 to 40 characters with no control
character; colours are strictly
#rrggbb; the accent is refused unless white text on it reaches WCAG's 4.5:1, since it is the primary button's background; the SIP product follows RFC 3261'sserver-valgrammar and must not contain any scannerUser-Agentsignature siphon-sip drops requests on (the same list, not a copy). The table's own CHECKs repeat the ones that keep markup out of a page. - Each file's type is read from its bytes. The brand holds up to seven files, one per kind, in
brand_assets: the mark, a full logo for each theme, a favicon for each, and a body and a display font. The client's content type is never asked, and each kind takes only its own types: the mark and logos PNG, WebP or SVG, the favicons ICO, PNG or SVG (256 KiB each), the fonts WOFF2 only (1 MiB). An HTML page named.svgand a font offered as a logo are refused, by the release and by the table's CHECK. Each is served at/api/v1/brand/{kind}withnosniffand asandboxcontent security policy that allows nothing but inline style, so script in an SVG runs nowhere, opened directly or not; writes are operator-only, at/api/v1/operator/branding/assets/{kind}. - The tab icon is the favicon, else the mark, else the stock arch, linked from
index.htmlwith the type read from its bytes (the page no longer claims an SVG for a PNG), with a second link for a dark favicon underprefers-color-scheme: darkand anapple-touch-iconfrom the first of them that is a PNG. The same chain answers/favicon.svgand/favicon.ico, which browsers and bookmarks ask for by name. A host that is no site always gets the stock icon, the SIPhon kit's, with its home screen icon. - Corners, fonts and links. The corner preset (sharp, default, round) sets the four radius tokens; an
uploaded font is declared with
@font-facefrom our own origin, sofont-src 'self'and an air-gapped deployment both hold, and goes in front of--sansor--display(headings and the wordmark). The support link ishttps:ormailto:and the documentation linkhttps:only, checked in Rust and by the table, and shown at the foot of an organisation's sidebar and in the flow editor's account menu. - No flash of the stock look.
index.htmlis rendered per request with the brand's name as its (escaped) title and an inline style setting--brand-accent,--tube-start,--tube-endand--tube(and--brand-accent-darkwhen one is given, the radius tokens for a preset other than the stock one and the typefaces of uploaded fonts), so the first paint is already the brand's. Nothing is added for what a brand leaves stock, so an unbranded page is the page as built. The app reads the same values from/api/v1/status, which carries them on the operator address and an organisation's hostnames. A host that is no site gets no brand from the status, and its page's title names no product, not even the stock one. - Light, dark or the system's. Each theme is a set of tokens in
app.css: the light one on:root, the dark one under[data-theme="dark"]and, for a reader who left it to the system, underprefers-color-scheme: dark(two identical bodies, held identical by a test). The reader's choice is kept in their browser (siphon-pbx:theme) and set on<html>by/theme.js, a same-origin script in the head that runs before the page paints, so a dark reader sees no flash of light. The dark accent is the brand'saccent_dark, checked for 4.5:1 against the dark text on it and against the dark surfaces, or, when none is given, the light accent mixed with 65% white in OKLab, which reaches 4.5:1 for every accent the server takes. A QR code stays dark on light in both. - The brand's default theme. A brand designed for a light background sets
default_theme: light(ordark), and its pages open in it for a reader who has not chosen: the server writes it onto<html>asdata-theme, so the very first paint is in it, and/theme.jsleaves it there when nothing is stored. A reader's own choice still wins, and picking "System" in their menu is now stored assystemrather than as nothing, so it keeps following their system whatever the brand's default. Atsystem, the stock value, nothing is written and the page is the page as built. A reader who picked "System" before this existed has nothing stored, so a brand that sets a default applies to them until they pick again. - Every change is an operator's, recorded in the machine's own audit log.
Applying a brand from configuration management¶
siphon-pbx brand apply <dir> --as <operator email> [--check] sets the brand from a directory, for a
deployment managed by Ansible or the like rather than by hand. The directory holds brand.yaml and the files
it names, by paths relative to it:
product_name: Example Voice
accent: "#9a3412" # quote every colour: unquoted, YAML reads # as a comment
accent_dark: "#fdba74" # or null to derive it from the accent
gradient_start: "#f97316"
gradient_end: "#9a3412"
sip_product: Example-Voice/2.1 (office)
show_release: false
radius: round # sharp, default or round
default_theme: light # system, light or dark: for a reader who has not chosen one
support_url: mailto:help@example.com
docs_url: https://docs.example.com/
assets: # mark, logo_light, logo_dark, favicon, favicon_dark, font_body, font_display
mark: mark.svg
logo_light: logo-light.svg
logo_dark: logo-dark.svg
favicon: favicon.ico
font_body: fonts/body.woff2
- A key left out keeps the current value;
nullclears.nullis taken only where empty means something (accent_dark, the two links, and any file, which goes back to the stock one) and refused for the rest. An unknown key or file kind is refused, and so is a colour written without quotes, which YAML would otherwise read asnull. - The same checks as the console, all of them before anything is written. The settings go through
branding::checkand each file throughbranding::sniff_asset, so the accent must reach 4.5:1 with white text on it, a dark accent 4.5:1 against the dark theme's text and surfaces, and each file must be one of its kind's types within its size. The gradient's two colours are only checked to be#rrggbb: no contrast is asked of them, since nothing is written on the gradient. A file must lie inside the directory: an absolute path,..or a link that leads out is refused. One refusal and nothing is written; otherwise every change is written in one transaction. - Recorded against an operator who exists.
--asnames one by the address they sign in with, and the command refuses to run without one. Each change is written exactly as the console writes it: the same audit entries under that operator, the revision counted once per change. There is no actor of its own for the command, since an older release reads an actor kind it does not know as corrupt. - Idempotent. The request is compared with the brand as it is, each setting by its checked value and
each file by its SHA-256; when nothing differs, nothing is written, no revision is counted and nothing is
recorded.
--checkdoes the same comparison and writes nothing either way. - One line to read. The last line printed is
brand: unchanged,brand: changed (<keys and kinds>), or with--checkbrand: would change (...). When the SIP product changed, the line before it issip product changed: siphon-sip must be re-rendered (init-telephony) and reloaded (apply-telephony): siphon-sip reads its name from that file, so nothing else is needed for any other change. A refusal exits non-zero, naming the key orassets.<kind>and why.
The compose stack runs it as the brand-apply one-shot, which up never starts. A playbook templates
brand.yaml and copies the files beside it, with any owner and mode (the one-shot runs as root, like
init-telephony, and mounts the directory read-only), then:
cd deploy
SIPHON_PBX_BRAND_DIR=/srv/brand SIPHON_PBX_BRAND_OPERATOR=operator@example.com \
docker compose run --rm brand-apply
# only when that printed the sip product line:
docker compose up -d
changed_when reads the last line for brand: changed. up renders siphon-sip's configuration again, and
when siphon-sip started before that file was last written apply-telephony asks it to reload the file
(POST /admin/config/reload, siphon-sip 1.15.0 and later). The SIP product is applied that way, with no
restart, so registrations and calls in progress are untouched; running up when nothing changed costs
nothing at all. apply-telephony restarts siphon-sip only when the reload names a change siphon-sip applies
on a restart (the advertised address, a listener, the header policy), or when the admin API does not answer
with a report, and its last line names the fields or the reason. A file siphon-sip refuses as invalid fails
apply-telephony and leaves siphon-sip running on what it read before, rather than restarting it onto a file
it would not start on.
Delivering recorded calls¶
After a call that recorded something has ended and every part of its recording is imported, siphon-pbx
sends one signed multipart/form-data POST to the organisation's receiver, carrying the call's facts and
every audio part. A call that recorded nothing sends nothing: the upload is also the receiver's "call
completed" signal, so no separate hook is needed.
Settings¶
- Two layers. The operator names a deployment receiver for every organisation
(
/api/v1/operator/recording-delivery, the console's Recording delivery page, orrecording-delivery.yaml). Withorganisations_may_set_their_ownon (the default) an organisation may name a receiver of its own (/api/v1/recording-delivery, the organisation's Recording delivery page), which wins; while it is off an organisation cannot set one and one it had is treated as off, asallow_any_numberis under the operator's transfer policy. An organisation's own receiver withenabled: falseis kept but unused; there is no way for an organisation to opt out of the operator's receiver. - Two credentials. The token is the receiver's own, supplied by the administrator, write-only, sent as
Authorization: Bearer. The signing secret is generated by siphon-pbx (32 random bytes, 64 hex characters), shown once in the answer to the write that created it (signing_secret) and to a rotation (POST .../signing-secret), and never returned again; every read says onlyhas_tokenandhas_signing_secret. Both are sealed under the master key, bound to their own table, column and row. - Where it may point.
https://anywhere;http://to a loopback address written out, or to an address written out inside a private network named inSIPHON_PBX_VOICE_BOT_PRIVATE_NETWORKS, by the same check a voice bot'sws://address goes through (voice_bots::check_plain_transport). The check runs when the address is saved and again before every send. Over such anhttp://URL the token, the signature and the audio cross that network in clear text, which is what naming the network accepts. The HTTP client refuses a secret header over plainhttp://to anything but loopback, the cluster network or an address the caller has just checked against those networks (Request::on_a_private_network), so no other path opens it. recording-delivery.yaml, applied withsiphon-pbx recording-delivery apply <dir> --as <operator> [--check](compose:recording-delivery-apply, profilerecording-delivery, the directorySIPHON_PBX_RECORDING_DELIVERY_DIR), sets the deployment receiver:
url: https://receiver.example.com/recordings
token_file: token # the receiver's Bearer token
signing_secret_file: signing-secret # at least 32 visible characters, e.g. `openssl rand -hex 32`
organisations_may_set_their_own: true # optional; left out keeps the stored value
Neither secret is ever a value in the YAML or an argument. Unlike the console, the signing secret is
supplied, not generated: a deployment configured from code keeps its secrets in its own store, and a
secret shown once on a terminal would have nowhere to go. Applying is idempotent (the stored secrets are
opened to compare) and the last line is recording-delivery: unchanged or changed (<keys>).
The receiver contract¶
POST <url>
Authorization: Bearer <token>
X-Siphon-Timestamp: <Unix seconds>
X-Siphon-Signature: <lowercase hex HMAC-SHA256(key = signing secret, message = timestamp + "." + body)>
Content-Type: multipart/form-data; boundary=siphon-<32 hex>
- The signature is over the exact request body bytes. The key is the signing secret exactly as shown
(its 64 characters as UTF-8, not decoded from hex), so
printf '%s' "$TIMESTAMP.$BODY" | openssl dgst -sha256 -hmac "$SECRET"computes it. There is no prefix and no version in the header. A receiver should compare in constant time and reject a timestamp more than a few minutes from its own clock. - The body. First a part named
metadata(application/json), thenaudio_1toaudio_n, one per recording part in order. Each audio part isaudio/ogg(Opus, stereo, caller left and bot or far end right) named<recording_id>.opus; a part recorded before recordings were Ogg Opus isaudio/wavnamed<recording_id>.wav. The boundary is random per request and never occurs in a body. - Only a 2xx is success. Anything else, a timeout included, is tried again (below); redirects are not
followed. A receiver should answer 2xx only when it has stored the upload, and may see the same call more than
once if it answered 2xx after the PBX gave up waiting (dedupe on
call_id). metadata(version1; a field may be added within a version, none is renamed or retyped):
| Field | Meaning |
|---|---|
version |
1 |
call_id, sip_call_id |
siphon-pbx's id for the call, and the SIP Call-ID |
organisation |
{id, external_ref, name} |
direction |
inbound or outbound; null for a call recorded before it was kept |
caller |
{number, national, name, withheld}: number in E.164 where it reads as one without guessing, national as someone in the organisation's country says it (needs the dialling plan); a caller who withheld their identity has no number and no name |
called |
{number, national} |
trunk |
{id, name} of the trunk an inbound call came in on, else null |
started_at, answered_at, ended_at, duration_ms |
UTC, RFC 3339; answered_at null when never answered; duration_ms is ended_at - started_at |
ended_by |
caller, bridged_party, bot, flow or transfer; null when not known. There is no callee: siphon-sip reports one bye for a bridged call whichever side sent it, so a hang-up on a bridged call is bridged_party rather than a guess |
outcome |
{kind, detail, ...}: kind is completed, transferred (with destination and mode), no_answer, busy or failed (with reason); detail is the flow's own name for what happened |
flow |
{id, name, version}, null for a call no stored flow handled |
bot |
{name, report} of the last voice bot the call was handed to, null when none; report is {kind: chose, option}, {kind: finished}, {kind: failed, reason} or {kind: transferred, to, mode}, null while the bot still had the call |
voice_bots |
every bot visit in order, {id, name, report} |
recordings |
[{recording_id, position, started_at, duration_ms, format, channels, field}] where format is ogg_opus or wav and field is the multipart field carrying it |
complete, missing_recordings |
false and a count when the upload was sent before every part was imported (below) |
source |
own for a call this PBX recorded, siprec for a recording session another PBX sent it (below) |
siprec |
for siprec only, else null: {session_id, participants: [{participant_id, aor, name, side}], streams}, where side is left or right, the channel of the stereo recording the participant is on (null for a third participant) |
The outbox¶
- Queued in the call's own transaction. When a call's record is written (
calls::record) and the call recorded something and the organisation has a receiver at that moment, arecording_upload_outboxrow is inserted in the same transaction,awaiting_recordings, withexpected_parts. A receiver set later does not send calls that already ended. A crash between the call ending and its audio being imported cannot lose the upload. - Due when the import ends. The end of
import_the_recordingmakes the rowdueand wakes the worker. A row still waiting after 10 minutes is made due by the worker and sent with the parts that exist,complete: falseandmissing_recordingssaying how many are missing. An import that stored nothing drops the row. - The worker takes one due row at a time with
FOR UPDATE SKIP LOCKEDand moves itsnext_attempt_atahead by a 15 minute lease, so several nodes can run it. A failed attempt waits 1 minute, doubling to an hour (the first wait isSIPHON_PBX_RECORDING_DELIVERY_FIRST_RETRY_SECONDS, for an end-to-end test only); after 8 attempts the row isdead. A dead row is kept, unlike the voicemail outbox's, withlast_errorandlast_status. A no-receiver, a receiver address the private networks no longer allow, and a call whose audio retention removed aredeadat once with the reason, since trying again changes nothing. One call's failure never blocks the next. - Resend and the list.
GET /api/v1/recording-deliveries?state=<awaiting_recordings|due|delivered|dead>&limit=lists the organisation's uploads, newest first;POST /api/v1/recording-deliveries/{call_id}/resendsends one again from the start (404 for a call with no upload, 409 while it is still queued and 409 when retention already removed the audio). The console's Recording delivery page lists them with a Resend button. - Retention. Delivered rows are kept 7 days and dead rows for
SIPHON_PBX_RECORDING_RETENTION_DAYS, pruned by the leader-held recording sweep (recording_upload::prune), written so a per-kind retention policy can take it over./metricscarriessiphon_pbx_recording_uploads_due,..._awaiting_recordingsand..._dead.
Retention and legal hold¶
How long data is kept is the operator's policy, with an organisation's own value inside it
(siphon_pbx_core::retention, migration 0109).
- A kind with no rule is kept as it always was: recorded audio by
recording_retention_days, captured SIP bycapture_retention_days, everything else for ever. A kind with a rule is always a bounded range: a default, amin_daysand amax_days(1 to 3650), andorganisations_may_change. There is no "for ever" choice once the operator sets a rule. SIP traces are never an organisation's to change: one partition holds every organisation's packets. - Only a kind a sweep enforces is accepted (
Kind::is_swept): every kind is swept in this release. The API,retention applyand the writes refuse any kind that is not (and a mailbox cap below one message), so a setting is never stored that nothing acts on. - What a value means is one pure function (
retention::effective). An operator-set value for one organisation applies even where organisations may not change the kind; an organisation's own is ignored unless they may. Either is clamped into the range when read and never rewritten. Recordings and transcripts are cut short by the call history's window, and an unheard voicemail is kept at least as long as a heard one. - The sweep (
retention_sweep::run) runs on the leader every six hours. Each batch is its own short transaction under the leader lease, per organisation, and a full batch is followed by a short pause. Recorded audio goes in batches of 50 parts, finished uploads (never one still queued) and transcripts in batches of 500. Call history (migration 0110 adds the audit index) goes last per organisation, 500 calls a batch, by the call's end: only a call that has ended is ever a row, and the legs, transcript and finished upload go with it by cascade. A call still holding recorded audio, or a queued upload, is skipped and taken by a later sweep: recordings are capped at the call history's window and run first, so this only waits out a batch limit, and audio is never dropped with a call it was not accounted for. Voicemail (migration 0111 addsvoicemail_messages.heard_at) goes after transcripts, 100 messages a batch: heard messages age from when they were first heard (heard_atis set once, on the first playback, and a second one does not move it; a message heard before the column existed ages from its arrival), unheard ones from their arrival. Then the mailbox cap (voicemail_max_messages): while a mailbox holds more messages than that, its oldest heard messages go. An unheard message is never deleted for the cap, so a mailbox of nothing but unheard messages stays over it until they are heard or their own window ends. The audio is the row's own column and the pending email follows the row, so nothing is left behind. A message that came in on a call under legal hold (same Call-ID) is kept, and the cap still counts it. Every mailbox that lost a message is then told once throughmessage_waiting::mailbox_changed, so the extension's waiting light follows. The mailbox's message list says when each message expires (expires_at, null where nothing will delete it). The audit log goes 5000 rows a batch by its organisation's window; rows of no organisation (changes to the system) follow the deployment default. SIP traces are dropped a whole day-partition at a time: first those past the window, then, while the rest exceedsip_traces_max_bytes, the oldest day, never today. Files the media engine wrote and nothing imported (.opusand.wav) are removed per node after a day. - Legal hold. The operator holds a whole organisation at the console: nothing of it is deleted by age, except
SIP traces, which are not the organisation's. An organisation holds a single call (
PUT /calls/{id}/legal-hold), which keeps its recording; a call hold records who placed it, so an organisation cannot lift the operator's. Policy, value and hold writes are refused with 409 while a node running an older schema is live, since its sweep would not honour them. retention.yaml, applied withsiphon-pbx retention apply <dir> --as <operator> [--check](compose:retention-apply, profileretention, the directorySIPHON_PBX_RETENTION_DIR), is the whole policy: a kind it does not list has its rule removed.
kinds:
recordings:
default_days: 90
min_days: 30
max_days: 365
organisations_may_change: true # optional, false when left out
sip_traces:
default_days: 7
min_days: 1
max_days: 30
limits:
sip_traces_max_bytes: 10737418240 # optional
voicemail_max_messages: 200 # optional, at least 1
The last line is retention: unchanged or retention: changed (<kinds>).
- What is stored (
siphon_pbx_core::storage, migration 0112 addsstorage_measurements). The leader measures at the end of every retention sweep, one grouped pass per table, and replaces the stored snapshot in one transaction; a follower measures and stores nothing. The cost is the rows of each table and never the bytes (an audio value's size is read from its header), once every six hours, outside any lock the sweep holds. Kinds: recorded audio, voicemail, transcripts, call history (the call's trace, outcome and identifying text, legs not counted), audit log and SIP traces. Captured SIP is the partitions' total size with the planner's row estimate (exact for a partition never analysed). It belongs to no organisation, and neither do the audit rows of changes to the system, so both are the deployment's. The operator's Storage page (GET /operator/storage, readable with anorganisations:readtoken) serves that snapshot with when it was measured, per organisation and per kind: bytes, items, the age of the oldest item and the effective window beside it (voicemail names both), and says when the oldest item is already past the window. It never scans; before the first measurement it says so. - Metrics.
siphon_pbx_retention_deleted_total{kind}counts the rows each sweep step deleted, on the node that ran the sweep (the leader), every kind rendered from zero.siphon_pbx_stored_bytes{kind,organisation}is the snapshot as a gauge, reported only by the node that holds the leader lease, so several nodes scraped together report each figure once.organisationis the organisation's id; captured SIP and system audit rows carry the fixed valuedeployment. Labels are bounded by the number of organisations and the six kinds.
Recording calls another PBX sends (SIPREC)¶
siphon-pbx is a session recording server (RFC 7866) for each organisation that asks to be one: a PBX or SBC that records its calls sends each one as a recording session, and siphon-pbx keeps it as a recorded call of the organisation's, listed, played and delivered exactly as a call a flow recorded.
- siphon-sip answers the handshake; siphon-pbx decides it. The rendered
srs:block is always on, withappthe same control app the calls reach, so every recording session is offered to siphon-pbx (aStasisStartwithkind: siprec) before siphon-sip answers it or anchors any media (siphon_pbx_control::siprec). - Which organisation, and whether. The organisation is the one whose SIP domain the Request-URI host names.
The session is taken only when that organisation has SIPREC switched on and the source is in a network it
lists (
siphon_pbx_core::siprec::decide), then the deployment's country and network rules and the organisation's own access rules, as for a call. An empty list refuses every session. A domain nobody has is refused 404 and everything else 403, before the 200 and with nothing anchored. The source is the client's own address, the PROXY-protocol one on the TLS hop. - Sent to the PBX's address, by participant number. When no organisation has the host (an address, or a
name nobody has),
siphon_pbx_core::siprec::attributereads every participant of the offer's initialrecording_session(theaorof each,sip:,sips:ortel:), takes the user part canonicalised asflows::canonical_numberdoes, and finds the organisation that owns it (numbers::owner, a number or a block). Each such organisation is asked the same questions as one named by its domain (siprec::refusal_of, then the country and network rules and its access rules), and the session is taken for every one that qualifies; one that does not is left out and logged at info. Nobody qualifying is 404 when no participant number belonged to an organisation and 403 when some did, always before the 200. The decision is made at the INVITE from the initial metadata, which siphon-sip carries in the offer; later metadata is never waited for. A session taken for several organisations is one session, recorded once and imported once per organisation: a call of its own, a stored copy under a key that includes the organisation, and its own "Recorded by" with the number that selected it (calls.siprec_selected_by). The organisations and their numbers are kept on the channel (siphon_pbx_siprec_recipients, beside the first organisation in the earliersiphon_pbx_siprec_tenant), so a restart finishes the session for all of them and a session an earlier release took for one organisation resumes from the older variable alone. - Who may change it. The operator sets an organisation's switch and networks
(
/api/v1/operator/organisations/{id}/siprec, also with anorganisations:writetoken) whatever else; organisations manage their own (/api/v1/siprec) only while/api/v1/operator/siprecallows it, off by default. - Recorded as a call is. A taken session is accepted as one stereo Ogg Opus file for two parties (the
participant the first
participantstreamassocsends on the left), into a directory siphon-pbx makes on the recordings volume (siprec-<key>), which siphon-sip and the engine see at the same path. siphon-sip's own storage backend isnone: it would otherwise write ametadata.jsonthere after the session ends. - Kept from
RecordingSessionEnded, which lists every closed file with the final metadata, so an update mid-call (a transfer at the recorded PBX) is in the record. A file is read only when it is directly inside the session's directory. The session becomes acallsrow withcalls.siprecholding the metadata, originsiprec, outcomesiprec_recorded, caller the left participant and dialled party the right, direction null (RFC 7865 metadata has no direction), and its parts are stored withsourcesiprec. Its upload is queued in the same transaction and made due when the import ends, as a recorded call's is. - Across a restart of siphon-pbx. The session's key, organisation, start and source address are set as channel
variables before the
accept(the address ends up incalls.siprec_source; a session an earlier build remembered has none); a reattached channel carrying them is finished from them, waiting for the same event. - What is left behind is swept: a session directory untouched for a day (an import that never came, or a file one kept) is removed by the recordings sweep, as an engine file nobody imported is.
- Not built: the live tee of a session to a WebSocket (siphon-sip has it); it is a separate decision.
The voice bot the operator provides¶
A deployment whose operator runs one voice bot for everybody sets it once, for every organisation, at the
operator address (/api/v1/operator/voice-bot, the console's Voice bot page) rather than in each
organisation.
- When a call reaches it. A voice block that names no bot, in an organisation that has no bot of its own.
An organisation's own bots always come first: one of them is the answer while there is exactly one, and a
block naming none among several is refused at publish whatever the operator provides, since an
organisation with two bots has said it chooses. A block that names a bot never reaches the operator's, not
even when the bot it names is gone, and a block cannot name the operator's bot. With no bot anywhere the
block takes its unavailable port and publishing warns, as before. The rule is one function
(
choose_voice_bot), and the directory the validator, the simulator and the live executor all read carries the operator's bot beside the organisation's, so all three give the same answer. - A table of its own.
deployment_voice_botholds one row, not avoice_botsrow with no organisation. A NULLtenant_idwould stay unseen by everyWHERE tenant_id = $1, but it would also make the per organisation name uniqueness, the composite keys that tie a hosted bot's roles to its organisation, the delete guard and the second-bot guard each learn a row that belongs to nobody. Apart, none of them can see it. Expanding: an older release reads no such table and sends that call to the unavailable port. - Reached at an endpoint, always with a secret. A bot this deployment runs names the organisation's own AI providers and keys, and a bot serving every organisation has no organisation whose providers it could name, so the hosted kind is not offered. The secret is required the first time, write-only, and sealed under the master key, bound to this table and the row's own id, so a value lifted from an organisation's bot does not open here.
- Sessions. A session minted for the operator's bot records its id, so the route a bot reports on opens the operator's bot's secret for it and nothing else; an organisation bot's secret opens only its own sessions, and the voice-runtime token opens neither. Every refusal is the same 404.
- What an organisation sees. Its name and whether the organisation may use bots of its own
(
organisations_may_add_bots, below), at/api/v1/provided-voice-botand read-only on the Voice bots page: not where it is, not its id, not whether it has a secret. It is not a row of/api/v1/voice-bots, which lists what the organisation owns, edits, deletes and names in a flow.
Who runs the turns on a bot's call¶
Each bot has a media setting saying how the media engine treats its audio. Telephony owns what the line
needs (echo, timing, the wire rate); the bot owns conversation behaviour when it says it does.
media |
noise suppression | echo cancellation | speech events (ws_vad) |
barge-in | wire |
|---|---|---|---|---|---|
engine_turns (default) |
on | on | on (neural) | in the engine | 16 kHz |
bot_turns |
off | on | off | off | 16 kHz |
raw |
off | off | off | off | 16 kHz |
- For a model with its own turn detection (a speech-to-speech model, typically),
bot_turns. Underengine_turnsit gets a second detector and a second suppressor on the same audio: the two detectors disagree, the engine's barge-in flushes audio the bot still meant to play, and suppression applied twice damages speech. - Each setting is a rendered siphon-sip profile, split by caller origin as before:
voice_bot/phone_voice_botareengine_turns, unchanged, besidevoice_bot_bot_turns/phone_voice_bot_bot_turnsandvoice_bot_raw/phone_voice_bot_raw. The hand-over picks one from the bot's setting and the caller's origin (siphon_sip::voice_bot_profile_name), on the answer, on the attach behind a greeting and on a call this PBX places to a bot. The gate, the source hint andreplace: originare the same in all six, so whether the bot hears the caller is not part of the choice. - All six are rendered always, not only once a bot uses one. siphon-sip's config reload does not apply a
media profile (it reports one as needing a restart), so rendering on demand would make changing one bot's
setting either a siphon-sip restart, dropping every registration it holds in memory, or a call refused for
a profile that is not there until the next deploy. The cost is one changed
siphon.yaml, once, on the upgrade that adds them. - Set where bots are set:
mediaon/api/v1/voice-botsand/api/v1/operator/voice-bot, the Voice bots page and the console's Voice bot page, andmedia:invoice-bot.yaml. Left out of a change it keeps what it was.GET /api/v1/voice-bot-media(and/api/v1/operator/voice-bot-media) lists each setting with the server's sentence for it, and each stored bot carries its own asmedia_describes;web/src/api/voice-bot-media.fixture.jsonis that catalogue as this server emits it. - The bot is told: the brief carries
mediaon every call, so a bot can check the line is what it was built for.
A bot's prepare URL and instance domain¶
Two optional settings of a bot somebody else runs; a hosted bot takes neither and refuses them.
prepare_urlis where a call's brief is to be posted while the caller is still ringing. It is checked by the rule a recording receiver's address is (https://anywhere, plainhttp://only to loopback or an address written out inside a private network the operator named), at most 512 characters, with no credentials, query string or fragment. The post is signed with the bot's secret, so a bot with none may be given only a loopback or named-private address. Setting or changing it is a disclosure, likecontext: an operator acting as an organisation cannot (disclosure_in_a_view).instance_domainis a bare lowercase DNS suffix of at least two labels, with no scheme, port or wildcard, and not an IP address.InstanceDomain::coverssays whether a host is the domain or a name under it, on a label boundary (evilbots.example.comis not underbots.example.com).- Absent keeps, empty clears. Set on
/api/v1/voice-bots,/api/v1/operator/voice-botand invoice-bot.yaml; each stored bot returns them when set.
Preparing a bot before the call is answered¶
A Prepare bot block ahead of the first answer lets the caller hear ringing while the bot looks the caller up and opens its model session. What happens, in order, on a live call:
- Ring. If the call is unanswered, siphon-sip's
ringverb sends a bare180 Ringing(no body, so never early media). An already answered call is prepared with no ring. A ring that fails leaves byunavailable. - A session opens early in a preparing state, with the call's context at the bot's own
contextlevel and nothing the Voice bot block will bring (no instructions, no options). The bot may read this brief and say it is ready; it may report nothing. Closing it (release, hang-up, timeout) kills the token: brief and ready answer404. - The webhook. A spawned task (never the call's actor) POSTs to the bot's
prepare_url, 3 s deadline, no redirects, answer capped. The address is checked again immediately before every send, so a secret removed since the bot was saved cannot lead to an unsigned post. Body:
{"event":"prepare","session":"<token>","call_id":"<SIP Call-ID>","context":{...},
"brief_url":"<base>/voice/sessions/<token>","ready_url":"<base>/voice/sessions/<token>/ready",
"deadline_secs":10}
context is left out for a bot set to none. <base> is where bots reach this PBX: SIPHON_PBX_PUBLIC_URL,
or the address it listens on. It is signed as a recording delivery is: X-Siphon-Timestamp (Unix seconds)
and X-Siphon-Signature, the lowercase hex of HMAC-SHA256(bot secret, timestamp + "." + body). The secret
is never sent. A non-2xx answer, a transport error, the deadline, no prepare_url or a failed re-check leaves
the block by unavailable with the reason in the call's trace. The deployment's own runtime has no prepare
step and is ready at once.
4. Ready. POST /voice/sessions/{token}/ready with the bot's Bearer secret (same 404-on-anything rules as
a report, and forwarded to the owning node like one), body {"connect":"wss://..."} optional. A connect must
read as a bot address, pass the usual transport rule, and be a name under the bot's instance_domain (a bot
with none may name none), else 422 with a short reason and the bot may retry within the wait. 204 tells
the call once; a repeat is 204 and tells it nothing.
5. The Voice bot block takes the call. Naming the same bot, it reuses the session: same token, now complete
(instructions, options, deadline, destinations), and the media engine dials connect when the bot gave one,
else the configured address, with ?call={call_id}&session=<token> either way. A load balancer can hash on
session when the bot names no instance. A different bot closes the prepared session and opens its own.
6. Cancelled. Release, a hang-up while preparing or the wait running out sends one signed
{"event":"cancelled","session":"<token>","call_id":"<Call-ID>"} to the same address (one try, 3 s, logged on
failure). A bot whose prepare post failed is not sent one. A session the Voice bot block took is the live one
and is never cancelled.
A restart. The session lives in memory. siphon-sip hands a call a restarted PBX no longer holds back as
reattached, and that call is refused 500 rather than left ringing; while the PBX is up the block's own timer
ends any wait.
A bot's own audio settings (Advanced)¶
The preset is the first choice. Tuning a bot to one line takes the settings themselves: a speech-to-speech bot
on a carrier leg that interrupts itself wants echo_cancellation off and everything else its preset gives it.
So each bot also stores audio, the media engine's settings it changes from its preset, under the engine's
own names (siphon_pbx_core::voice_bot_audio). A setting left out is the preset's.
| Group | Setting | Takes | engine_turns |
bot_turns |
raw |
|---|---|---|---|---|---|
| Echo | echo_cancellation |
true / false | on | on | off |
| Echo | echo_delay_search_ms |
16-1000 ms (a tail length with echo_long_tail) |
256 | 256 | 256 |
| Echo | echo_long_tail |
true / false, only with the canceller on | off | off | off |
| Echo | echo_residual_suppression |
true / false, only with the canceller on | off | off | off |
| Noise | noise_suppression |
true / false | on | off | off |
| Speech detection | ws_vad |
true / false | on | off | off |
| Speech detection | ws_vad_engine |
energy / neural |
neural | energy | energy |
| Speech detection | ws_vad_min_speech_ms |
0-1000 ms | 100 | 0 | 0 |
| Speech detection | ws_vad_threshold |
1-1073741824 (energy detector) | 1000000 | 1000000 | 1000000 |
| Speech detection | ws_vad_hangover_ms |
0-2000 ms (energy detector) | 200 | 200 | 200 |
| Speech detection | ws_barge_in |
true / false, turns detection on | on | off | off |
| Wire | ws_sample_rate |
a multiple of 1000, 8000-48000 Hz | 16000 | 16000 | 16000 |
- What reaches the engine. The hand-over still names the preset's profile and adds siphon-sip's per-call
media_flagsbeside it, holding only the settings the bot changes; siphon-sip merges them over the profile for that call alone. A bot that changes nothing sends nomedia_flagskey at all, so its verbs are byte for byte what they were. Nothing is rendered and nothing restarts: a profile per combination would cost a siphon-sip restart per combination, which drops every in-memory registration. This needs siphon-sip 1.15.4 or later, the first release that takesmedia_flags(MEDIA_FLAGS_SINCEindeploy/e2e/telephony.sh, whose step proves it on the pinned image). - Where it cannot travel, it is left off and said. siphon-sip refuses
media_flagswithoffer: "early"and on astream_startnaming no profile; no hand-over here has either shape, and one that did would warn naming the bot and run the preset rather than fail the call. A call this PBX places to a bot (originate), and a warm transfer's consult, carry them on the originate's anchor (OriginateMedia::Anchor { media_flags }, control SDK 0.11.0), which siphon-sip holds until it answers the callee; a caller given back to its bot after a consult gets them again on the attach. - Checked when it is saved, by the engine's rules, under the preset the bot ends up on: the echo window,
the canceller's posture (
echo_long_tailandecho_residual_suppressionneed the canceller, or siphon-rtp refuses the call), the wire rate, and bounds of our own for the three settings neither siphon-sip nor siphon-rtp checks. A refusal is400 {"error": {"code": "invalid_audio_setting", "field", "allowed"}}; a key the engine does not name, anulland a value of the wrong type are refused the same way. Changing only the preset can be refused too, when it would leave the stored settings unrunnable. - Set where bots are set:
audioon/api/v1/voice-botsand/api/v1/operator/voice-bot, the Advanced tab of both consoles' voice-bot forms, andaudio:invoice-bot.yaml. The object replaces what is stored: left out keeps it,{}clears it.GET /api/v1/voice-bot-audio(and/api/v1/operator/voice-bot-audio) lists each setting with what it takes, its unit, what it needs to be on, each preset's value and a line of help;web/src/api/voice-bot-audio.fixture.jsonis that catalogue as this server emits it. - While the operator keeps organisations to its own bot (
organisations_may_add_botsoff), an organisation cannot change a bot's audio: the Advanced tab is read-only and the write is refused (organisation_bots_not_allowed). Sending the stored settings back unchanged is not a change. - The bot is told every setting as the engine runs it, as
audiobesidemediain its brief: all twelve, the engine's defaults under the preset under the bot's own.
siphon-pbx voice-bot apply <dir> --as <operator email> [--check] sets it from a directory, the same way
brand apply sets the brand and with the same machinery. The directory holds voice-bot.yaml and the file
holding the secret, which the YAML names by a path relative to the directory:
name: Receptionist
endpoint: wss://bot.example.com/stream
secret_file: secret
context: organisation # optional: none, organisation or full
organisations_may_add_bots: true # optional: false makes this the only bot any organisation uses
record_new_organisations: true # optional: new organisations play the notice and record before the bot
recording_notice_file: notice.wav # optional: the notice, a WAV file held to a prompt's rules
media: bot_turns # optional: engine_turns, bot_turns or raw
audio: # optional: the media engine's settings this bot changes from its preset
echo_cancellation: false
prepare_url: https://bot.example.com/prepare # optional: where a call's brief is posted while it rings
instance_domain: bots.example.com # optional: where the bot may ask the media connection to go
- The secret is a file, never a value and never an argument. A YAML file is templated, diffed and printed
by the tools that write it, and an argument is visible to every process on the host. A
secretkey is refused; the file must lie inside the directory, as a brand file must. - Every key is required but these, every refusal is named at once, and the checks are the console's own.
One transaction, under an operator who already exists, recorded as the console records it. The optional
keys are
default_flow_for_new_organisations: true|false,organisations_may_add_bots: true|falseandrecord_new_organisations: true|falsewithrecording_notice_file(all below),context: none|organisation|full(see What a voice bot is told about a call) andmedia: engine_turns|bot_turns|raw(see Who runs the turns on a bot's call) andaudio:(see A bot's own audio settings), a map that replaces the stored settings as a whole,audio: {}clearing them; each left out keeps the stored value. - Idempotent. The name and address are compared by their checked values and the secret by opening the
stored one, so it reads the master key. When nothing differs nothing is written and nothing is recorded.
The last line is
voice-bot: unchanged,voice-bot: changed (<keys>), or with--checkvoice-bot: would change (...).
cd deploy
SIPHON_PBX_VOICE_BOT_DIR=/srv/voice-bot SIPHON_PBX_VOICE_BOT_OPERATOR=operator@example.com \
docker compose run --rm voice-bot-apply
No restart is needed: the next call reads it.
A bot on a private network, over plain ws://¶
A bot's address is wss://, or ws:// to a loopback address written out. A deployment whose bot runs on
another machine of its own, on a private subnet with no public certificate, can name that subnet in
SIPHON_PBX_VOICE_BOT_PRIVATE_NETWORKS (comma-separated CIDRs, unset by default). Then ws:// to an IP
address written out inside one of those networks is accepted too, for the operator's bot and for an
organisation's, by the console, the API and voice-bot apply alike: all three call one check
(voice_bots::check_bot_endpoint), and the compose file passes the variable to siphon-pbx and to the
voice-bot-apply one-shot so both read the same setting.
- Over ws:// nothing is encrypted. Every caller's voice crosses that network in clear text, and so does
the call's session token, which is the credential on that connection: it travels in the
session=query of the WebSocket URI the media engine is given. The bot's own secret is used only toward siphon-pbx, on/voice/sessions/{token}. Naming the network is the operator saying that is acceptable on it. siphon-pbx logs a warning naming the networks at start whenever any are set, and the bot's row in the console still reads "in the clear". - Private ranges only. Each network must lie inside
10.0.0.0/8,172.16.0.0/12,192.168.0.0/16(RFC 1918),100.64.0.0/10(RFC 6598) orfc00::/7(RFC 4193). A public range,/0, link-local (169.254.0.0/16,fe80::/10: one link rather than a subnet, an IPv6 one needs a zone identifier a bot address cannot carry, and169.254.169.254is cloud instance metadata) or a typo stops siphon-pbx andvoice-bot applyat start, naming the variable, rather than quietly weakening the check. - An address, never a name.
ws://bot.internal.exampleis refused even if it resolves into a named network today, because what it resolves to can change after the check and the audio would follow it in clear text. An address outside every named network is refused with the networks named. - The database's own check widens to the same ceiling (migration 0070, expanding): an organisation's bot
row may hold
ws://to a loopback address or to an address written out in one of those private ranges, and nothing else. Whether it is in a network the operator actually named is checked in Rust, since the constraint cannot read the process's setting. Unsetting the variable later leaves stored bots as they are (a call reads the address and does not re-check it); saving one again is then refused.
A new organisation can start with a flow to it¶
default_flow_for_new_organisations, off by default, on the console's Voice bot page, in the operator API's
settings body and in voice-bot.yaml. While it is on, an organisation the operator creates starts with one
published inbound flow, "Every call to the voice bot", so an organisation given a trunk answers on its first
number without anyone drawing a flow. Organisations that already exist are never touched, and nothing is
created while it is off.
- What it claims: the catch-all. The flow's entry takes every other number of the organisation, the least
specific of the three claims, so a number or block the administrator claims later wins over it. Its limits
are the catch-all's, and each one refuses a call rather than guessing whose it is: only a call from a
source no registration owns, arriving from an address where exactly one organisation has a trunk (the
trunk's host written as an address, or a source network declared on it), reaches it. Two organisations
behind one carrier address reach neither catch-all from there; a trunk named by DNS counts once the sweep
has resolved it, so right after a restart such a call is refused
404until then; a carrier sending from an address its trunk does not name needs that network declared. - What it does. A voice block naming no bot, so it reaches the operator's bot by the rule above, and the
organisation's own bot once it sets one up. Its
completedandunavailableports each end in a hang-up: a new organisation has nothing else to send a call to, and an unavailable bot (removed, refusing, or out of time after the longest conversation the validator allows) must not leave a caller waiting. - An ordinary flow. Created through the same insert and publish as any flow, validated by the same validator, recorded in the organisation's audit log under the operator. The administrator edits, publishes again or deletes it like any other.
- Atomic with the organisation. Created in the organisation's own transaction: if the flow cannot be created, the organisation is not either.
- It lives on the bot's row. It cannot be on with no bot, and removing the bot removes it; set again, the
bot starts with it off. A change is recorded in the machine's audit log as
deployment_voice_bot.default_flow_for_new_organisations.
A new organisation can record the calls its bot takes¶
record_new_organisations, off by default, on the console's Voice bot page, in the operator API's settings body
(PUT /api/v1/operator/voice-bot) and in voice-bot.yaml, next to the one recording notice the operator uploads.
It changes only the flow default_flow_for_new_organisations creates, and only for organisations created from
then on: the flow becomes inbound, an announcement playing the notice, record_call, the voice block, and the
same two hang-ups. With it off the flow is exactly the one above. Organisations that already exist are never
touched, and "Apply the default flow" to an existing organisation still makes the plain flow.
- The notice is the operator's one WAV file, stored in 16-bit PCM on the bot's row (migration 0113), checked
and converted by the same code as a prompt upload (the same size limit and WAV rules; refused with
422). Uploaded at the console (PUT /api/v1/operator/voice-bot/notice, the raw WAV body;GETplays it back,DELETEremoves it) or carried byvoice-bot applyasrecording_notice_file, a path inside the directory. The three notice routes are an operator session's, as the brand's mark is, and not an operator token's. - It is copied, not shared. In the transaction that creates the organisation the notice becomes a prompt
named "Recording notice" in the organisation's own
prompts, and the flow names that prompt. From then on it is an ordinary prompt: the organisation can rename or replace it, and the operator replacing the notice never changes a copy. While the flow plays it the organisation cannot delete it, as for any prompt a flow uses. - The setting cannot be on without a notice. Turning it on with none uploaded is
422(recording_notice_missing) from the API and a refusal namingrecord_new_organisationsfromvoice-bot apply; the table refuses the same combination. Removing the notice while the setting is on is refused (409) rather than switching the setting off, so nobody stops recording by removing a file. Removing the bot removes both. - A call the engine cannot record is still served. The record step's
failedport leads to the bot, so the caller is not turned away; the call's path shows it left the step byfailed. The recording is capped at fifteen minutes a part: the conversation itself is held to ten, and the cap only has to stop a call nobody ends. - It has an effect only while the default flow is on. Changes are recorded as
deployment_voice_bot.record_new_organisations,.recording_notice_setand.recording_notice_removed.
Organisations may add their own voice bot, or not¶
organisations_may_add_bots, on by default, on the console's Voice bot page ("Organisations may add their own
voice bot"), in the operator API's settings body (PUT /api/v1/operator/voice-bot, an operator session or a
token with voice-bot:write) and in voice-bot.yaml. All three write through one function
(deployment_voice_bot::store). On, nothing changes. Off, the operator's bot is the only bot any
organisation uses:
- Every voice block resolves to it, at call time, whatever bot it names. Decided in
siphon_pbx_flow::directory::choose_voice_bot, the one function the validator, the simulator and a live call ask, so no flow an organisation publishes, then or before, can take its calls off the operator's bot. - Adding a bot is refused with
409 organisation_bots_not_allowed, naming the setting. Bots an organisation already has stay stored and are not used; the Voice bots page hides the add buttons and says the provider chose the operator's bot. - Publishing a flow that names an organisation's bot is allowed, with a warning
(
voice_bot_replaced_by_operators) saying where its calls go. Refusing would protect nothing, since the call resolves to the operator's bot anyway, and would only stop an organisation publishing an unrelated change. - It lives on the bot's row, so it means something only while there is a bot: removing the bot is refused
while the setting is off. Should a directory ever say off with no bot, a voice block takes its unavailable
port with a reason saying so. A change is recorded as
deployment_voice_bot.organisations_may_add_bots. - Rolling back. Migration 0071 is expanding: a release before it neither reads nor writes the column, and simply does not enforce the setting (organisations add and use their own bots, as before).
The announcement endpoint the operator provides¶
A deployment whose operator runs one announcement service for everybody sets it once, at the operator address
(/api/v1/operator/announcement-endpoint), and every organisation's Remote announcement block may name it
beside the organisation's own endpoints.
- Reached by id. The flow directory admits the deployment endpoint's id for every organisation
(
deployment_announcement_endpoint::id), so the validator, the simulator and the live executor accept a block naming it with no new issue code.announcement_endpoints::for_callasks the organisation's own endpoints first and falls back to the deployment's for an id that is not one of them, so another organisation's own endpoint stays unresolved. What the endpoint is told is still built for the call's own organisation; only the level (none,organisation,full) is the operator's. - A table of its own.
deployment_announcement_endpointholds one row, not anannouncement_endpointsrow with no organisation, for the reasons the voice bot's is: every organisation-scoped read, name uniqueness and delete guard would otherwise have to learn a row that belongs to nobody. Expanding migration 91. - Always signed. The signing secret is made on the first write when the operator supplies none and is shown
once; a supplied one (at least 32 visible characters) is used as it is and never echoed. It is sealed under the
master key, bound to this table, column and the row's id.
POST .../signing-secretmakes a new one, shown once, and is audited. Operator routes are session-only, as the recording receiver's are. - Address policy on save. Saving an endpoint, the operator's or an organisation's, resolves the host and
refuses unless every address it resolves to is admitted by the
remote_announcementspolicy (SIPHON_PBX_REMOTE_ANNOUNCEMENTS_ALLOW_PRIVATE_NETWORKS,..._TRUST_ANCHORS_FILE); a name that does not resolve is refused. Every request is screened by the same rule again. - Organisations may add endpoints (default on). Off, an organisation cannot create an endpoint or move one's
address (409
organisation_endpoints_not_allowed); a rename, and calls to endpoints it already has, are unaffected. Removing the deployment endpoint is refused while it is off, and while any organisation's draft or live flow names it (the refusal names the flows and their organisations). - What an organisation sees.
GET /api/v1/provided-announcement-endpoint: its id, name and the switch, ornull. An organisation tests it withPOST /api/v1/announcement-endpoints/{id}/test, asked with that organisation's own context. - In the console. The operator console's Announcement endpoint page (beside Voice bot) sets it: name, address, an optional signing secret (blank keeps or makes one, shown once; New secret rotates it), what it is told, and the switch; Remove is disabled while the switch is off and shows the server's 409 as it says it when a flow names it. An organisation's Announcement endpoints page lists it read only with a Test, and holds Add back while the switch is off. In the designer's Remote announcement block it is its own option, "(provided by the operator)", chosen even when the organisation has no endpoint of its own.
announcement-endpoint.yaml, applied withsiphon-pbx announcement-endpoint apply <dir> --as <operator> [--check](compose:announcement-endpoint-apply, profileannouncement-endpoint, the directorySIPHON_PBX_ANNOUNCEMENT_ENDPOINT_DIR, the operatorSIPHON_PBX_ANNOUNCEMENT_ENDPOINT_OPERATOR), sets the deployment endpoint from code, asvoice-bot.yamldoes the bot:
name: Weather
url: https://audio.example.com/announce
signing_secret_file: signing-secret # required: at least 32 visible characters, e.g. `openssl rand -hex 32`
context: organisation # optional: none, organisation or full; left out keeps the stored value
organisations_may_add_endpoints: true # optional; left out keeps the stored value
The secret is a file inside the directory, never a value and never an argument, and is required: a
deployment configured from files holds the secret in its own store and gives the receiver the same one, so
nothing is made and shown once. Every refusal is named at once, by the console's own checks plus the address
policy; the comparison opens the stored secret, so an unchanged file writes and records nothing. The last line
is announcement-endpoint: unchanged, changed (<keys>) or, with --check, would change (...). The apply
reads SIPHON_PBX_REMOTE_ANNOUNCEMENTS_ALLOW_PRIVATE_NETWORKS as the server does and checks the address only
(resolved and admitted); it never connects, so it needs no CA file and reads none.
First start¶
- A one-shot
initcontainer generates the Postgres password and the master key into a named volume. Secrets are never passed on a command line. - While no operator exists, siphon-pbx logs a one-time link to the operator address with a code, so a freshly started box on a public address cannot be claimed by whoever reaches it first. The link creates the first operator.
- The operator creates an organisation, gives it a hostname and invites its first administrator.
- The invite opens setup on the organisation's hostname: the organisation's name and time zone, the administrator's name and password, and optionally a range of extensions. TLS, SIP passwords, a first trunk and an AI provider join that wizard as each of them lands.
- siphon-pbx renders siphon-sip's configuration and siphon-sip starts with it.
.env exists only for optional overrides; a working system needs none.
Security defaults¶
- siphon-sip's automatic banning of abusive sources is on.
- No default passwords anywhere; SIP credentials are generated.
- Toll-fraud guard: outbound destinations are allow-listed and each extension has rate and spend limits.
- TLS and SRTP wherever the peer supports them.
- The UI uses the same public, authenticated API as any integration; there are no private endpoints.
- A session works only for the organisation it was started for, or only at the operator address; over
HTTPS its cookie carries the
__Host-prefix.SECURITY.mdsays what the Host header decides and what it does not. - Outbound mail requires STARTTLS or TLS with verified certificates; clear text is refused to anything but a loopback relay, and the SMTP password is sealed and write-only.
- An operator acting as an organisation is bounded, attributed and visible: a five-minute one-time link, a 30-minute session tied to the operator session it was made in, every change in the organisation's own audit log under the operator's name, a banner with the way out on every screen, and three carve-outs refused server-side.
- siphon-sip's admin API is bound to loopback, published nowhere, and gated on a token with
auth.protect_readsset. The default is that a token gates only the mutating routes and everyGETstays open, which on that API means the registration list — every extension's number, contact address and expiry — readable by anything that can reach the port. The token is a sixth secretinit-secretscreates, written into siphon-sip's 0600 configuration as a literal rather than as an environment variable for the reasonSECURITY.mdgives, and the same token is what enables siphon-sip's log tail. - A refused admin token latches instead of being retried. siphon-sip scores every failed admin
authentication into the same auto-ban store
failed_auth_banuses, so a console polling every 30 seconds with a stale token would steadily score siphon-pbx toward banning its own address. The first refusal logs what is wrong and stops siphon-pbx presenting the token until it is restarted. - The System view is the operator's alone and there is no read-only version of it inside an organisation. Every number in it is the whole machine's — one registrar, one engine session table, one control connection for every organisation — so there is nothing to narrow to one tenant, and a route that belongs to the operator address answers 404 anywhere else.
Address rules, in two layers¶
Which addresses may reach the deployment is decided in two places, and the split is what keeps one organisation from shutting out another.
- The operator's country and network rules apply to every site, every call and every registration, and
are decided inside siphon-pbx (
geo, migration 0075), not in the proxy. They come first in each of the three gates below:site::resolvefor every site, the console included;DatabaseResolver::resolvefor a call that reached an organisation; and/internal/registration-access, before the realm is looked at, so a phone at a refused place registers to no organisation. Deny wins; a non-empty allow list admits only what it names; an address the database cannot place isUNK, which a list names explicitly. Each dimension (country, ASN) is decided on its own and both must allow. A refused request is403 access_refusedwith a message naming the operator rather than the organisation; a refused call is403 Forbidden, logged atinfowith the address, its country, its ASN and the Call-ID, and counted assiphon_pbx_calls_ended_total{outcome="geo_refused"}. A call that reached nothing is not judged by them: it is refused or dropped anyway, and a 403 to a stranger's probe would undo the silence it is met with. The databases are the operator's own downloads under their MaxMind licence (SIPHON_PBX_GEOIP_DIR, layerdocker-compose.geoip.yml), read by themaxminddbcrate,verify()ed on every load, and reloaded when a file changes; a refused file keeps the previous database. A rule needs its database at write time (409 geo_database_missing), and a rule whose database disappears later is ignored, which fails open, with awarn!every minute and a console banner: refusing everyone over a missing file would lock the operator out too. A write that would refuse the operator's own address is409 access_would_refuse_you;siphon-pbx geo clear --as <operator>is the way back from elsewhere. One copy of the rules per process, five seconds, shared by the three gates. - The operator's address rules are enforced by the reverse proxy, rendered from the console
(
proxy_rules, migration 0076). Three lists of networks:denyandallowfor the whole deployment, andconsole_allowfor the operator console alone. On the HTTPS site they areremote_ipmatchers, the address that connected to Caddy, answeredrespond 403with a one-line plain body before the request reaches siphon-pbx (a branded page would have to come from siphon-pbx, which a refused address must not reach); the console list is matched together withhost <operator address>, so organisations' sites are not affected by it. On the 5061 layer4 route the deployment-wide lists are caddy-l4'sremote_ipmatcher on a route ahead of the serving one whose only handler isclose, so a refused phone's connection is closed before its TLS handshake. Deny wins; a non-empty allow list admits only what it names; no rules render nothing, which keeps the default render byte for byte. A/0is refused. The address siphon-pbx reads for a request through Caddy (X-Forwarded-For, believed from Caddy alone, which writes the address it accepted and ignores a client's) is the one Caddy's matchers see, so a write that would refuse the operator's own address at the console is refused (409 access_would_refuse_you). A write is applied before it is committed:proxy_rules::setwrites the rows in a transaction holding a lock on the table, loads the render into Caddy, writes it as the file Caddy restarts on, and only then commits. A render Caddy refuses (502 proxy_refused) or a Caddy that cannot be reached (503 proxy_unreachable) rolls the rows back and leaves Caddy as it was, so the database never claims a rule the proxy does not enforce. That order was chosen over committing first because the proxy's answer is the step most likely to fail; should the commit itself fail after Caddy took the render, Caddy is put back on the stored rules. The lock serialises two writes, so Caddy ends on the one that committed last.init-proxyreads the stored rules too, so a stack started again runs them from its first request; a database without the table yet has none, and a database it cannot read stops it, and Caddy with it, rather than starting the proxy open.siphon-pbx proxy reset --as <operator>clears them from the server for an operator they shut out, and the console's "Reload proxy" loads what is stored again. Each node's write loads its own proxy only: with several nodes, another node's Caddy keeps its rules untilproxy applyor its next start there. - The operator's rate limit rides with the address rules (
AddressRules::rate_limit, migration 0077, a one-row table). It is caddy-ratelimit'srate_limithandler (caddy-siphon 0.3.0) in one zone,per_address, keyed by{remote_host}(the address that connected: Caddy trusts no proxy in front of it), withipv6_prefix 64so one subscriber cannot spread its requests over its /64. Past the limit an address is answered429withRetry-Afteron every HTTPS site; the 5061 route is not limited. The handler's own place in Caddy's directive order is ahead ofrespond, so a site with a limit is rendered inside oneroute, where the written order holds: the refusals, the limit, thenreverse_proxy. A site without one is rendered exactly as before. The floor (proxy_rules::MIN_EVENTS, 100 in the window, andMIN_EVENTS_PER_MINUTE, 100 a minute) is what keeps the console usable under any limit: a load of it is about thirty requests (page, script, style, three fonts, icons, then the view's own calls, nine at once on the System view) and an open console polls. The floor is checked in Rust, in the console, and by the table's CHECK. It is one write with the lists: the same load-then-commit, the same502/503, andproxy resetremoves it too. Caddy keeps a zone's counts across loads by its name, so changing the limit does not forget what each address sent; clearing it stops counting at once. Counts are per Caddy, so with several nodes each node's proxy counts its own. - The wildcard certificate (
wildcard_certificate, migration 0080, a one-row table) is rendered as a site of its own,*.<base>, beside the on-demandhttps://site, with the same handling (caddy::site_bodyrenders both: refusals, rate limit,reverse_proxy). Caddy gives the explicit*.<base>policy precedence over the on-demand catch-all, and at a handshake certmagic takes a cached exact certificate, then a cached wildcard, before it would issue on demand, so a name one label under the base is served the wildcard and never gets one of its own; caddy-l4'stlshandler goes through the same automation, so SIP over TLS on 5061 does too.certificates::allowedalso answers 404 for such a name, so even an ask the policy should never make cannot put the name in a transparency log. Itstlsrestates the deployment's issuer: with ACME,issuer {$SIPHON_PBX_CERTIFICATE_ISSUER:acme} { dns <provider> {...} }, so a staging directory carries over; withinternal,issuer internaland no credentials at all (which is howtls.shproves the site without a real zone). Hence siphon-pbx and init-proxy readSIPHON_PBX_CERTIFICATE_ISSUERtoo. The credentials are sealed under the master key (bound to the table, column and row id), opened only to render, and written into the proxy's0640file as literals rather than{env.*}: the setting is changed in the console, and Caddy's environment cannot change without a restart. With a wildcard rendered under ACME the global options gainpersist_config off, so Caddy's autosave on its own volume is not a second copy. Each value is checked to be one plain Caddyfile token of the provider's own form (Cloudflare's exactly as the plugin checks it, because the plugin quotes a token it refuses into Caddy's log), andcaddy::redacttakes the credentials out of any refusal before it is logged or answered. A write is the same load-then-commit under the same lock as the address rules (proxy_rules::lockandload_then_commit), and every write of either restates the other, since a load replaces the whole configuration.proxy resetkeeps it. Limits: a name with its own certificate already in Caddy's cache keeps it until Caddy restarts; until the wildcard is issued, a name under the base is not served (the policy is not on demand), which is why a base the console sits under is refused;*.<base>does not cover<base>or a name two labels under it, which stay on demand. Real DNS-01 issuance is proven only on a live deployment. - What they are rendered into: siphon-pbx renders Caddy's whole configuration (
siphon_pbx_core::caddy),init-proxywrites it onto theproxyvolume before Caddy starts, andsiphon-pbx proxy applyposts a render to Caddy's/loadand writes it to that volume once Caddy has taken it.init-proxydoes the same load (Proxy::apply) when a Caddy answers on the admin socket, because an upgrade'sdocker compose uprecreates it and leaves Caddy running on the old render: no socket or no answer (a first start) only writes the file, and a Caddy that answers and refuses fails init-proxy with Caddy's reason, so the deploy stops rather than reporting a render that is not running. A render Caddy refuses changes nothing, in Caddy or on disk. The admin API listens on a unix socket on that volume only, never on a network, and every render restates it, because a load replaces the whole configuration. Caddy runs as root withoutCAP_DAC_OVERRIDEand siphon-pbx as uid 10001, so they share the socket and the file through one group (10001) that both containers are given, on a setgid directory: socket0660, file0640, nothing open to anyone else. - An organisation's own rules (
access_rules, migration 0072) are set by its administrator under Settings, and decided insite::resolveonly after the hostname has resolved the request to that organisation. So they can refuse that organisation's own traffic and nobody else's. Deny wins; once there is an allow rule only allowed networks are served; with no rules everyone is. A refusal is403 access_refused, logged atinfowith the organisation and the address. The status and the brand's files stay open so the page can say why. - The same rules apply to calls and to registrations. A call is checked in
DatabaseResolver::resolve, the one gate every resolution to a flow passes, against the organisation the call resolved to and itssource_ipfrom siphon-sip's handover. A refused call is answered403 Forbiddenbefore anything runs, logged atinfowith the organisation, the address and the Call-ID, and counted assiphon_pbx_calls_ended_total{outcome="access_refused"}. Every source is judged, a carrier's, Microsoft's (Teams) and an S-CSCF's (IMS) included, because the rule is the organisation's own choice about its own calls; the UI warns that denying your carrier, or allowing only your office, stops your inbound calls. A handover that names no source is refused by an allow list and admitted by rules of deny alone. - A REGISTER is checked by
pbx_register.pyonce its digest has passed: it asksPOST /internal/registration-accesswith the digest realm and the source, and only that realm's organisation's rules are read. Only a403refuses (answered403 Forbidden, not bound). Anything else, siphon-pbx unreachable included, registers the phone and logs a warning, so a restart of siphon-pbx cannot take every phone off. A binding held before a rule was added lapses at its expiry, since its refresh is refused. The third-party REGISTER an S-CSCF sends is not checked: it is not a phone registering here. - Behind the TLS proxy, siphon-sip reads the phone's own address from the PROXY header before the handshake
(
listen.tls[].proxy_protocol,accept_proxiedin siphon-sip'stransport/tls.rs), and that is the address both checks see. - The API and the call resolver share one copy of the rules per process, so a rule saved on a node counts for that node's next call as well as its next request.
- An organisation's rules are never rendered into the proxy, into siphon-sip's
securityblock or into any other state the organisations share: that is how a trunk's address once reachedtrusted_cidrsfor the whole machine. - The client address is the one
ClientAddressdecides (X-Forwarded-Foronly from a trusted proxy). An IPv4 address written as IPv6 is compared as IPv4. - A change that would refuse the address it was made from is refused with
409 access_would_refuse_you. An operator can clear any organisation's rules from the console. An operator acting as the organisation is held to its rules like anyone else. - Each process keeps a copy of an organisation's rules for five seconds and drops it on its own writes. There is no notification between nodes, so a change made on one node reaches another within those five seconds.
Crates¶
| Crate | Responsibility |
|---|---|
siphon-pbx-flow |
flow model, validator, executor, queue engine, simulator; no I/O |
siphon-pbx-core |
domain (extensions, queues, schedules, voicemail, CDR), Postgres |
siphon-pbx-api |
HTTP API, authentication, event stream, embedded UI |
siphon-pbx-control |
the live adapter: engine commands to control-plane verbs, events back |
siphon-pbx (bin) |
wiring, siphon-sip configuration rendering, setup mode |
None of them links siphon-sip; siphon-pbx speaks to it over the control plane only. Crates are added in the change that gives them real content.