RestClient

View as MarkdownOpen in Claude

The RestClient is the entry point for all SignalWire REST API operations. It authenticates with your project credentials and exposes every API namespace as a property, giving you typed access to phone numbers, fabric resources, call control, video rooms, datasphere documents, logs, and more.

Constructor Parameters

project
string

SignalWire project ID. Falls back to the SIGNALWIRE_PROJECT_ID environment variable when not provided.

token
string

API token for authentication. Falls back to the SIGNALWIRE_API_TOKEN environment variable when not provided.

host
string

SignalWire space hostname (e.g., your-space.signalwire.com). Falls back to the SIGNALWIRE_SPACE environment variable when not provided.

All three parameters are required. If any is missing from both the constructor arguments and environment variables, an Error is thrown.

Namespace Properties

fabric
FabricNamespace

AI agents, SWML scripts, subscribers, call flows, SIP gateways, and tokens. See Fabric.

calling
CallingNamespace

REST-based call control with 37+ commands dispatched via POST. See Calling.

phoneNumbers
PhoneNumbersResource

Search, purchase, and manage phone numbers. See Phone Numbers.

addresses
AddressesResource

Manage regulatory addresses. See Addresses.

queues
QueuesResource

Manage call queues and queue members. See Queues.

recordings
RecordingsResource

List, retrieve, and delete call recordings. See Recordings.

numberGroups
NumberGroupsResource

Manage number groups and their memberships. See Number Groups.

verifiedCallers
VerifiedCallersResource

Manage and verify caller IDs. See Verified Callers.

sipProfile
SipProfileResource

Get and update the project SIP profile. See SIP Profile.

lookup
LookupResource

Phone number carrier and CNAM lookup. See Lookup.

shortCodes
ShortCodesResource

Manage short codes. See Short Codes.

importedNumbers
ImportedNumbersResource

Import externally-hosted phone numbers. See Imported Numbers.

mfa
MfaResource

Multi-factor authentication via SMS and voice. See MFA.

registry
RegistryNamespace

10DLC brand and campaign registration. See Registry.

datasphere
DatasphereNamespace

Document management and semantic search. See Datasphere.

video
VideoNamespace

Video rooms, conferences, sessions, recordings, and streams. See Video.

logs
LogsNamespace

Message, voice, fax, and conference log queries. See Logs.

project
ProjectNamespace

Project-level API token management. See Project.

pubsub
PubSubResource

PubSub token generation. See PubSub.

chat
ChatResource

Chat token generation. See Chat.

compat
CompatNamespace

Twilio-compatible LAML API for migration. See Compatibility.

Examples

Explicit credentials

1import { RestClient } 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
9const numbers = await client.phoneNumbers.list();

Environment variables

1import { RestClient } from "@signalwire/sdk";
2
3// With SIGNALWIRE_PROJECT_ID, SIGNALWIRE_API_TOKEN, and SIGNALWIRE_SPACE set
4const client = new RestClient();
5
6const available = await client.phoneNumbers.search({ areaCode: "512" });