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
  • Example
  • Error Handling
  • Resources
REST Client

REST Client

TypeScript API reference for RestClient and resource namespaces
|View as Markdown|Open in Claude|
Was this page helpful?
Edit this page
Previous

Addresses

Next
Built with

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:

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
9// Search for available numbers in area code 512
10const available = await client.phoneNumbers.search({ areaCode: "512", quantity: 3 });
11for (const number of available.data ?? []) {
12 console.log(`${number.number} - ${number.region}`);
13}
14
15// Purchase the first available number
16const purchased = await client.phoneNumbers.create({ number: available.data[0].number });
17console.log(`Purchased: ${purchased.number}`);
18
19// List your AI agent resources
20const response = await client.fabric.aiAgents.list();
21for (const agent of response.data ?? []) {
22 console.log(`Agent: ${agent.name} (${agent.id})`);
23}
24
25// Query recent voice call logs
26const logs = await client.logs.voice.list({ pageSize: 5 });
27for (const log of logs.data ?? []) {
28 console.log(`Call from ${log.from} to ${log.to}`);
29}

All three constructor arguments can also be provided via environment variables: SIGNALWIRE_PROJECT_ID, SIGNALWIRE_API_TOKEN, and SIGNALWIRE_SPACE. When those are set, you can instantiate with new RestClient() and no arguments.

Error Handling

REST errors throw RestError:

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

Resources

RestClient

Constructor, authentication, and all namespace properties.

Phone Numbers

Search, purchase, and manage phone numbers.

Fabric

AI agents, SWML scripts, subscribers, call flows, and tokens.

Calling

REST-based call control with 37+ commands.

Video

Rooms, conferences, sessions, recordings, and streams.

Datasphere

Document management and semantic search.

Logs

Message, voice, fax, and conference log queries.

Registry

10DLC brand and campaign registration.

Compatibility

Twilio-compatible LAML API for migration.

MFA

Multi-factor authentication via SMS and voice.