disconnect

View as MarkdownOpen in Claude

Disconnect a previously bridged call, breaking the connection between the two call legs. Both parties return to their respective RELAY applications for further processing. Use this after connect() to separate bridged calls.

Parameters

None.

Returns

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

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
12 // Bridge to an agent
13 await call.connect([
14 [{ type: 'phone', params: { to_number: '+15551234567', from_number: '+15559876543' } }],
15 ]);
16
17 // Disconnect (unbridge) the connected call
18 const result = await call.disconnect();
19 console.log(`Disconnected: ${JSON.stringify(result)}`);
20
21 await call.play([{ type: 'tts', text: 'The other party has disconnected.' }]);
22 await call.hangup();
23});
24
25await client.run();