Integrator API¶
How a system you run provisions an organisation on a siphon-pbx deployment with no browser session: with an operator token, over HTTPS, in JSON. This is the contract. A route is in this document or it is not part of it; a field not named here is refused.
Everything below sits under /api/v1 on the operator address of the deployment (the one the operator
console is served on, such as https://pbx.example.com), never on an organisation's own hostname: a token is
nobody there.
Each section says which scope a route needs. The scopes are listed in Scopes. The routes are for trunks, for extensions and their SIP credentials and for numbers and the default flow, and for web calls (a token that lets a browser call into a flow). Nothing else of an organisation has a route here: a request for any other path under an organisation is refused to a token.
The machine-readable description of this API is the OpenAPI 3.1 document at GET /api/v1/openapi.json on the
operator address. It needs no token. It also describes the organisation and voice bot routes that are not in
this document, and POST /api/v1/calls (placing a call with an organisation API token).
Authentication¶
Send the token as a bearer credential:
- Issuing one. An operator issues a token at the console's API tokens page, or from configuration management
with
siphon-pbx operator-token issue(the compose stack'soperator-tokenone-shot). The variables and the command are in configuration.md (SIPHON_PBX_OPERATOR_TOKEN_*) and in the operator tokens section of architecture.md. The token is shown once and acts as the operator who issued it, within its scopes, for 1 to 365 days (90 by default). Only a SHA-256 of it is stored. - No cookie, no
Origin, noX-Requested-With. A request that presents anAuthorizationheader is decided by the token alone; a cookie beside it is never read. A request with anOriginheader is refused with 403token_from_a_browser: a token is for programs. - A token that is not valid (unknown, revoked or expired, one answer for all three) is 401
invalid_token. - A token without the scope the route needs is 403
missing_scope. A route no token may use is 403session_only. - Every change a token makes is recorded in the audit log as the operator, with the token's name, in the organisation's own log. Every refusal of a token that exists is recorded in the deployment's own log.
Errors¶
Every error answer is JSON of one shape, and the code is what a client branches on:
{ "error": { "code": "missing_scope", "message": "this operator token does not have the trunks:write scope" } }
The message is for people and may be reworded; the code is stable. The codes the routes in this document can
return, besides the ones above, are:
| Status | code |
Meaning |
|---|---|---|
| 404 | not_found |
The organisation, the trunk, the extension or the flow does not exist (an id that is not an id too); or a number or block to detach that is not attached; or "flow": "default" where the organisation has no default flow. |
| 409 | conflict |
The request clashes with what exists, such as a source network another organisation holds, no master key on the deployment to seal a password under, an extension a flow still uses, an organisation with no SIP domain, a mailbox the extension already has, or a number, block of numbers or catch-all another flow already holds. |
| 409 | draft_pending |
A flow has changes nobody has published (or was never published), so a number is not attached to or detached from its live version. See Numbers and the default flow. |
| 409 | flow_exists |
The default flow was asked for and the organisation has a flow of that name. The answer carries its id as error.flow_id. |
| 409 | no_deployment_voice_bot |
The default flow was asked for and the deployment has no voice bot. |
| 422 | invalid |
The body was read and a value is refused: a setting out of range, a combination that does not fit, a name that does not match the address, a number that cannot be an extension, a voicemail that differs from the extension's mailbox. |
| 422 | bad_request |
The body is JSON but not the shape the route takes: an unknown field, a missing required field, a value of the wrong type. |
| 400 | bad_request |
The body is not JSON. |
| 415 | bad_request |
A body was sent without Content-Type: application/json. |
| 503 | database |
The database could not complete the request; repeat it. |
A response to every route in this document carries Cache-Control: no-store.
Scopes¶
| Scope | Opens |
|---|---|
organisations:bots |
GET of an organisation's own voice bots, PUT of one by name and DELETE of one by id. A secret-bearing scope with no separate secrets scope: it sets the bot's secret, the address the call's audio is streamed to and what the bot is told about each call. It reaches neither the bot the deployment provides (voice-bot:write) nor any flow. |
trunks:read |
GET of an organisation's trunks. |
trunks:write |
Creating, changing and deleting an organisation's trunks, except what moves or sets a password. |
trunks:secrets |
Setting, replacing or clearing a trunk's password, and moving a trunk that holds one. It opens no route of its own: it is used beside trunks:write. |
extensions:read |
GET of an organisation's extensions. Never a credential. |
extensions:write |
Creating, renaming and deleting an organisation's extensions, giving one its mailbox, and setting its registration, outbound caller id and outbound flow. Reaches no credential: not to issue, rotate, revoke or read one, by any route. |
extensions:credentials |
Issuing, rotating and revoking the SIP credential of an extension. It opens the two credential routes and nothing else; it does not read or write extensions, so a system that provisions phones holds it beside extensions:write. |
numbers:read |
GET of an organisation's numbers: every number, block of numbers and catch-all its live flows claim, and the flow each leads to; and GET of the numbers the organisation owns. |
numbers:write |
Making an organisation the owner of a number or a block of numbers, and taking one away; and attaching a number or a block of numbers to one of the organisation's flows, and detaching it. Each attach or detach is a new published version of that flow. It reads and edits nothing else of a flow. |
flows:write |
Applying the default flow to an organisation. It writes no other flow. |
calls:web |
Asking for a web-call token for an organisation, and reading back what became of one. It costs the organisation calls, so no other scope implies it. The organisation's limits on web calls are read with organisations:read and set with organisations:write. |
The scopes for organisations and the voice bot (organisations:read, organisations:write, voice-bot:write)
are described in architecture.md. No scope reads a flow's blocks: an operator token has no
flows:read, and flows:write and numbers:write write only what their section says.
A token reaches an organisation's secrets never, unless it carries a secret scope. There are two (plus organisations:bots, below):
trunks:secrets and extensions:credentials; organisations:bots is a third that opens its own routes. Issue trunks:secrets only to a system you trust with the carrier
credentials of every organisation: a token that holds it can send any organisation's trunk password to a host it
names. Issue extensions:credentials only to a system you trust to register phones: a token that holds it can
issue a password for any extension of any organisation, and register a phone of its own as that extension.
Trunks¶
A trunk is an organisation's account with a carrier. Its name is unique in the organisation and is the key
you provision it by. Its id is a UUID the server makes.
{organisation} below is the organisation's id, as the operator organisations routes return it. Percent-encode a
trunk name in a path (Main carrier is Main%20carrier).
The trunk, as it is read¶
{
"id": "0b6c3f5e-2a4d-4e0f-9a4b-1c2d3e4f5a6b",
"name": "Main carrier",
"direction": "both",
"host": "carrier.example.com",
"port": 5060,
"transport": "udp",
"authentication": "digest",
"carrier_identifies_us_by": "number",
"diversion_headers": "both",
"media": "auto",
"username": "office-pbx",
"has_password": true,
"realm": "carrier.example.com",
"registers": true,
"registration_interval_secs": 600,
"contact_user": "0123456789abcdef0123456789abcdef",
"source_networks": ["198.51.100.0/24"],
"created_at": "2026-11-20T09:00:00Z",
"updated_at": "2026-11-20T09:00:00Z",
"owner_node": null,
"handoff_node": null,
"preferred_node": null,
"outbound_via_owner": false,
"carries_extensions": false,
"proxy": null,
"registration_user": null
}
The password is never in an answer. has_password says whether one is stored. contact_user, owner_node
and handoff_node are the server's: they are read, never written.
The trunk, as it is written¶
The body of PUT is exactly these fields, and an unknown field is refused 422 bad_request. A field marked optional
may be left out.
| Field | Type | Meaning |
|---|---|---|
name |
string | Required. 1 to 80 characters after trimming; must equal the name in the path. |
direction |
"inbound", "outbound", "both" |
Required. Which calls the trunk carries. |
host |
string | Required. A DNS name or an IP address. |
port |
integer | Optional. Left out, the carrier is found by DNS (SRV first, then the transport's default port); a port given turns SRV off. |
transport |
"udp", "tcp", "tls" |
Required. |
authentication |
"ip", "digest" |
Required. ip: the trunk is known by source_networks, with no username, password or realm. digest: it has a username and a password, and may register. |
username |
string | Required for digest, refused for ip. Printable ASCII, no spaces, quotes or backslashes, at most 128. |
password |
string | Write-only; see below. At most 256 characters, no control characters, no ${. |
realm |
string | Optional, digest only. Any realm the carrier challenges with, if left out. |
registers |
boolean | Optional, false if left out. Only a digest trunk registers. |
registration_interval_secs |
integer | Optional, 3600 if left out. 60 to 86400. |
source_networks |
array of strings | Optional. CIDR networks or single addresses the carrier sends from. No two overlap, and none overlaps another organisation's (409 conflict). |
carrier_identifies_us_by |
"number", "account" |
Optional, "number" if left out. account needs digest. |
diversion_headers |
"both", "history_info", "diversion", "none" |
Optional, "both" if left out. |
media |
"auto", "plain", "srtp" |
Optional, "auto" if left out (SRTP over TLS, plain RTP otherwise). |
preferred_node |
string | Optional. A registering trunk is registered from that node whenever it is running. |
outbound_via_owner |
boolean | Optional, false. Only for a trunk that registers. |
carries_extensions |
boolean | Optional, false. Not for an inbound trunk. |
proxy |
string | Optional outbound proxy: a SIP URI such as sip:sbc.example.com:5060;transport=udp (sips: is TLS), no user part, no parameter but transport. Every request of the trunk is sent there while host stays the registrar and account domain, for a carrier whose domain has no DNS record. Resolved by A/AAAA, never SRV: with no port it goes to 5060 (5061 over TLS), so give a port when the carrier's is not that. Empty or null: none. Changing it on a trunk that holds a password needs trunks:secrets. |
registration_user |
string | Optional registration number: the user part of the address of record the trunk registers under (sip:<registration number>@<host>, the To and From of its REGISTER), for a carrier that wants a phone number there while username is used only in the Digest Authorization. A SIP user part of at most 64 characters: letters, digits, -_.!~*'()&=+$,?/ and %HH escapes (a leading + is fine); no @, :, ; or whitespace. Empty or null: the username is the user part. Not for an ip trunk. Changing it on a trunk that holds a password needs trunks:secrets. |
The password. A digest trunk needs one when it is created. On a change, a body with no password (or an
empty one) keeps the stored password. A body with a password replaces it. A change to ip authentication clears
it. The deployment must have a master key configured, or a password cannot be sealed and the answer is 409
conflict.
GET /operator/organisations/{organisation}/trunks¶
Scope trunks:read. The organisation's trunks, by name, as an array of trunks. An organisation with none is [].
- 200: the array.
- 404
not_found: no such organisation.
GET /operator/organisations/{organisation}/trunks/{trunk_id}¶
Scope trunks:read. One trunk.
- 200: the trunk.
- 404
not_found: no such organisation, or no such trunk in it (another organisation's trunk id is not found either).
PUT /operator/organisations/{organisation}/trunks/by-name/{name}¶
Scope trunks:write; trunks:secrets as described below. Set the trunk of this name to exactly the body:
create it if the organisation has none, change it if it has one. The body is the written trunk above, and its
name must equal {name} (compared after trimming, case-sensitively). This route never renames a trunk.
- 201 and the trunk: it did not exist and was created.
- 200 and the trunk: it existed and was set to the body. Sending a body that is already what is stored is
answered 200 and changes nothing a client could see (
updated_atmoves). - 403
missing_scope: the token lackstrunks:write, or the body needstrunks:secretsand the token lacks it. - 404
not_found: no such organisation. - 409
conflict: a source network another organisation holds, or no master key for a password. - 422
invalid: a value refused, or a body whosenameis not{name}; 422bad_request: a body of the wrong shape.
Idempotency. The name is the key: repeating the request, or two requests at once, ends with one trunk and never an error for the second. Exactly one of two concurrent first requests is answered 201 and the other 200. The body is the whole state: a field left out takes its default, it is not kept from before (only the stored password is kept when none is sent).
What trunks:secrets governs. Without it, the request is refused with 403 missing_scope (the message names
trunks:secrets, the refusal is recorded against the token, and nothing is written) when it would:
- set or replace a password (a non-empty
passwordin the body), on a new trunk or an existing one; - clear a stored password (change an existing
digesttrunk that holds one toipauthentication); - move a trunk that holds a password: change its
host,portortransport, which would send the stored password to a different destination.
A token without it can still create a trunk with no password to guard (ip authentication), change anything
about such a trunk, and change a digest trunk that holds a password in any way that sets, clears and moves
nothing (its interval, its networks, its direction, its username or realm). A digest trunk is created with a
password, so creating one needs trunks:secrets; a digest body with no password is 422 invalid instead.
The two secret checks are decided against the stored trunk inside the write, so a password stored by another request while yours is in flight cannot slip through.
DELETE /operator/organisations/{organisation}/trunks/{trunk_id}¶
Scope trunks:write. Delete the trunk, its stored password and its source networks. A registering trunk is
de-registered from the carrier.
- 204, no body.
- 404
not_found: no such organisation or trunk, which includes a trunk already deleted: repeating a delete answers 404, and the way to be idempotent is to treat that 404 as done.
Effects of a write¶
A write has the same effects as the same change made in the organisation's console: siphon-sip is asked to re-read the trunks and carriers siphon-pbx serves it, the trunk's DNS name is resolved again, and the node that registers the trunk decides again at once. A trunk that registers is therefore registering within seconds, without a restart of anything.
Voice bots¶
An organisation's own voice bots, for a system that switches an organisation between the bot the deployment
provides and one of its own. Scope organisations:bots for all three routes, which reaches neither the
deployment's bot (voice-bot:write) nor any flow. A voice block that names no bot reaches the organisation's bot
while it has exactly one, and the deployment's bot while it has none; so an organisation set up this way has one.
GET /operator/organisations/{organisation}/voice-bots: the organisation's bots,[]for none. Each is read as the organisation's own route reads it (id,name,endpoint,has_secret,context,media,audio,prepare_url,instance_domain,created_at,updated_at, ...). The secret is never returned.PUT /operator/organisations/{organisation}/voice-bots/by-name/{name}: set the bot of this name to exactly the body, 201 when created and 200 when set. The body:name(must equal the path, else 422invalid),endpoint(wss://, orws://where the operator allows it, same screening as the organisation's route),secret(write-only, needed the first time; absent or empty on a change keeps the stored one), and optionallycontext,media,audio,prepare_urlandinstance_domain, which default as the organisation's route does.DELETE /operator/organisations/{organisation}/voice-bots/{bot_id}: 204; 404 for none or one already gone.
409 organisation_bots_not_allowed while the operator lets organisations use only its own bot; 409 conflict when
the organisation already has a bot of another name, and on a delete while a draft or live flow names the bot. Every
write is in the organisation's audit log as the operator, with the token's name.
Extensions and their SIP credentials¶
An extension is a number inside an organisation (2 to 6 digits, not starting with 0) with a name, usually a mailbox of its own, and a phone that registers as it. Its number is unique in the organisation and is the key you provision it by. A phone registers with a SIP credential: the username is the extension's number, the realm is the organisation's SIP domain, and the password is generated by the server.
{organisation} is the organisation's id and {number} the extension's number.
The extension, as it is read¶
The same JSON the organisation's own extensions list returns:
{
"number": "201",
"name": "Front desk",
"mailbox": "0b9d7a5e-0000-4000-8000-000000000001",
"holder": null,
"outbound_caller_id": null,
"outbound_flow_id": null,
"registration_allowed": true,
"do_not_disturb": false,
"forwarding": { "always": null, "busy": null, "no_answer": null, "no_answer_seconds": 20 }
}
mailbox is the id of the extension's own mailbox, or null when it has none. holder, do_not_disturb and
forwarding are the organisation's own to set and have no route here. No answer carries a credential or its
digests: whether an extension has one is not readable with extensions:read.
GET /operator/organisations/{organisation}/extensions¶
Scope extensions:read. The organisation's extensions, by number length then number, as an array. An
organisation with none is [].
- 200: the array.
- 404
not_found: no such organisation.
GET /operator/organisations/{organisation}/extensions/{number}¶
Scope extensions:read. One extension.
- 200: the extension.
- 404
not_found: no such organisation, or no such extension in it.
PUT /operator/organisations/{organisation}/extensions/{number}¶
Scope extensions:write. Set the extension of this number to this name: create it if the organisation has
none, rename it if it has one. The body:
| Field | Type | |
|---|---|---|
name |
string | Required. Trimmed; not empty. A mailbox of its own is named after it, so it is renamed with it. |
voicemail |
boolean | Optional. Takes effect at creation only. See below. |
A field not named here is 422 bad_request.
- 201 and the extension: it did not exist and was created, with a mailbox of its own unless
voicemailisfalse. - 200 and the extension: it existed and was renamed. Repeating a request that is already what is stored is answered 200.
- 403
missing_scope: the token lacksextensions:write. - 404
not_found: no such organisation. - 422
invalid: the number is not an extension number (digits only, 2 to 6, not starting with 0), is longer than the organisation's dialling plan allows, or is one of its emergency numbers; the name is empty; orvoicemailis refused as below. - 422
bad_request: a body of the wrong shape.
Idempotency. The number is the key: repeating the request, or two requests at once, ends with one extension and never an error for the second. Exactly one of two concurrent first requests is answered 201 and the other 200.
voicemail. Left out, a new extension gets a mailbox and an existing one is not asked. Given, it is applied
when the extension is created. On an extension that exists, a voicemail that differs from whether it has a
mailbox now is refused with 422 invalid, and nothing is changed (not the name either): the answer says to
use the mailbox route (POST …/mailbox) to give an extension its mailbox. It is never silently ignored. Taking
a mailbox away, with its messages, is the organisation's to do and has no route here, so voicemail: false
on an extension that has one is refused too.
DELETE /operator/organisations/{organisation}/extensions/{number}¶
Scope extensions:write. Delete the extension, its credential and its own mailbox with its messages. As in the organisation's console, an extension that a flow or a queue names, that is the target
of another extension's forward, or whose mailbox a flow records into is held back.
- 204, no body.
- 403
missing_scope. - 404
not_found: no such organisation or extension, which includes one already deleted: repeating a delete answers 404, and the way to be idempotent is to treat that 404 as done. - 409
conflict: something still uses it; the message says what.
PUT /operator/organisations/{organisation}/extensions/{number}/registration¶
Scope extensions:write. Body {"allowed": true | false}. Whether the extension's phone may register. Off, its
REGISTER is refused, the bindings it holds are dropped on every node and nothing is rung for it; the extension
stays a valid target (it reads as unavailable) and its credential is kept, so on again the phone registers
with the password it has. Setting what it already is changes nothing.
- 200 and the extension. 404
not_found. 422bad_requestfor any other field.
PUT /operator/organisations/{organisation}/extensions/{number}/outbound-caller-id¶
Scope extensions:write. Body {"outbound_caller_id": "+15550100"}, or null for the trunk's own. The number
calls from the extension show. It must be one of the organisation's own numbers (the list under Trunks, see numbers:write), written as
digits with an optional leading +, 7 to 15 of them; any other is 422 invalid and the setting is left as it
was.
- 200 and the extension. 404
not_found. 422invalid.
PUT /operator/organisations/{organisation}/extensions/{number}/outbound-flow¶
Scope extensions:write. Body {"outbound_flow_id": "<flow id>"}, or null for the organisation's own. The
outbound flow calls placed from the extension run. It must be an outbound flow of the organisation's own: another
organisation's flow is 404 not_found, and an inbound flow is 422 invalid.
- 200 and the extension. 404
not_found. 422invalid.
POST /operator/organisations/{organisation}/extensions/{number}/mailbox¶
Scope extensions:write. No body. Give the extension the mailbox of its own: the way to turn voicemail on for an
extension that was created without it.
- 201 and the mailbox (
id,name,greeting,max_message_secs,extension,members,email_delivery). - 404
not_found: no such organisation or extension. - 409
conflict: it already has one.
POST /operator/organisations/{organisation}/extensions/{number}/credential¶
Scope extensions:credentials (and only that: extensions:write alone is refused). Issue the extension's
SIP credential, or rotate it if it has one. No body.
- 201 with
Cache-Control: no-store. Thepasswordis in this answer only: the server keeps its MD5 and SHA-256 digests (RFC 7616) and not the password, so it cannot be shown again, is in no other answer and in no audit entry. Keep it from this answer, or rotate. - Rotating (issuing again) invalidates the previous password at once: siphon-sip is told to drop what it cached of it on every node. Rotation is not idempotent by design: each request makes a new password.
- 403
missing_scope: the token lacksextensions:credentials. The message names it; the refusal is recorded in the deployment's audit log against the token, and nothing is written. - 404
not_found: no such organisation or extension. - 409
conflict: the organisation has no SIP domain yet (the operator gives it one, withorganisations:write); the digests are made for it. If the SIP domain is changed afterwards the credential no longer matches and is issued again.
The credential is written as it is in the organisation's console: an entry credential.issued in the
organisation's audit log as the operator with the token's name, and siphon-sip's cache is dropped.
DELETE /operator/organisations/{organisation}/extensions/{number}/credential¶
Scope extensions:credentials. Revoke the credential: the phone can no longer register.
- 204, no body,
Cache-Control: no-store. - 403
missing_scope. - 404
not_found: no such organisation, extension, or credential, which includes one already revoked: repeating a revoke answers 404, and the way to be idempotent is to treat that 404 as done.
What extensions:credentials governs. A credential is a secret: whoever can issue one can register a phone as
that extension and place and receive its calls. The server therefore decides it twice: the route table asks
for extensions:credentials, and the write asks again, from how the request was authenticated. An operator signed
in to the console is refused as it is inside a view of the organisation (403 secret_in_a_view), and a token
without the scope is refused with 403 missing_scope. A token with extensions:write or extensions:read has
no route to read, set or rotate a credential.
Effects of a write¶
A write has the same effects as the same change in the organisation's console: a registration or credential
change asks every node to drop siphon-sip's cache of the credential, so a phone switched off or rotated stops
registering within moments, not when its cached entry lapses. Every write is one entry in the organisation's
audit log (extension.created, extension.updated, extension.deleted, extension.registration_set,
extension.outbound_caller_id_set, extension.outbound_flow_set, mailbox.created, credential.issued,
credential.revoked) as the operator, with the token's name; a refused request writes nothing there.
Numbers and the default flow¶
A number leads to a flow because that flow's inbound block claims it. There are three ways a flow claims
numbers, and a call takes the most specific that matches: a number named outright, a block of consecutive
numbers (written from to to, both included, 7 to 15 digits each, the same length, not starting with 0), and
the organisation's catch-all, which takes every other number it has. A number leads to one flow on the whole
deployment, so one organisation cannot hold a number another does.
Attaching a number is therefore a change to a flow: a new published version of that flow, made from its live version with the number added to its inbound block. The same publish an administrator makes in the console does it, in one transaction, so what a number may be, who else may hold it and what the flow must still satisfy are that publish's own rules, with its own refusals. A request never changes a draft that somebody is editing, and never leaves one half-made: it either publishes the new version or changes nothing.
A flow may claim only numbers its organisation owns. The organisation's own list, the one its administrator keeps under Trunks, is what an attach is held to: a number or block that is not all in it is refused, exactly as the administrator's own publish of that flow refuses it. So a number is owned first (see the owned numbers) and attached second; with a token and no browser, both are done here.
{organisation} is the organisation's id, {number} a dialled number (digits with an optional leading +;
+15550123 and 15550123 are the same number, and the one already stored is kept as it was written) and
{range} a block written from-to, such as 15550140-15550149 or +15550140-+15550149. In a path, + is
literal and may also be sent as %2B.
The numbers an organisation owns¶
An entry of the list is one number or one block of consecutive numbers, optionally assigned to one of the
organisation's trunks. It is read and written as the administrator's /trunks/numbers reads and writes it, by the
same functions, so every rule of that list is these routes' too.
{ "id": "5d0e8b2a-7f41-4c93-b6a0-3e9f1c2d4a5b", "from": "+15550123", "to": "+15550123", "label": "Reception", "trunk": null, "created_at": "2026-11-20T09:00:00Z" }
to is the same as from for a single number.
GET /operator/organisations/{organisation}/owned-numbers¶
Scope numbers:read. The organisation's own numbers and blocks, in number order, assigned to a trunk or not.
- 200: an array of entries as above, empty for an organisation with none.
- 404
not_found: no such organisation.
POST /operator/organisations/{organisation}/owned-numbers¶
Scope numbers:write. Make the organisation the owner of a number, or of a block of consecutive numbers.
Body:
| Field | Type | |
|---|---|---|
from |
string | The number, or the first of the block: digits with an optional leading +, 7 to 15 of them, not starting with 0. |
to |
string | Optional. The last number of the block, which it includes, of the same length. Left out for a single number. |
label |
string | Optional. At most 100 characters. |
trunk |
string | Optional. The id of one of the organisation's trunks to assign it to. |
- 201 and the entry. It is the organisation's own list from then on: its administrator sees it under Trunks, and a flow of the organisation may claim it.
- 403
missing_scope: the token lacksnumbers:write. - 404
not_found: no such organisation, or atrunkthat is not one of its trunks. - 409
conflict: a number in the entry is already held, by this organisation or by any other on the system. A number belongs to one organisation. Nothing is written. - 422
invalid: not a number or a block (the message says which end and why), or a label over the limit. - 422
bad_request: a field this route does not take.
It is not idempotent: owning a number the organisation already owns is the 409 above, so a provisioning system that retries reads the list first, or treats that 409 as done once it has checked whose it is.
DELETE /operator/organisations/{organisation}/owned-numbers/{entry}¶
Scope numbers:write. Take an entry out of the organisation's own numbers; {entry} is the id the list gives.
- 204, no body.
- 403
missing_scope. - 404
not_found: no such organisation, or no such entry (which includes one already removed). - 409
conflict: a live flow of the organisation still claims a number in the entry, or an extension presents one as its caller ID. The message says which. Detach the number from the flow first. A trunk that presented a number the removal leaves outside its own numbers stops presenting it, and that is recorded in the log.
What the numbers are, as they are read¶
{
"numbers": [
{ "number": "+15550123", "flow_id": "0b6c3f5e-2a4d-4e0f-9a4b-1c2d3e4f5a6b", "flow_name": "Main line" }
],
"ranges": [
{ "from": "15550140", "to": "15550149", "flow_id": "0b6c3f5e-2a4d-4e0f-9a4b-1c2d3e4f5a6b", "flow_name": "Main line" }
],
"catch_all": { "flow_id": "7c1e9d20-3b5a-4c6d-8e7f-0a1b2c3d4e5f", "flow_name": "Every call to the voice bot" }
}
numbers are as the flow writes them, by number; ranges have their ends as digits without a +; catch_all is
null when no flow of the organisation takes every other number. What is listed is what a call is routed
from, the claims of the flows' live versions, and not a flow's draft.
GET /operator/organisations/{organisation}/numbers¶
Scope numbers:read. Every number, block and catch-all of the organisation, each with the flow it leads to.
- 200: the object above, with empty
numbersandrangesand anullcatch_allfor an organisation with none. - 404
not_found: no such organisation.
PUT /operator/organisations/{organisation}/numbers/{number}¶
Scope numbers:write. Lead this number to this flow. The body names the flow one of two ways, and exactly
one; any other field, or both, or neither, is refused:
| Field | Type | |
|---|---|---|
flow_id |
string | The id of one of the organisation's flows, as the organisation's flow list gives it. |
flow |
"default" |
The organisation's default flow, found by its name, Every call to the voice bot. |
The answer says which flow and which version is live:
{ "number": "+15550123", "flow_id": "0b6c3f5e-2a4d-4e0f-9a4b-1c2d3e4f5a6b", "flow_name": "Main line", "live_version": 2 }
- 201 and the answer: the number was not in the flow's live version, and a new version that names it is live.
live_versionis that version. - 200 and the answer: the flow's live version already names it. Nothing was written: no new version, no
audit entry.
live_versionis the version that was already live. A number is the same number with or without its leading+, so15550123is answered 200 for a flow that names+15550123. - 403
missing_scope: the token lacksnumbers:write. - 404
not_found: no such organisation; no such flow in it (another organisation's flow id is not found either); or"flow": "default"where the organisation has no flow of that name, which says to apply it or to name a flow byflow_id. - 409
draft_pending: the flow has unpublished changes, or has never been published. See below. - 409
conflict: another flow holds the number. The message says which:... already leads to flow "X"; remove it there firstfor another flow of this organisation, and... was claimed elsewhere just now; try againwhen two publishes raced. A number another organisation owns is not this one's to attach: it is the 422 below. Nothing is written. - 422
invalid: what the flow's validator refuses: the number is not one the organisation owns (the message is the one the administrator's own publish gives,... is not one of the organisation's numbers: add it under Trunks first; own it withPOST .../owned-numbers), the number is not a number (digits with an optional+) or is an emergency number of the organisation's plan or 112 or 911, and the message says so; the flow is outbound, has no inbound block, or has more than one, so which block takes the number is not for a request to say; aflow_idthat is not an id; both offlow_idandflow, or neither; orflowof anything but"default". - 422
bad_request: a field this route does not take.
Idempotency. The number is the key. Repeating a request, or sending two at once, ends with the number once and no error for the second: of two concurrent first requests exactly one publishes a version (201) and the other finds it there (200). Attaching many numbers to one flow at once is safe: they queue on the flow, and each is a version of its own, made on the version before it.
Unpublished changes. Publishing makes the flow's draft the new version, so an administrator's unpublished edit
would go live with the number, or be thrown away by it. A request is therefore refused with 409 draft_pending,
and nothing is changed, when the flow's draft differs from its live version, and when the flow was never
published. Ask the organisation's administrator to publish or discard their changes (a draft equal to the live
version is no change), then repeat the request. The check comes after the idempotent answer: a number the
live version already names is answered 200 whatever state the draft is in, so a retry that arrives after an
administrator has started editing is still answered.
DELETE /operator/organisations/{organisation}/numbers/{number}¶
Scope numbers:write. Take this number away from the flow of the organisation that names it, as a new
published version of that flow without it. No body, and no flow to name: a number leads to one flow.
- 204, no body.
- 403
missing_scope. - 404
not_found: no such organisation, or the number is not attached to any live flow of the organisation, which includes one already detached and one that another organisation holds: repeating a detach answers 404, and the way to be idempotent is to treat that 404 as done. It is 404 and not 204 so that a number mistyped in a deprovisioning request is told apart from one that was removed. - 409
draft_pending: the flow that names it has unpublished changes, as above. - 422
invalid: the flow that names it does not validate as it stands (a refusal of the publish).
PUT /operator/organisations/{organisation}/number-ranges/{range} and DELETE¶
Scope numbers:write. The same as a number, for a block of consecutive numbers, written from-to in the
path. The body of the PUT is the same (flow_id or flow), and so are the answers; the PUT answer carries
the ends as the request wrote them:
{ "from": "+15550140", "to": "+15550149", "flow_id": "0b6c3f5e-2a4d-4e0f-9a4b-1c2d3e4f5a6b", "flow_name": "Main line", "live_version": 3 }
- A block is both ends as numbers of the same length, 7 to 15 digits, not starting with 0, the first not higher
than the last. Anything else is 422
invalid, the message saying which end and why; so is a path that is notfrom-to. Written with or without the+, a block is the same block, and one the flow's live version already claims is 200 with no new version. - A block that overlaps another block of this flow is 422
invalid(a number leads to one flow, and a flow does not claim a number twice); one that overlaps another flow's block of this organisation is 409conflict; a block not all among the organisation's own numbers, another organisation's included, is 422invalid. DELETEdetaches the block with exactly these ends: a part of a block is a different block and is 404. A block not attached, or another organisation's, is 404not_found.
POST /operator/organisations/{organisation}/default-flow¶
Scope flows:write. Give the organisation the default flow: an inbound flow named Every call to the voice
bot that hands every call to the voice bot the deployment provides. No body.
The flow is the catch-all of the organisation, so it takes every number no other flow of the organisation
claims, and anything an administrator draws later wins over it. It claims no number by name: attach numbers to it
with PUT .../numbers/{number} and {"flow": "default"}. It reaches the deployment's bot while the organisation
has no bot of its own, and the organisation's own bot from the moment it sets one up; an organisation with two
bots of its own makes that choice ambiguous, and is refused as below. It is an ordinary flow once it exists:
published as version 1, and the organisation's administrator can edit, publish again, rename or delete it.
It needs a voice bot in the deployment, and no more. The operator's setting that gives organisations created from then on this flow does not govern this route: this is the operator asking for the flow for one organisation, so it applies with that setting on or off.
- 201 and the answer: the flow was created and published, in one transaction.
- 403
missing_scope: the token lacksflows:write. - 404
not_found: no such organisation. - 409
flow_exists: the organisation has a flow of that name (whoever made it, and whether or not it is still the flow it was). The answer carries its id aserror.flow_id, so a retry of this request recognises the flow its first attempt made; nothing is written. A request is therefore safe to repeat, and treating 409flow_existsas done is the way to be idempotent. - 409
no_deployment_voice_bot: the deployment has no voice bot. Nothing is written. - 409
conflict: another flow of the organisation already holds its catch-all (every other number of this organisation already leads to flow "X"; remove it there first). Nothing is written. - 422
invalid: the flow does not validate against the organisation as it is, for instance because it has two voice bots of its own. Nothing is written.
Two requests at once leave one flow: the second is answered 409 flow_exists.
Effects of a write¶
Every change to a flow is one published version, written in the organisation's audit log as the operator with the
token's name, and a call that enters the flow afterwards enters that version; a call already in progress keeps the
version it entered on. An attach or detach writes flow.published (<flow> version <n>) and
flow.number_attached, flow.number_detached, flow.number_range_attached or flow.number_range_detached
(<number or from-to> on <flow>); applying the default flow writes flow.created and flow.published. A request
that changed nothing (a 200, a 404) and a refused one write nothing in the organisation's log; a refusal for a
missing scope is in the deployment's own log. What a number leads to is read by calls from the moment the request
is answered: nothing is restarted.
Detaching a number a call is leading to does not end that call. A number that an extension's outbound caller id shows is no longer one of the organisation's once it is detached, and calls from that extension then show the trunk's number instead.
Web calls¶
A web-call token lets a browser call into one flow (or the flow that claims one number) of an organisation over WebSocket, without registering and without any credential of its own. The organisation's backend asks for the token, hands it to the page, and the page puts it on its INVITE. The token is single use and lives 10 to 120 seconds (30 unless asked). Only its SHA-256 is stored.
An organisation's own backend asks at its own hostname with an organisation API token holding calls:web
(POST /api/v1/web-calls, GET /api/v1/web-calls/{id}; no cookie, no Origin). A system that provisions
organisations asks on the operator address with an operator token holding calls:web
(POST /operator/organisations/{organisation}/web-calls and the read-back below), and the browser is sent to the
organisation's first hostname. Both answers are no-store, and both are described in the OpenAPI document.
POST /web-calls and POST /operator/organisations/{organisation}/web-calls¶
At most one target, and three optional fields (with none, the call enters the organisation's default flow):
{ "flow": "5b0c3f7e-2a4d-4e0f-9a4b-1c2d3e4f5a6b", "marker": "order-1234", "caller_name": "Website visitor", "ttl_secs": 30 }
flow: one of the organisation's flows, entered at its live version. Ornumber: a number one of its published flows claims, entered as a call to that number is. Name neither and the call enters the organisation's default flow at its live version: the inbound flow siphon-pbx made from the deployment's default flow for it (the flow that carries default-flow provenance; a flow merely named like it is not one). It is resolved when the token is asked for and its id is kept in the token, so the answer'sflownames it and a later change of the default does not alter a token already issued. Naming both is 422.marker: your own label for the call (1 to 64 of letters, digits and. _ : -). It is kept on the call's record and is told to a voice bot in its brief, atweb_call.markerbesideweb_call.id.caller_name: the name the call is shown as, in place of what the browser sends.ttl_secs: 10 to 120.
201 and the token, which is in no other answer:
{
"id": "7c1e5a90-4b2d-4f6a-8d3e-9a0b1c2d3e4f",
"token": "swc_<64 hex>",
"expires_at": "2026-11-28T09:00:30Z",
"wss_url": "wss://office.example.com/sip",
"sip_uri": "sip:web-call@phones.office.example.com",
"token_header": "X-Siphon-Web-Call-Token",
"flow": "5b0c3f7e-2a4d-4e0f-9a4b-1c2d3e4f5a6b",
"number": null,
"marker": "order-1234",
"ice_servers": [{ "urls": ["turn:198.51.100.10:3478"], "username": "1795900000:wc-7c1e5a90-4b2d-4f6a-8d3e-9a0b1c2d3e4f", "credential": "..." }]
}
The browser opens a WebSocket to wss_url, calls sip_uri with the token in the header token_header, and
gives ice_servers to its peer connection (an empty list where the deployment runs no relay). The credentials are
tagged wc-<id>, so the relay's log says which web call an allocation is.
- 401
unauthorized: no valid token of this organisation. Another organisation's token is no token here. - 403
forbidden: no credential at all on a changing request, or a request from a browser (anOrigin).insufficient_scope: the token lackscalls:web. (Operator routes:missing_scope.) - 404
not_found: the flow is not the organisation's, or no published flow of it claims the number. - 409
conflict: the flow has no published version. With no target named, 409no_default_flow(the organisation has none: never made, or deleted),default_flow_unpublished(it has no published version),default_flow_not_inbound(its live version is an outbound flow) andambiguous_default_flow(more than one flow carries default-flow provenance, and none is picked: name a flow). 409no_sip_domain: the organisation has no SIP domain, so there is nothing to call. 409no_hostname(operator route): the organisation has no hostname. - 422
invalid: bothflowandnumber, a value outside its bounds, an unknown field. - 429
rate_limitedwithRetry-After: the organisation has been issued as many tokens as it may in the last minute (20 unless set). Nothing was issued. - 503
database: repeat it.
The browser's side, with JsSIP¶
The page needs nothing but what the backend relayed from the 201: it never registers, so it has no account and
no password. It connects, then calls sip_uri with the token in token_header and ice_servers for its peer
connection (JsSIP 3.x; the console's own browser phone is built the same way):
import { UA, WebSocketInterface } from "jssip";
// `issued` is the 201 above, as your backend passed it to the page.
const ua = new UA({
sockets: [new WebSocketInterface(issued.wss_url)],
uri: "sip:web-caller@anonymous.invalid", // nothing the INVITE says about who is calling is read
register: false,
});
ua.on("connected", () => {
const session = ua.call(issued.sip_uri, {
extraHeaders: [`${issued.token_header}: ${issued.token}`],
mediaConstraints: { audio: true, video: false },
pcConfig: { iceServers: issued.ice_servers }, // add iceTransportPolicy: "relay" to use the relay only
});
// A refusal says its status: 403 (spent, expired or another organisation's), 486, 480, 404, 503.
session.on("failed", (data) => console.log("refused", data.message?.status_code ?? "no answer"));
});
ua.start();
Call as soon as the token is in hand: it lives 30 seconds unless asked for longer, and JsSIP sends the INVITE only
once the browser has gathered its candidates, which with a TURN server that does not answer can take 40 seconds, so
ask for a longer ttl_secs where the browser's network may block the relay. session.request.call_id is the
Call-ID, which GET /web-calls/{id} returns as sip_call_id once the call is admitted. A call that is dropped
(no such token, or no token at all) gets no answer and fails on JsSIP's own timer.
What the browser's call is answered with¶
A browser that presents a token over WebSocket is entered into the flow as a caller who never registered: it has the media of a browser, and none of what is reserved for a registered phone (it can place no call out and use no feature code). Every call is answered or dropped, and a refusal does not spend the token unless it says so.
| What | Answer |
|---|---|
| No such token | dropped, no answer |
| Already used, past its lifetime, or addressed to another organisation's domain | 403 |
| The organisation is disabled, or its address rules (or the deployment's country and network rules) refuse the browser | 403 |
| The organisation has as many web calls up as it may (5 unless set) | 486; try again when one ends |
| The flow has no published version | 480 |
| The flow no longer exists | 404 |
| The database failed | 503 |
The header is read only on a call that arrived over WebSocket. Over WebSocket a call to a number a flow claims is answered only for a browser that registered or presents a valid token: a bare WebSocket stranger is dropped. Carriers over UDP, TCP and TLS are unchanged.
GET /web-calls/{id} and GET /operator/organisations/{organisation}/web-calls/{call_id}¶
What became of one of the organisation's tokens:
{ "id": "7c1e5a90-...", "state": "ended", "expires_at": "2026-11-28T09:00:30Z", "sip_call_id": "q1w2e3@browser", "marker": "order-1234", "call_id": "0b6c3f5e-..." }
state is issued (not yet presented, still valid), expired (never presented, past its lifetime),
in_progress or ended. sip_call_id is the browser's own Call-ID once it presented the token; call_id is the
id of the call's record once it is written, which the call history and its recording are read by. 404 not_found
for another organisation's token and for one that was deleted after a week.
Web calls from your own website: the WebSocket origins¶
The page that makes a web call is on your website, so its Origin (https://shop.example.com) is not the
PBX's. By default nothing checks it, and any website could ask a visitor's browser to open WebSocket SIP to your
organisation's /sip. An organisation can name the origins that may, and then the TLS proxy refuses an upgrade
from any other with 403 before it reaches the SIP stack:
| Header on the upgrade | List empty (the default) | List set |
|---|---|---|
No Origin (a program, not a browser) |
let through | let through |
| One of the list | let through | let through |
https://<one of the organisation's own hostnames>, with or without a port |
let through | let through |
Any other, null included |
let through | 403 |
The list is exact origins: https://host or https://host:port, lower case, no path, no query, no trailing slash
and no wildcard (https://*.example.com is refused, list each site). An explicit default port is dropped
(https://example.com:443 is https://example.com). http:// is accepted for localhost and loopback addresses
only, so an integration can be built against a local page. At most 32 entries, none twice.
GET and PUT /api/v1/organisation/websocket-origins (an administrator, or a member whose group grants
settings) and GET and PUT /api/v1/operator/organisations/{organisation}/websocket-origins (organisations:read
and organisations:write) read and replace the whole list: { "origins": ["https://shop.example.com"] }. A
refused entry or a list over the cap is 422 and changes nothing. Every replace is in the organisation's audit log
(websocket-origins.replaced). A change takes effect on the next upgrade, nothing is cached; a WebSocket that is
already open stays open. The refusals are counted in siphon_pbx_websocket_origin_refused_total.
This is defence in depth, not access control. Origin is set by the browser and cannot be changed by the page,
so the list stops other websites from driving a visitor's browser into your SIP. A program that is not a browser
sends any Origin it likes, or none, so the list says nothing about who may call: that is what the single-use
web-call token, or a registered phone's credentials, are for.
GET and PUT /operator/organisations/{organisation}/web-call-limits¶
GET needs organisations:read and PUT organisations:write. The body is { "concurrent": 5, "per_minute": 20 }:
how many web calls the organisation may have up at once (1 to 1000) and how many tokens it may be issued in a
minute (1 to 6000). An organisation with no limits of its own has the values above. The concurrent limit is
counted across every node of the deployment. A web call that ends, and one whose node stopped, free their slot.