Asterisk call recording with MixMonitor
Decide which conversation leg to record, when recording starts and stops, and who may read the resulting file before adding an application call. A recording file's existence does not establish that it contains the entire intended interaction.
Source-reviewed, 19 October 2026. Prepared from the cited documentation. Recording paths have not been independently tested by Phone Guides. Scope: Asterisk 22 MixMonitor behaviour and operational planning. Applicable recording/privacy requirements must be resolved for the actual deployment before recording people.
Record the intended scope
| Decision | What to state |
|---|---|
| Call scope | Which channel and stages must be included |
| Start/stop | Before answer, after answer, while bridged, or another documented policy |
| File ownership | Protected directory, runtime write permission and authorised readers |
| Identity | Internally generated filename and correlation record |
| Retention | How long to keep the recording and backups |
| Completion | When downstream processing may open the finished file |
MixMonitor records audio on the current channel as an audiohook. It does not automatically answer the call. The branch-22 application reference defines its options and the distinction between bridged-only recording and a broader interval.
Read a narrow recording route
This original route records the bridged portion of a call towards the existing local endpoint 6001. Only use it for an authorised recording on a system you control. The destination, context and recording directory are illustrative; confirm they do not collide with existing routes and replace the directory with your approved private writable location before use.
[pg-recording-demo]
exten => 6097,1,Answer()
same => n,MixMonitor(/var/spool/asterisk/monitor/pg-${UNIQUEID}.wav,b)
same => n,Dial(PJSIP/6001,15)
same => n,StopMixMonitor()
same => n,Hangup()
The filename uses Asterisk's channel identifier rather than caller-entered text. It is not an access-control mechanism: file permissions, directory access and retention still matter. Verify the real recording directory and format support on the installed system instead of assuming this example path already exists.
The b option restricts recording to time when the channel is bridged. It is not a guarantee that every later transfer or conference remains within the intended recording scope. MixMonitor() does not itself answer the call; this route answers explicitly before starting the attempt. Confirm that answering at that point is the desired caller treatment.
When Dial() returns through the normal dialplan path, StopMixMonitor() supplies an explicit completion boundary before subsequent processing. If the caller hangs up, later priorities may not run. Do not place indispensable durable processing only after Dial() and assume it executes for every hangup path. Define completion detection separately for the deployed application.
For an unanswered attempt, check whether any usable audio exists rather than treating a created filename as proof of a recorded conversation. Keep call outcomes and recording outcomes as separate monitoring questions.
Constrain file and command parameters
Use a filename generated from trusted internal identifiers in an approved directory. Do not put caller-supplied names, numbers or arbitrary input directly into recording parameters or a post-recording command. Upstream explicitly warns that untrusted values can create command-injection exposure.
Avoid adding an external shell command when the job can be handled by a separate bounded processing service. If a deployment does use processing commands, review the complete parameter construction and permission boundary. A safe-looking file extension does not validate the rest of a path or command.
Wait for the recording to finish
If dialplan logic must process a completed file, use the documented stopping/completion behaviour rather than assuming a file is finished as soon as it appears. The StopMixMonitor reference is the companion operation.
Record the actual filename supplied by the application where relevant; extension handling and selected options can affect the output. Choose a supported recording format and check it with the consuming application. Do not publish a generic recording expression as a complete retention or consent design.
Treat transfers and applications as separate paths
An audiohook attached to one channel does not justify assuming it follows every later transfer, conference or application-created channel exactly as desired. Document the intended behaviour and compare the relevant call legs. Use architecture, transfers and conferencing to identify where the path changes.
If direct media or a different bridge arrangement is in use, establish how the required audio becomes available for the actual recording path. Do not diagnose a short recording solely from its file size.
Reader checks
On your own authorised deployment, check answered and unanswered calls, both audio directions, a transfer, caller hangup and the completion handoff. Verify that ordinary users cannot browse other recordings. Include full storage, denied writes and failed post-processing in the operational design.
Monitor recording failures separately from the caller's call success. A normal call can still fail its recording requirement. Protect recordings and their metadata in backups, and make their availability visible to the appropriate operator without exposing subscriber content in alerts.
Return to Asterisk documentation.