string versus structured, refer to Embedded Forms overview.
To use Embedded Forms, you need Headless Web SDK v0.3.1 or later (
@suki-sdk/platform and @suki-sdk/platform-react). Make sure your environment has this feature enabled before you use it.Seed Embedded Forms
CallsetSessionContext any time after you create the session and before you submit it. You can call it before you start recording. It sends the full context with POST, checks that the session is still created, and stores that context in IndexedDB for a later offline upload.
Use updateSessionContext only after that first seed, when a template changes during the visit. It sends a PATCH for the fields in updateMask. It does not recover the ambient session, and it does not check that the session is still created. Seed with setSessionContext first so an offline upload still has the templates.
Sections and precharted_content shape
Section[]
Sections to seed on the ambient session context.
object
Prior text for the section.
object
An Embedded Form template.
Each entry is either
string or structured. Do not mix fields from both types in one entry.sections you pass to setSessionContext and updateSessionContext:
TypeScript
React
Update Embedded Forms during a visit
CallupdateSessionContext to change sections or templates after the first seed. Prefer the useUpdateAmbientSessionContext hook, which wraps the same call.
updateMaskis required. Prefer["sections"]. The string"sections"is also valid.precharted_contentlives onsections[]. Mask the top-levelsectionsfield, then send the fullsectionslist you want. The PATCH replaces that list. It does not append.- Do not use nested paths under
sections, such as["sections.precharted_content"]or["sections.loinc"]. Those are not supported for Embedded Form updates. Nested paths on object fields, such aspatient.dob, are supported when you are updating that field. - Add other top-level paths only when you are also patching those fields, for example
["sections", "orders"].
React
Errors
client.setSessionContext throws AmbientSessionError. setSessionContext from useAmbientSession throws that failure as a string, so do not check it with instanceof AmbientSessionError. updateSessionContext and useUpdateAmbientSessionContext throw PlatformError. The read hooks return the PlatformError object.Read filled values
Filled values come back insection_structured_values. Use the section helpers when you only need Embedded Forms. Use the full structured data helpers when you also need diagnoses and orders.
Note structured data does not include Embedded Forms in this release. Read Embedded Forms from the session or encounter helpers.
{ id?, context?, key, value }. It does not include the options or field type you sent in the template.
TypeScript
React hooks
@suki-sdk/platform-react includes these hooks for Embedded Forms and related content:
Each read hook takes one object:
string
required
The ID the hook reads by. Session hooks take
ambientSessionId, encounter hooks take encounterId, and note hooks take noteId. The query does not run while this value is empty.boolean
Optional: Controls whether the query runs. Defaults to
true.number
Optional: Polling interval in milliseconds. When you omit it, the hook does not poll.
ambientSessionStructuredDataQueryOptions, that you can use to prefetch with your QueryClient. After a successful useUpdateAmbientSessionContext call, the SDK refreshes the session structured data, section structured data, and session content hooks for that session.
Code examples
This component seeds Embedded Forms withsetSessionContext from useAmbientSession, records the visit, updates the templates, and reads the filled values.
React
refetchIntervalMs only if your app needs polling.
React
Offline behavior
- Seed Embedded Forms with
setSessionContext. It stores the full context in your browser’s IndexedDB, so the SDK can upload it if the session goes offline. - After a successful
updateSessionContext, the SDK merges only the fields inupdateMaskinto IndexedDB. A later offline upload keeps those updates. - If there is no IndexedDB context row yet, the SDK does not mirror the update locally and logs a warning. The update still reaches Suki, but a later offline upload does not include it. Call
setSessionContextfirst.
Troubleshooting
setSessionContext Throws ContextUpdateFailed
setSessionContext Throws ContextUpdateFailed
The session must still be in the
created state. If you already called submit or cancel, client.setSessionContext throws AmbientSessionError with code: "ContextUpdateFailed". Seed Embedded Forms after create and before submit. setSessionContext from useAmbientSession throws that failure as a string.updateSessionContext Fails with updateSessionContextFailed
updateSessionContext Fails with updateSessionContextFailed
Pass both
ambientSessionId and updateMask. Prefer updateMask: ["sections"], then send the full sections list you want. Nested paths under sections, such as sections.precharted_content, are not supported. Prefer useUpdateAmbientSessionContext. This call throws PlatformError, not AmbientSessionError.section_structured_values Is Empty
section_structured_values Is Empty
Wait until your app knows the note is ready, then call the helper or refetch the hook. The SDK does not poll in the background unless you pass
refetchIntervalMs. Use the session or encounter structured data helpers. getAmbientNoteStructuredData does not include Embedded Forms in this release. Note content helpers return note text only, not Embedded Forms.Offline Upload Is Missing Embedded Forms
Offline Upload Is Missing Embedded Forms
Call
setSessionContext first so the SDK stores the full context in your browser’s IndexedDB. If you call updateSessionContext with no prior IndexedDB context row, the update can still reach Suki, but a later offline upload does not include it. Refer to Offline behavior.cumulative Does Not Affect Embedded Forms
cumulative Does Not Affect Embedded Forms
The optional
cumulative flag applies only to session content helpers such as getAmbientSessionContent. It does not apply to section structured data reads.Next steps
Embedded Forms overview - What Embedded Forms are, the ambient flow, and string versus structured. Platform client and provider -setSessionContext, updateSessionContext, and structured data methods.
SessionContext - Full session context shape, including precharted_content.
Offline mode - Track sessions that upload after the network returns.
Manage ambient session - Start, pause, and submit recording.