Skip to content

Protocol Overview ​

The control protocol connects your controller to sipbridge. The controller opens a WebSocket, and from then on the two exchange JSON messages: sipbridge offers SIP requests and reports events, and the controller sends back decisions and commands.

This section is for controller authors. This page covers the connection, the message format and the overall flow; the following pages cover the session, capabilities, every message type and commands and their outcomes. Field names and types come from the control schema; the complete rules are in the protocol specification.

Connection ​

ItemValue
URLwss://<control address>/v1/control; ws:// only on a loopback address
Subprotocolsipbridge.control.json.v1
AuthenticationClient certificate (default) or bearer token; see Identities and TLS
Origin headerMust be absent
CompressionDisabled
FramesText only; a binary frame closes the session
Who connectsAlways the controller

Envelope ​

Every WebSocket message is one JSON object, called an envelope. It has a few common fields and exactly one payload field, whose name says what kind of message it is:

FieldTypeMeaning
correlationIdstringChosen by the sender of a request and repeated in the reply, so the two can be matched. Pattern [A-Za-z0-9_.:@+-]{1,96}. Make it unique within one run of your process. It is a label and grants nothing.
sessionIdstringIssued in helloAck. Leave it out of hello; include it, exactly, in every later message.
remainingBudgetMsintegerHow many milliseconds the sender is still willing to wait for this operation. Required on requestDecision, command and inspect; left out of hello, status, ping and pong. At most 2,000, or 40,000 for a command.
one payloadobjectExactly one of hello, helloAck, status, ping, pong, request, requestDecision, command, result, dialogEvent, inspect, and the others listed in Message Families.

A heartbeat is a complete, minimal example:

json
{"correlationId":"0c4b1f0e-3d55-4b0b-a2e5-5f8e9d0a7b11","sessionId":"0d4f7a52-93b1-4c8e-a6d2-7e15b9c3f841","ping":{"nonce":"0c4b1f0e-3d55-4b0b-a2e5-5f8e9d0a7b11"}}

JSON encoding ​

The JSON follows protobuf's standard ProtoJSON mapping, applied strictly. A protobuf JSON codec generated from the schema gives you most of this for free. If you write JSON by hand, use these forms:

Schema typeJSON formExample
field nameslowerCamelCase only; snake_case is rejectedconnectionAttempt
uint64Decimal string, 0 to 18446744073709551615; no sign, leading zero or exponent"9007199254740993"
uint32JSON number1048576
boolJSON booleantrue
bytesPadded standard base64 string"AP+AQQ=="
enumSymbolic name"ACCEPTED"
oneofThe chosen variant as a named field; exactly one present"cancel":{}

sipbridge is strict about what it accepts, and a malformed message closes the session. It rejects invalid UTF-8, duplicate keys, nesting deeper than 32 levels, null or a wrongly typed value in a known field, a missing or extra payload, unknown enum names and anything after the closing brace. Unknown fields are ignored, so that new fields can be added without breaking older controllers. A field holding its default value (0, "", false) may be left out, and sipbridge leaves such fields out of what it sends: treat a missing field as its default.

In JavaScript, never parse a uint64 into a Number; use BigInt or the generated TypeScript codec. The repository's shared JSON cases list accepted and rejected examples you can use to test your codec.

Size limits ​

A complete message, as UTF-8 text including base64 and JSON overhead, must fit the envelope limit agreed in the handshake: at most 1 MiB and at least 512 bytes. A SIP message inside an envelope can be up to 64 KiB.

Message flow ​

text
Controller                                   sipbridge
    | ---- WebSocket upgrade -----------------> |
    | ---- hello ------------------------------> |
    | <--- helloAck ---------------------------- |
    | ---- status (ready) ---------------------> |
    | <--> ping / pong, both directions <------> |
    |                                            |  a SIP request arrives
    | <--- request ----------------------------- |  offered once
    | ---- requestDecision --------------------> |  exactly one answer
    | <--- result ------------------------------ |  decision recorded
    | ---- command (respond, dialogRequest...) > |  as the call proceeds
    | <--- result ------------------------------ |
    | <--- dialogEvent ------------------------- |
    | ---- result (ACCEPTED) ------------------> |  event received

Many operations are in flight on one session at once, so match replies to requests by correlationId, not by arrival order. If you hold several sessions, the order of messages on one says nothing about the order on another.

A Call, Step by Step shows this flow with complete messages.

sipbridge holds SIP connections and runs the protocol; your application decides what happens on each call.