Skip to navigation

Initiate an outbound call. Sends a calling.dial JSON-RPC request and waits for the server to return a calling.call.dial event confirming the call was answered or failed. Returns a fully-initialized Call object with valid callId and nodeId.

The devices parameter supports both serial and parallel dialing strategies. Each inner array represents a set of devices to ring simultaneously (parallel). The outer array represents sequential attempts — if the first group fails, the next group is tried.

Throws RelayError if the dial fails or if no answer is received within the dialTimeout period. The default timeout is 120 seconds.

Parameters

devices
Record<string, unknown>[][]Required

Nested array of device definitions for serial and parallel dialing. Each device is an object with type and params keys. You can also put the fields flat next to type; the SDK wraps them in params and, for "phone", maps to and from to to_number and from_number.

  • Serial dial (try one after another): each inner array has one device
  • Parallel dial (ring simultaneously): one inner array with multiple devices

Up to 20 devices are dialed in total, counted across all inner arrays rather than per array. Any device after the 20th is skipped.

devices[][].type
stringRequired

Device type. Valid values:

  • "phone" — PSTN phone number
  • "sip" — SIP endpoint

To reach a resource address, such as a subscriber, use a "fabric" device with connect on an existing call. dial places only "phone" and "sip" devices.

devices[][].params
Record<string, unknown>Required

Device-specific parameters. Which fields apply depends on the device type.

devices[][].params.to_number
string

Destination phone number in E.164 format. Required for "phone".

devices[][].params.from_number
string

Caller ID phone number in E.164 format. Required for "phone". By default, it must be a number you bought in this project or a verified caller ID, or, when connecting an existing call, that call’s own from or to number. SignalWire support can lift this restriction for your account, after which any E.164 number works.

devices[][].params.to
string

Destination. Required for "sip", where it’s a SIP URI starting with sip: or sips:, and, on connect, for "fabric", where it’s a resource address.

devices[][].params.from
string

Caller ID. Required for "sip" and, on connect, for "fabric". Use a SIP URI or a caller ID string, such as a phone number. For a SIP destination, a caller ID string can contain letters, digits, and _, ., -, +, or ,. By default it must also be a number you bought in this project or a verified caller ID, or, when connecting an existing call, that call’s own from or to number. SignalWire support can lift this restriction for your account.

devices[][].params.from_name
string

Caller ID name shown to the person you’re calling, for "sip". Use 1 to 70 characters: letters, digits, spaces, and _, ., -, +, or ,.

devices[][].params.timeout
numberDefaults to 60

How long to ring this device, in seconds, before giving up on it.

devices[][].params.headers
{ name: string; value: string }[]

Custom SIP headers to add to the INVITE, for "sip". Each header is an object with a "name" and a non-empty "value". A name must start with X- or be Privacy, P-Asserted-Identity, or User-to-User. Names starting with SignalWire, X-SignalWire, X-CID, or X-SW-Xregion are reserved and rejected.

devices[][].params.session_timeout
number

Value of the SIP Session-Expires header, in seconds, for "sip". Values from 1 to 15000 take effect; anything else is ignored and the default is used.

devices[][].params.call_state_url
string

HTTP or HTTPS URL that receives a webhook when this device’s call changes state. When omitted, the device uses the state URL of the call it’s connected to, if that call has one.

devices[][].params.call_state_events
string[]

Which states send a webhook to call_state_url. Valid values: "created", "ringing", "answered", "ended". When omitted, the device uses the events of the call it’s connected to, or only "ended" when there are none.

devices[][].params.confirm
string | Record<string, unknown>[]

SWML to run on this device’s call after it answers and before it’s connected, for example to have the callee press a key to accept. Either an HTTP or HTTPS URL that returns a SWML document, or an array of SWML methods to run inline. The same methods are allowed as in the SWML connect.confirm parameter.

devices[][].params.confirm_timeout
number

How long confirm can run, in seconds. Defaults to the device’s timeout.

options
object

Optional second argument with dial configuration.

options.tag
string | undefined

Client-provided correlation tag for event matching. Auto-generated as a UUID if not supplied.

options.maxDuration
number | undefined

Maximum call duration in seconds. The call is automatically ended when this limit is reached.

options.dialTimeout
number | undefinedDefaults to 120

How long in seconds to wait for the dial to complete (answer or failure) before throwing a timeout error. Matches the Python SDK convention.

Returns

Promise<Call> — A call object with all properties populated and ready for call control operations.

Examples

Simple outbound call

import { RelayClient } from '@signalwire/sdk';
const client = new RelayClient({
project: process.env.SIGNALWIRE_PROJECT_ID!,
token: process.env.SIGNALWIRE_API_TOKEN!,
contexts: ['default']
});
await client.connect();
const call = await client.dial(
[[{
type: 'phone',
params: {
from_number: '+15551234567',
to_number: '+15559876543',
timeout: 30,
},
}]]
);
const action = await call.play([{ type: 'tts', text: 'Hello!' }]);
await action.wait();
await call.hangup();
await client.disconnect();

Serial dial (failover)

import { RelayClient } from '@signalwire/sdk';
const client = new RelayClient({
project: process.env.SIGNALWIRE_PROJECT_ID!,
token: process.env.SIGNALWIRE_API_TOKEN!,
contexts: ['default']
});
await client.connect();
// Try the first number, then fall back to the second
const call = await client.dial([
[{ type: 'phone', params: { to_number: '+15551111111', from_number: '+15550000000' } }],
[{ type: 'phone', params: { to_number: '+15552222222', from_number: '+15550000000' } }],
]);
await client.disconnect();

Parallel dial (ring all)

import { RelayClient } from '@signalwire/sdk';
const client = new RelayClient({
project: process.env.SIGNALWIRE_PROJECT_ID!,
token: process.env.SIGNALWIRE_API_TOKEN!,
contexts: ['default']
});
await client.connect();
// Ring both numbers simultaneously, first to answer wins
const call = await client.dial([[
{ type: 'phone', params: { to_number: '+15551111111', from_number: '+15550000000' } },
{ type: 'phone', params: { to_number: '+15552222222', from_number: '+15550000000' } },
]]);
await client.disconnect();