hangup

View as MarkdownOpen in Claude

End the call. The call transitions through the ending state and then to ended. Any active operations (play, record, etc.) are stopped automatically when the call ends.

Parameters

reason
stringDefaults to hangup

The end reason string sent to the server. Valid values:

  • "hangup" — normal hangup (default)
  • "cancel" — cancel the call
  • "busy" — signal busy
  • "decline" — decline the call

Returns

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

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.hangup();
12 console.log('Call ended');
13});
14
15await client.run();