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

import { RelayClient } from '@signalwire/sdk';
const client = new RelayClient({
project: process.env.SIGNALWIRE_PROJECT_ID!,
token: process.env.SIGNALWIRE_API_TOKEN!,
contexts: ['default']
});
client.onCall(async (call) => {
await call.answer();
// Bridge to an agent
await call.connect([
[{ type: 'phone', params: { to_number: '+15551234567', from_number: '+15559876543' } }],
]);
// Disconnect (unbridge) the connected call
const result = await call.disconnect();
console.log(`Disconnected: ${JSON.stringify(result)}`);
await call.play([{ type: 'tts', text: 'The other party has disconnected.' }]);
await call.hangup();
});
await client.run();