Errors
Relay doesn’t fail with HTTP status codes — there’s no HTTP response on a WebSocket. A request can fail in one of two ways, and you handle both:
- A failing result. The command reached the call or service and came back with a
resultwhosecodeisn’t"200". This is how most command failures arrive. - A JSON-RPC
error. The request was rejected before it ran — the connection’s protocol version, credentials, or scopes don’t allow it, or a parameter is missing or malformed. The response carries anerrorobject instead of aresult.
A response carries one or the other, never both.
The result shape
A typical result looks like this:
Checking for success
The one thing to check is code, and remember it’s a string, not a number:
"200"— the request succeeded.- Anything else — the request failed, and
messageexplains why.
Numeric codes mirror familiar HTTP status conventions, so a "4xx" value means the request was rejected and a "5xx" value means something went wrong on SignalWire’s side.
Common codes
Identifier codes
When SignalWire can’t carry out your request at all, for example because the service that handles it didn’t answer in time, code is a lowercase identifier instead of a number. Treat any of these as a failure:
Examples
A failed request returns the same shape, with a non-"200" code and a message explaining the cause:
JSON-RPC errors
When a request is rejected before it runs, the response has an error object in place of result:
code is a negative integer and original_request echoes the request that failed. The codes you can see:
A JSON-RPC error on signalwire.connect closes the socket, and so does a signalwire.reauthenticate that sends a rejected Relay JWT. Fix the request and open a new connection. Errors on other requests leave the connection open, including a rejected Subscriber Access Token on signalwire.reauthenticate.
Using an SDK
The Browser SDK surfaces this result for you — successful commands resolve with a result you can inspect, and failures are raised in JavaScript’s idiomatic style instead of leaving you to compare code strings by hand. The code and message are still there when you need the underlying detail.