> ## Documentation Index
> Fetch the complete documentation index at: https://developer.suki.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Seed Form Filling with a Suki Template

> List Suki Medical form template IDs, then seed Form filling session context with form_template_id before you stream

export const CbRecipeMeta = ({items = []}) => <div className="cb-recipe-meta">
    {items.map(item => <span className={`cb-recipe-pill cb-recipe-pill--${item.type}${item.tone ? ` cb-recipe-pill--${item.tone}` : ""}`} key={`${item.type}-${item.label}`}>
        {item.type === "time" ? <svg className="cb-recipe-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" aria-hidden="true">
            <circle cx="12" cy="12" r="10" />
            <polyline points="12 6 12 12 16 14" />
          </svg> : item.type === "level" ? <svg className="cb-recipe-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" aria-hidden="true">
            <path d="M2 20h.01" />
            <path d="M7 20v-4" />
            <path d="M12 20v-8" />
            <path d="M17 20V8" />
            <path d="M22 20V4" />
          </svg> : item.type === "surface" ? <svg className="cb-recipe-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" aria-hidden="true">
            <polyline points="16 18 22 12 16 6" />
            <polyline points="8 6 2 12 8 18" />
          </svg> : <svg className="cb-recipe-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" aria-hidden="true">
            <path d="M12 3v3" />
            <path d="M12 18v3" />
            <path d="M3 12h3" />
            <path d="M18 12h3" />
            <path d="M5.6 5.6l2.1 2.1" />
            <path d="M16.3 16.3l2.1 2.1" />
            <path d="M5.6 18.4l2.1-2.1" />
            <path d="M16.3 7.7l2.1-2.1" />
          </svg>}
        {item.label}
      </span>)}
  </div>;

export const CbRecipePage = ({title, description, meta, recipeId, sidebar = {}, children}) => {
  const {tutorialHref, tutorialLabel = "Open Full Tutorial", apiHref, apiLabel = "View API Reference", authSections = [], glance = [], headers = []} = sidebar;
  return <div className="hp-wrap api-overview-wrap docs-frame-wrap cb-recipe-wrap" data-cb-recipe data-disable-read-time="true">
      <header className="cb-recipe-hero tut-hub-intro">
        <h1 className="sdk-overview-main-title api-overview-hero-page-title">{title}</h1>
        {description ? <div className="wse-prose">{description}</div> : null}
        {meta ? <div className="cb-recipe-meta-slot">{meta}</div> : null}
      </header>

      <div className="cb-recipe-body">
        <div className="cb-recipe-layout">
          <div className="cb-recipe-main prose prose-gray dark:prose-invert">{children}</div>

          <aside className="cb-recipe-sidebar" aria-label="Recipe actions and metadata">
            {recipeId ? <div className="cb-recipe-sidebar-card cb-recipe-sidebar-card--run">
                <div className="cb-run" data-cb-run data-recipe-id={recipeId} data-recipe-title={title}>
                  <button type="button" className="cb-run-trigger" aria-expanded="false">
                    <svg className="cb-run-trigger-icon" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true">
                      <path d="M8 5v14l11-7L8 5z" />
                    </svg>
                    <span>Run This Recipe</span>
                    <svg className="cb-run-trigger-chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" aria-hidden="true">
                      <polyline points="6 9 12 15 18 9" />
                    </svg>
                  </button>
                </div>
              </div> : null}

            <div className="cb-recipe-sidebar-card cb-recipe-sidebar-card--actions">
              <div className="cb-recipe-sidebar-actions">
                {tutorialHref ? <a className="cb-recipe-action cb-recipe-action--primary" href={tutorialHref}>
                    <svg className="cb-recipe-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" aria-hidden="true">
                      <path d="M4 19.5A2.5 2.5 0 0 1 6.5 17H20" />
                      <path d="M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z" />
                    </svg>
                    <span>{tutorialLabel}</span>
                  </a> : null}
                {apiHref ? <a className="cb-recipe-action cb-recipe-action--secondary" href={apiHref}>
                    <svg className="cb-recipe-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" aria-hidden="true">
                      <path d="M8 4H6a2 2 0 0 0-2 2v4" />
                      <path d="M8 20H6a2 2 0 0 1-2-2v-4" />
                      <path d="M16 4h2a2 2 0 0 1 2 2v4" />
                      <path d="M16 20h2a2 2 0 0 0 2-2v-4" />
                    </svg>
                    <span>{apiLabel}</span>
                  </a> : null}
              </div>
              <div className="cb-recipe-sidebar-caption">
                Step-by-step tutorial and API reference for this workflow.
              </div>
            </div>

            {authSections.length ? <div className="cb-recipe-sidebar-card">
                <div className="cb-recipe-sidebar-kicker">Auth</div>
                {authSections.map(section => <div className="cb-recipe-auth-block" key={section.title}>
                    <div className="cb-recipe-auth-title">{section.title}</div>
                    <div className="cb-recipe-sidebar-copy">
                      {section.text}{" "}
                      {section.href ? <a href={section.href}>{section.linkLabel || "Learn more"}</a> : null}
                    </div>
                    {section.scopes?.length ? <div className="cb-recipe-scope-pills cb-recipe-auth-scopes">
                        {section.scopes.map(scope => <span className="cb-recipe-scope-pill" key={scope}>
                            {scope}
                          </span>)}
                      </div> : null}
                  </div>)}
              </div> : null}

            {glance.length ? <div className="cb-recipe-sidebar-card">
                <div className="cb-recipe-sidebar-kicker">At a glance</div>
                <dl className="cb-recipe-glance">
                  {glance.map(row => <div className="cb-recipe-glance-row" key={row.label}>
                      <dt>{row.label}</dt>
                      <dd>{row.value}</dd>
                    </div>)}
                </dl>
              </div> : null}

            {headers.length ? <div className="cb-recipe-sidebar-card">
                <div className="cb-recipe-sidebar-kicker">Required headers</div>
                <div className="cb-recipe-auth-title">Partner API</div>
                <div className="cb-recipe-scope-pills">
                  {headers.map(h => <span className="cb-recipe-scope-pill" key={h}>
                      {h}
                    </span>)}
                </div>
              </div> : null}
          </aside>
        </div>
      </div>
    </div>;
};

<CbRecipePage
  recipeId="seed-form-filling-template-context"
  title="Seed Form Filling with a Suki Template"
  description="Form filling needs at least one form in session context before you end the session. List Suki Medical form templates, pick a `template_id`, then seed context with `form_template_id`."
  meta={
<CbRecipeMeta
  items={[
    { type: "time", label: "10 min" },
    { type: "level", label: "Beginner" },
    { type: "product", label: "Form Filling" },
    { type: "surface", label: "API", tone: "api" },
  ]}
/>
}
  sidebar={{
tutorialHref: "/documentation/tutorials/form-filling-websocket-code-example",
apiHref: "/form-filling-api-reference/form-filling-sessions/context",
authSections: [
  {
    title: "Partner API",
    text: "Authenticate every REST call with Partner Token headers on each request. See",
    href: "/documentation/get-started/partner-authentication",
    linkLabel: "Partner authentication",
    scopes: ["sdp_suki_token", "sdp_provider_id"],
  },
],
glance: [
  { label: "Product", value: "Form Filling" },
  { label: "Surface", value: "Partner API" },
  { label: "Time", value: "~10 min" },
  { label: "Level", value: "Beginner" },
],
}}
>
  ## Problem

  You create a Form filling session and stream audio, but structured results are empty or the context call fails. The session has no form bound yet.

  Seed context with at least one Suki `form_template_id` (or a partner `schema`) before you end the session. List available templates from [Suki Medical form templates](/form-filling-api-reference/info/suki-medical-form-templates), then call [Seed Form filling session context](/form-filling-api-reference/form-filling-sessions/context).

  ## Architecture

  ```mermaid actions={false} theme={"theme":{"light":"one-light","dark":"material-theme-darker"}}
  %%{init: {'theme':'base', 'themeVariables': { 'primaryColor':'#FFFBDE','primaryTextColor':'#1C1C1C','primaryBorderColor':'#FFD147','lineColor':'#6F5410','secondaryColor':'#FFFDF5','tertiaryColor':'#FFEB94','fontSize':'13px'}}}%%
  flowchart LR
    A[Login] --> B[Create Form filling session]
    B --> C[List Suki templates]
    C --> D[POST /context]
    D --> E[Stream /ws/stream]
  ```

  ## Prerequisites

  <Check>Completed [Partner onboarding](/documentation/get-started/partner-onboarding) and can obtain `sdp_suki_token` from Login.</Check>

  <Check>A Form filling session id from create (`ambient_session_id` on the Form filling create response).</Check>

  <Check>Suki enabled Medical form templates for your partner account. Do not invent template UUIDs.</Check>

  ## Solution

  <Columns cols={3}>
    <Card title="Before">
      Login, then create a Form filling session.
    </Card>

    <Card title="This Recipe">
      List Suki templates and seed context with `form_template_id`.
    </Card>

    <Card title="Next">
      Stream on `/ws/stream` with [Send START\_TIME Before Ambient Audio](/documentation/cookbooks/send-start-time-before-ambient-audio), then end the Form filling session.
    </Card>
  </Columns>

  Each object in `form_filling.values` must use exactly one of `form_template_id` or `schema`. This recipe uses a static Suki template. For partner-defined forms, see [Dynamic Form filling](/documentation/concepts/form-filling/dynamic-form-filling).

  <Tabs>
    <Tab title="TypeScript">
      ```typescript theme={"theme":{"light":"one-light","dark":"material-theme-darker"}}
      // seed-form-filling-template-context.ts
      // Flow: list Suki templates → pick template_id → POST Form filling context

      const BASE_URL = process.env.SUKI_BASE_URL ?? "https://sdp.suki.ai";
      const SDP_SUKI_TOKEN = process.env.SDP_SUKI_TOKEN!;
      const SDP_PROVIDER_ID = process.env.SDP_PROVIDER_ID ?? "";
      const AMBIENT_SESSION_ID = process.env.AMBIENT_SESSION_ID!; // Form filling create response

      function restHeaders(): Record<string, string> {
        const headers: Record<string, string> = {
          "Content-Type": "application/json",
          sdp_suki_token: SDP_SUKI_TOKEN,
        };
        if (SDP_PROVIDER_ID) headers.sdp_provider_id = SDP_PROVIDER_ID;
        return headers;
      }

      type MedicalFormTemplate = {
        template_id?: string;
        name?: string;
        description?: string;
      };

      async function listSukiFormTemplates(): Promise<MedicalFormTemplate[]> {
        const res = await fetch(`${BASE_URL}/api/v1/info/suki-medical-form-templates`, {
          headers: restHeaders(),
        });
        if (!res.ok) {
          throw new Error(`List form templates failed: ${res.status}`);
        }
        const data = (await res.json()) as { form_templates?: MedicalFormTemplate[] };
        if (!Array.isArray(data.form_templates)) {
          throw new Error("Response missing form_templates array");
        }
        return data.form_templates;
      }

      async function seedFormFillingTemplateContext(
        ambientSessionId: string,
        formTemplateId: string
      ): Promise<void> {
        const res = await fetch(
          `${BASE_URL}/api/v1/form-filling/session/${ambientSessionId}/context`,
          {
            method: "POST",
            headers: restHeaders(),
            body: JSON.stringify({
              form_filling: {
                values: [{ form_template_id: formTemplateId }],
              },
            }),
          }
        );
        if (!res.ok) {
          throw new Error(`Seed Form filling context failed: ${res.status}`);
        }
      }

      const templates = await listSukiFormTemplates();
      const formTemplateId = templates.find((t) => typeof t.template_id === "string")
        ?.template_id;
      if (!formTemplateId) {
        throw new Error("No template_id returned. Confirm templates are enabled for your partner.");
      }

      await seedFormFillingTemplateContext(AMBIENT_SESSION_ID, formTemplateId);
      console.log("Seeded form_template_id:", formTemplateId);
      ```
    </Tab>

    <Tab title="Python">
      ```python theme={"theme":{"light":"one-light","dark":"material-theme-darker"}}
      # seed_form_filling_template_context.py
      # Flow: list Suki templates → pick template_id → POST Form filling context
      # pip install requests

      import os
      from typing import Any

      import requests

      BASE_URL = os.environ.get("SUKI_BASE_URL", "https://sdp.suki.ai")
      SDP_SUKI_TOKEN = os.environ["SDP_SUKI_TOKEN"]
      SDP_PROVIDER_ID = os.environ.get("SDP_PROVIDER_ID", "")
      AMBIENT_SESSION_ID = os.environ["AMBIENT_SESSION_ID"]  # Form filling create response


      def rest_headers() -> dict[str, str]:
          headers = {
              "Content-Type": "application/json",
              "sdp_suki_token": SDP_SUKI_TOKEN,
          }
          if SDP_PROVIDER_ID:
              headers["sdp_provider_id"] = SDP_PROVIDER_ID
          return headers


      def list_suki_form_templates() -> list[dict[str, Any]]:
          res = requests.get(
              f"{BASE_URL}/api/v1/info/suki-medical-form-templates",
              headers=rest_headers(),
              timeout=60,
          )
          res.raise_for_status()
          templates = res.json().get("form_templates")
          if not isinstance(templates, list):
              raise RuntimeError("Response missing form_templates array")
          return templates


      def seed_form_filling_template_context(
          ambient_session_id: str,
          form_template_id: str,
      ) -> None:
          res = requests.post(
              f"{BASE_URL}/api/v1/form-filling/session/{ambient_session_id}/context",
              headers=rest_headers(),
              json={
                  "form_filling": {
                      "values": [{"form_template_id": form_template_id}],
                  }
              },
              timeout=60,
          )
          if res.status_code != 200:
              raise RuntimeError(f"Seed Form filling context failed: {res.status_code} {res.text}")


      templates = list_suki_form_templates()
      form_template_id = next(
          (t["template_id"] for t in templates if isinstance(t.get("template_id"), str)),
          None,
      )
      if not form_template_id:
          raise RuntimeError(
              "No template_id returned. Confirm templates are enabled for your partner."
          )

      seed_form_filling_template_context(AMBIENT_SESSION_ID, form_template_id)
      print("Seeded form_template_id:", form_template_id)
      ```
    </Tab>
  </Tabs>

  <Steps>
    <Step title="Create the Form filling session">
      Call Form filling create and store `ambient_session_id`. See [Form filling basic usage](/documentation/how-to/form-filling/form-filling-basic-usage).
    </Step>

    <Step title="List Suki Medical form templates">
      `GET /api/v1/info/suki-medical-form-templates` returns `form_templates[].template_id`. Use those values as `form_template_id`.
    </Step>

    <Step title="Seed session context">
      `POST /api/v1/form-filling/session/{ambient_session_id}/context` with `form_filling.values` containing `{ "form_template_id": "..." }`. Expect HTTP 200.
    </Step>

    <Step title="Stream and end">
      Stream on `/ws/stream` (same wire format as Ambient), then end with the Form filling REST end endpoint. Retrieve structured data after the session completes.
    </Step>
  </Steps>

  ## Try it

  <Card>
    * **List returns real template\_id values**

      Your partner account should return one or more `template_id` strings. Empty list means templates are not enabled yet.

    * **Context accepts form\_template\_id**

      A successful seed returns HTTP 200. Do not send both `form_template_id` and `schema` in the same `values[]` object.

    * **Stream uses Ambient wire format**

      Form filling audio uses `/ws/stream` with `START_TIME`, PCM in `data`, and `RU9G`, then Form filling REST end.
  </Card>

  ## Common mistakes

  <Warning>
    * Invent a `form_template_id` UUID instead of listing Suki templates for your partner.
    * Put both `form_template_id` and `schema` in the same `values[]` entry.
    * Seed after you already ended the session, or skip seed entirely before retrieve.
  </Warning>

  ## Related cookbooks

  <Columns cols={2}>
    <Card title="Send START_TIME Before Ambient Audio" href="/documentation/cookbooks/send-start-time-before-ambient-audio" arrow={true} icon="book-open">
      Send START\_TIME before PCM on /ws/stream.
    </Card>

    <Card title="End Ambient after Streaming" href="/documentation/cookbooks/end-ambient-after-streaming" arrow={true} icon="book-open">
      Same RU9G wire end; use Form filling REST end for Form filling sessions.
    </Card>
  </Columns>
</CbRecipePage>
