For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Log inSign up
Support
GuidesReference
GuidesReference
    • Core
      • Overview
    • Agents
      • Overview
      • AgentBase
      • AgentServer
      • Configuration
      • ContextBuilder
      • DataMap
      • FunctionResult
      • Helper Functions & Utilities
      • LiveWire
      • PomBuilder
      • Prefabs
      • SkillBase
      • SkillManager
      • SkillRegistry
      • Skills
      • SwaigFunction
      • SwmlBuilder
      • SWMLService
    • RELAY
      • Overview
      • Actions
      • Call
      • Constants
      • Events
      • Message
      • RelayClient
      • RelayError
    • REST Client
      • Overview
      • Addresses
      • Calling
      • ChatResource
      • Compat
      • Datasphere
      • Fabric
      • ImportedNumbersResource
      • Logs
      • LookupResource
      • MFA
      • Number Groups
      • Phone Numbers
      • Project
      • PubSubResource
      • Queues
      • Recordings
      • Registry
      • RestClient
      • RestError
      • Short Codes
      • SIP Profile
      • Verified Callers
      • Video
LogoLogoSignalWire Docs
Log inSign up
Support
On this page
  • Properties
  • Example
REST Client

RestError

|View as Markdown|Open in Claude|
Was this page helpful?
Edit this page
Previous

Short Codes

Next
Built with

Custom error class for REST API errors. Extends JavaScript’s built-in Error class. Thrown when an HTTP request to the SignalWire REST API returns a non-success status code. The name property is always "RestError".

Also exported as SignalWireRestError to match the Python SDK class name.

1import { RestError } from '@signalwire/sdk';

Properties

statusCode
number

HTTP status code returned by the API (e.g., 404, 422, 500).

body
string | Record<string, unknown>

Response body from the API. Parsed as JSON when the response was valid JSON; otherwise the raw text. Matches the Python SDK’s SignalWireRestError.body behavior.

url
string

The URL that was requested.

method
string

The HTTP method used ("GET", "POST", "PUT", "PATCH", "DELETE").

name
string

Always "RestError".

message
string

Human-readable summary: "{method} {url} returned {statusCode}: {body}".

Example

1import { RestClient, RestError } from "@signalwire/sdk";
2
3const client = new RestClient({
4 project: "your-project-id",
5 token: "your-api-token",
6 host: "your-space.signalwire.com"
7});
8
9try {
10 await client.phoneNumbers.get("nonexistent-id");
11} catch (e) {
12 if (e instanceof RestError) {
13 console.log(`HTTP ${e.statusCode}: ${e.body}`);
14 console.log(`Request: ${e.method} ${e.url}`);
15 }
16}