Record File

Since 0.4.0 AGI Commands Found this useful? Upvote it. ×

Records to a given file.

Last reviewed 2026-04-14

record file filename format escape_digits timeout offset_samples beep s=silence
Description

Record to a file until a given dtmf digit in the sequence is received. Returns -1 on hangup or error. The format will specify what kind of file will be recorded. The timeout is the maximum record time in milliseconds, or -1 for no timeout. offset samples is optional, and, if provided, will seek to the offset without exceeding the end of the file. beep can take any value, and causes Asterisk to play a beep to the channel that is about to be recorded. silence is the number of seconds of silence allowed before the function returns despite the lack of dtmf digits or reaching timeout. silence value must be preceded by s= and is also optional.

Arguments
  • filename required - The destination filename of the recorded audio.
  • format required - The audio format in which to save the resulting file.
  • escape_digits required - The DTMF digits that will terminate the recording process.
  • timeout required - The maximum recording time in milliseconds. Set to -1 for no limit.
  • offset_samples - Causes the recording to first seek to the specified offset before recording begins.
  • beep - Causes Asterisk to play a beep as recording begins. This argument can take any value.
  • s=silence - The number of seconds of silence that are permitted before the recording is terminated, regardless of the escape_digits or timeout arguments. If specified, this parameter must be preceded by s=.

User Notes

No notes yet. Be the first to contribute a tip or example.

Contribute a note

Share a tip, gotcha, or practical example. Keep it under 2000 characters. No questions (use the Asterisk community forums for support). Wrap code in backticks.

Moderated before publishing. Email never shown.