deviceId so ambient recording uses the mic your user picks. Your app lists devices and builds the picker UI. The Headless Web SDK does not list microphones, remember the last choice, or switch mics for you.
When you omit the id, recording uses the browser default microphone.
What this enables
- Choose which microphone the recording uses when you start or resume an ambient session.
- Apply the same microphone selection when a paused session resumes.
- Keep using the browser default microphone when
deviceIdis omitted.
What this does not do
- Change the active microphone mid-recording without pause and resume.
- Switch the microphone while recording is already running, without a pause.
- Expose a public
switchMicrophone(deviceId)API. - Enumerate devices or persist the userโs last choice.
- Fall back to the browser default when an exact
deviceIdis unavailable. - Accept an external
MediaStreamas the audio source. - Support Form filling microphone selection in this release.
When you pass a deviceId
The selected microphone is applied only when audio capture starts:There is no seamless mid-session microphone switch.
- Update your app state with the new
deviceIdsoconfig.audio.deviceIdis current. - Call
pause() - Call
resume()
Pass deviceId to the hook
Types
The following types show the options you can pass to the hook:deviceId is set, the recording uses getUserMedia with:
deviceId is omitted, the browser default microphone is used.
Enumerate devices and select a microphone
You own device enumeration and how you design and implement the microphone picker UI. Request microphone permission before you enumerate if you need readable device labels in Chromium. Changing the microphone while recording is active does not switch the microphone in use. First pause, then resume so the new device is applied. The following code example shows how to enumerate devices and select a microphone while using the Headless Web SDK.What your app handles
- List microphones in your app with
enumerateDevices(), and keep onlyaudioinputdevices. The SDK does not list them for you. - Ask for microphone permission before you list devices if you need the names to be readable.
- Save the chosen
deviceIdin your app. The SDK keeps it in memory only and does not save it to IndexedDB. Passconfig.audioagain after a page reload, an SDK remount, or session recovery. - If the user picks a new microphone while recording, the current microphone stays in use until you call
pause(), thenresume(). The hook may log a warning until thatresume()succeeds.
When the device is unavailable
When you pass an exactdeviceId and that device is missing, disconnected, or otherwise unavailable, getUserMedia fails. The Headless Web SDK does not automatically fall back to the browser default microphone.
Mic capture failures are not a top-level AudioRecorderFailure error. They are wrapped as session lifecycle errors:
Platform Client
You receive a structured error with
code, reason, and cause. cause is the browser microphone error from getUserMedia.React Hook
start() and resume() throw a string, not an object with error.code and error.reason.start() or resume() again. Starting a session and Resuming a session list the same code and reason.
Example code: Handle start failure
startAmbientSession / resumeAmbientSession) option retention, including { audio: undefined } to clear a previous in-memory selection, refer to Platform client and provider.
Partner checklist
See all the checklist items
See all the checklist items
- Enumerate
audioinputdevices in your app. - Store the selected
deviceIdin your app state. - Pass it through
useAmbientSessionconfig.audioor Platform start/resume options. - On mic change during an active recording, pause then resume.
- Re-supply
deviceIdafter remount or recovery. - Handle start/resume failures when the selected device is unavailable.
- Do not expect the microphone to change while recording is active, and do not expect a
switchMicrophoneAPI in this release.
Microphone FAQs
Does Changing the Dropdown While Recording Switch the Mic Immediately?
Does Changing the Dropdown While Recording Switch the Mic Immediately?
No. The microphone that is already recording does not change. Pause, then resume with the new
deviceId.Will the SDK Remember the Selected Mic After a Page Reload?
Will the SDK Remember the Selected Mic After a Page Reload?
No. Selection is in-memory only. Persist the preference in your app if needed, then pass it again on start/resume after remount.
What Happens If the Selected Device Is Unplugged?
What Happens If the Selected Device Is Unplugged?
Start or resume fails. The SDK does not fall back to another microphone automatically. The error uses
code: "StartSessionFailed" or code: "ResumeSessionFailed" with reason: "AudioRecorderFailure". On React, you may receive that information as a string from error.toString().Is Form Filling Covered?
Is Form Filling Covered?
No. Form filling
deviceId support is out of scope for this release.Is There a switchMicrophone API?
Is There a switchMicrophone API?
Not in this release. Use pause โ resume with the new
deviceId.Next steps
See working microphone and recording flows in Ambient session examples. Reviewconfig.audio.deviceId and related options in Configure ambient session.
Refer to the Manage ambient session guide for start, pause, and resume use cases.
Call startAmbientSession and resumeAmbientSession with microphone options in Platform client and provider.
Learn how to handle start and resume mic failures in the Error handling guide.