record

View as MarkdownOpen in Claude

Start recording audio from the call. Returns a RecordAction that you can use to pause, resume, stop, or wait for the recording to complete.

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

This method corresponds to the SWML record verb. See the SWML record reference for the full specification.

Parameters

audio
Record<string, unknown> | undefined

Audio recording configuration object.

audio.direction
string

Which audio to record.

  • "listen" — record audio heard by the caller
  • "speak" — record audio spoken by the caller
  • "both" — record audio in both directions
audio.format
string

Recording file format.

  • "mp3" — compressed MP3 format
  • "wav" — uncompressed WAV format
audio.stereo
boolean

Record in stereo (each side on a separate channel).

audio.initial_timeout
number

Seconds to wait for audio before ending with no_input.

audio.end_silence_timeout
number

Seconds of silence before stopping automatically.

audio.terminators
string

DTMF digits that stop recording (e.g., "#").

audio.beep
boolean

Play a beep before recording starts.

audio.input_sensitivity
number

Sensitivity threshold for detecting audio input.

controlId
string | undefined

Custom control ID for this operation. Auto-generated if not provided.

onCompleted
(event: RelayEvent) => void | Promise<void>

Callback invoked when recording reaches a terminal state (finished or no_input). The event contains the recording url, duration, and size.

Returns

Promise<RecordAction> — An action handle with stop(), pause(), resume(), and wait() methods.

Example

1import { RelayClient } from '@signalwire/sdk';
2
3const client = new RelayClient({
4 project: process.env.SIGNALWIRE_PROJECT_ID!,
5 token: process.env.SIGNALWIRE_API_TOKEN!,
6 contexts: ['default']
7});
8
9client.onCall(async (call) => {
10 await call.answer();
11 await call.play([{ type: 'tts', text: 'Leave a message after the beep.' }]);
12
13 const action = await call.record(
14 { beep: true, end_silence_timeout: 3, terminators: '#' }
15 );
16 const event = await action.wait();
17
18 const url = event.params.record?.url ?? '';
19 console.log(`Recording saved: ${url}`);
20 await call.hangup();
21});
22
23await client.run();