Skip to main content
With Headless Web SDK v0.3.1, you can pass an optional microphone deviceId so ambient recording uses the mic your user picks. Your app lists devices, builds the picker UI, and keeps the selected id in app state. Pass that deviceId through config.audio.deviceId on useAmbientSession, or through the same audio option on Platform Client start and resume. The Headless Web SDK opens capture on that device when you call start() or resume(), and does not list microphones, remember the last choice, or switch mics for you. When a session is paused, pass the same deviceId again on resume so capture continues on that microphone.
When you omit deviceId, recording uses the browser default microphone.

When you pass a deviceId

The selected microphone is applied only when audio capture starts:
There is no option to switch the microphone mid-session. Pause, then resume with the new deviceId.
To change microphones during a visit:
  • Update your app state with the new deviceId so config.audio.deviceId is current.
  • Call pause()
  • Call resume()
Expect a short capture gap between pause and resume when you change the microphone. Flowchart: Select deviceId in host app, start or resume, Recording active, User changes mic?, Update app state deviceId, pause, resume with new deviceId. Flowchart: Select deviceId in host app, start or resume, Recording active, User changes mic?, Update app state deviceId, pause, resume with new deviceId.

Pass deviceId to the hook

Types

The following types show the options you can pass to the hook:
When deviceId is set, the recording uses getUserMedia with:
When 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 only audioinput devices. 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 deviceId in your app. The SDK keeps it in memory only and does not save it to IndexedDB. Pass config.audio again 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(), then resume(). The hook may log a warning until that resume() succeeds.

When the device is unavailable

When you pass an exact deviceId 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.
In your UI, ask the user to pick another microphone, refresh the device list, then call start() or resume() again. Starting a session and Resuming a session list the same code and reason. Example code: Handle start failure
Changing config.audio.deviceId while recording does not switch the microphone that is already in use. The React hook may log a diagnostic warning. The new device applies on the next successful start() or resume().
For Platform Client (startAmbientSession / resumeAmbientSession) option retention, including { audio: undefined } to clear a previous in-memory selection, refer to Platform client and provider.

Partner checklist

  • Enumerate audioinput devices in your app.
  • Store the selected deviceId in your app state.
  • Pass it through useAmbientSession config.audio or Platform start/resume options.
  • On mic change during an active recording, pause then resume.
  • Re-supply deviceId after 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 switchMicrophone API in this release.

Microphone FAQs

No. The microphone that is already recording does not change. Pause, then resume with the new deviceId.
No. Selection is in-memory only. Persist the preference in your app if needed, then pass it again on start/resume after remount.
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().
No. Form filling deviceId support is out of scope for this release.
Not in this release. Use pause → resume with the new deviceId.

Limitations

  • You cannot change the active microphone while recording is running. Pause, then resume with the new deviceId.
  • There is no public switchMicrophone(deviceId) API in this release.
  • The SDK does not enumerate microphones or persist the user’s last choice. Your app owns listing, picker UI, and storage.
  • When an exact deviceId is missing or unavailable, the SDK does not fall back to the browser default microphone.
  • You cannot pass an external MediaStream as the audio source.
  • Form filling microphone selection is out of scope for this release.

Next steps

Ambient session examples Configure ambient session Manage ambient session - Guide for start, pause, and resume use cases. Platform client and provider Error handling guide
Last modified on November 5, 2026