REST Client
The REST namespace provides an HTTP client for the SignalWire platform APIs. It organizes every HTTP endpoint into namespaced resource objects with standard CRUD operations, letting you manage phone numbers, fabric resources, call logs, video rooms, datasphere documents, and more from TypeScript.
Example
Search for available phone numbers, purchase one, and assign it to a fabric AI agent resource:
All three constructor arguments can also be provided via environment variables:
SIGNALWIRE_PROJECT_ID, SIGNALWIRE_API_TOKEN, and SIGNALWIRE_SPACE (or
SIGNALWIRE_REST_BASE_URL for a full base URL, which takes precedence).
When those are set, you can instantiate with new RestClient() and no arguments.
Pagination
list() returns one page. paginate() returns an async iterator that follows
the server’s next-page links and yields one item at a time, so you don’t build
the page loop yourself. Query parameters apply to the first request only.
Timeouts, retries, and cancellation
Every resource method accepts a trailing requestOptions object that sets the
timeout, retry count, backoff, and an AbortSignal for that one call. Pass the
same object to the constructor to set a client-wide default. See
RequestOptions.
Error handling
REST errors throw RestError. A request that never reaches the
server, such as a DNS failure or a timeout, throws RestTransportError, a
subclass of RestError with a null status code, so one catch handles both:
Resources
Constructor, authentication, and all namespace properties.
Search, purchase, and manage phone numbers.
AI agents, SWML scripts, subscribers, call flows, and tokens.
REST-based call control with 37+ commands.
Rooms, conferences, sessions, recordings, and streams.
Document management and semantic search.
Message, voice, fax, and conference log queries.
10DLC brand and campaign registration.
Send SMS and MMS messages and redact message bodies.
Create and manage projects and rotate signing keys.
Multi-factor authentication via SMS and voice.