refer

View as MarkdownOpen in Claude

Transfer a SIP call to an external SIP endpoint using the SIP REFER method. Unlike transfer() which transfers control within RELAY, refer() performs a SIP-level transfer to an external endpoint.

This method emits calling.call.refer events. See Call Events for payload details.

Parameters

device
Record<string, unknown>Required

The target SIP device for the REFER.

device.type
stringRequired

Device type. Typically "sip".

device.params
Record<string, unknown>Required

SIP parameters including uri (the SIP URI to refer to).

statusUrl
string | undefined

URL to receive REFER status webhooks.

Returns

Promise<Record<string, unknown>> — Server response confirming the refer operation.

Example

1import { RelayClient } from '@signalwire/sdk';
2
3const client = new RelayClient({
4 project: process.env.SIGNALWIRE_PROJECT_ID!,
5 token: process.env.SIGNALWIRE_TOKEN!,
6 contexts: ['default']
7});
8
9client.onCall(async (call) => {
10 await call.answer();
11 await call.play([{ type: 'tts', text: 'Transferring to another line.' }]);
12
13 const result = await call.refer({
14 type: 'sip',
15 params: { uri: 'sip:support@example.com' },
16 });
17 console.log(`SIP REFER result: ${JSON.stringify(result)}`);
18});
19
20await client.run();