Skip to main content
This guide shows how to seed, update, and read Embedded Forms with the Headless Web SDK. For what Embedded Forms are and when to use 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

Call setSessionContext 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.
For when to use type: "string" versus type: "structured", refer to Prior text and Embedded Form 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.
The following types show the shape of sections you pass to setSessionContext and updateSessionContext:
TypeScript
React

Update Embedded Forms during a visit

Call updateSessionContext to change sections or templates after the first seed. Prefer the useUpdateAmbientSessionContext hook, which wraps the same call.
  • updateMask is required. Prefer ["sections"]. The string "sections" is also valid.
  • precharted_content lives on sections[]. Mask the top-level sections field, then send the full sections list 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 as patient.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 in section_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.
The SDK does not poll for filled values in the background. Call the helpers, or refetch the hooks, when your app knows the note is ready. To poll with a hook, pass refetchIntervalMs.
Each filled value is { 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.
Each read hook also has a query options factory, such as 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 with setSessionContext from useAmbientSession, records the visit, updates the templates, and reads the filled values.
React
The following component reads the filled values and the diagnoses after submit. The hooks do not poll by default. Pass 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 in updateMask into 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 setSessionContext first.
For how the SDK handles offline sessions, refer to Offline mode.

Troubleshooting

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.
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.
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.
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.
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.
Last modified on October 16, 2026