> ## 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.

# Update Form Filling Session Context

> Partially update Form filling session context using the Form filling URL binding

Use this endpoint to partially update the
session context (Metadata provided when creating an ambient session (such as encounter type, patient age, diagnoses) that helps guide note generation and improve output quality.)
for Form filling sessions. Providing detailed context helps Suki generate more accurate structured form output.
This is a **PATCH** operation that allows partial updates to the session context.

> [!NOTE]
>
> The body of this request is optional. However, if you decide to provide context, you must provide **valid values** for the properties. When you send `form_filling`, each `values[]` entry must use exactly one of `form_template_id` or `schema`. Refer to [Dynamic Form filling](https://developer.suki.ai/documentation/concepts/form-filling/dynamic-form-filling.md).

**Language tabs (agents):** Equivalent code samples are available in: Python, TypeScript. Humans see one language at a time. Use the variant that matches the user's stack; behavior is the same across tabs.

> [tab] Python
>
> ```python expandable theme={"theme":{"light":"one-light","dark":"material-theme-darker"}}
> from typing import Any, NotRequired, Optional, TypedDict, Union, cast
>
> import requests
>
> BASE_URL = "https://sdp.suki-stage.com"
>
>
> class StaticFormEntry(TypedDict):
>     # Suki Medical form template. Do not also send `schema` in this object.
>     form_template_id: str
>
>
> class DynamicFormEntry(TypedDict):
>     # Partner-defined form. Do not also send `form_template_id` in this object.
>     schema: dict[str, Any]
>     id: NotRequired[str]
>     name: NotRequired[str]
>     type: NotRequired[str]
>
>
> FormFillingMetadata = Union[StaticFormEntry, DynamicFormEntry]
>
>
> class FormFillingContext(TypedDict):
>     # Non-empty list. Mix static and dynamic entries when needed.
>     values: list[FormFillingMetadata]
>
>
> class FormFillingUpdateContextRequest(TypedDict, total=False):
>     form_filling: FormFillingContext
>
>
> class FormFillingReturnedContext(TypedDict, total=False):
>     form_filling: FormFillingContext
>
>
> class FormFillingUpdateContextResponse(TypedDict):
>     context: FormFillingReturnedContext
>
>
> class ApiHttpError(RuntimeError):
>     def __init__(self, status: int, url: str, detail: str) -> None:
>         super().__init__(f"HTTP {status} {url}: {detail}")
>         self.status = status
>         self.url = url
>
>
> def _patch_json_expect(
>     url: str,
>     headers: dict[str, str],
>     payload: dict[str, Any],
>     expect_status: int,
> ) -> dict[str, Any]:
>     r = requests.patch(url, json=payload, headers=headers, timeout=60)
>     if r.status_code == expect_status:
>         data = r.json()
>         if isinstance(data, dict):
>             return data
>         raise ApiHttpError(expect_status, url, "response JSON was not an object")
>
>     detail = ""
>     try:
>         err = r.json()
>         if isinstance(err, dict) and isinstance(err.get("message"), str):
>             detail = err["message"]
>     except ValueError:
>         detail = (r.text or "")[:500]
>     raise ApiHttpError(r.status_code, url, detail or "(no body)")
>
>
> def login_for_suki_token(partner_id: str, partner_token: str, *, provider_id: Optional[str] = None) -> str:
>     url = f"{BASE_URL}/api/v1/auth/login"
>     body: dict[str, Any] = {"partner_id": partner_id, "partner_token": partner_token}
>     if provider_id is not None:
>         body["provider_id"] = provider_id
>     r = requests.post(url, json=body, headers={"Content-Type": "application/json"}, timeout=60)
>     if r.status_code != 200:
>         raise ApiHttpError(r.status_code, url, (r.text or "")[:500] or "(no body)")
>     data = r.json()
>     token = data.get("suki_token") if isinstance(data, dict) else None
>     if not isinstance(token, str) or not token:
>         raise ValueError(f"{url}: 200 response missing suki_token")
>     return token
>
>
> def update_form_filling_session_context(
>     suki_token: str,
>     ambient_session_id: str,
>     body: FormFillingUpdateContextRequest,
> ) -> FormFillingUpdateContextResponse:
>     """PATCH /api/v1/form-filling/session/{ambient_session_id}/context. HTTP 200 returns FormFillingUpdateContextResponse."""
>     url = f"{BASE_URL}/api/v1/form-filling/session/{ambient_session_id}/context"
>     headers = {"sdp_suki_token": suki_token, "sdp_provider_id": "<sdp_provider_id>", "Content-Type": "application/json"}
>     data = _patch_json_expect(url, headers, dict(body), 200)
>     ctx = data.get("context")
>     if not isinstance(ctx, dict):
>         raise ValueError(f"{url}: 200 response missing context")
>     return cast(FormFillingUpdateContextResponse, {"context": cast(FormFillingReturnedContext, ctx)})
>
>
> if __name__ == "__main__":
>     try:
>         token = login_for_suki_token("<partner_id>", "<partner_token>")
>
>         # Example mixes one Suki template and one partner schema.
>         # Each values[] entry must use either form_template_id or schema, never both.
>         out = update_form_filling_session_context(
>             token,
>             ambient_session_id="<ambient_session_id>",
>             body={
>                 "form_filling": {
>                     "values": [
>                         {"form_template_id": "019d4cdc-9319-7d81-ae2e-fd6de7f1b4f0"},
>                         {
>                             "id": "partner-custom-1",
>                             "name": "Custom Partner Form",
>                             "type": "NEURO_ASSESSMENT",
>                             "schema": {
>                                 "type": "object",
>                                 "properties": {"gcs": {"type": "number"}},
>                             },
>                         },
>                     ]
>                 }
>             },
>         )
>         form_filling = out["context"].get("form_filling")
>         print(form_filling)
>     except (ApiHttpError, ValueError) as e:
>         print(e)
> ```

> [tab] TypeScript
>
> ```typescript expandable theme={"theme":{"light":"one-light","dark":"material-theme-darker"}}
> const BASE_URL = "https://sdp.suki-stage.com";
>
> // Suki Medical form template. Do not also send `schema` in this object.
> type StaticFormEntry = { form_template_id: string };
>
> // Partner-defined form. Do not also send `form_template_id` in this object.
> type DynamicFormEntry = {
>   schema: Record<string, unknown>;
>   id?: string;
>   name?: string;
>   type?: string;
> };
>
> type FormFillingMetadata = StaticFormEntry | DynamicFormEntry;
> type FormFillingContext = { values: FormFillingMetadata[] }; // non-empty; mix allowed
> type FormFillingUpdateContextRequest = { form_filling?: FormFillingContext };
> type FormFillingReturnedContext = { form_filling?: FormFillingContext };
> type FormFillingUpdateContextResponse = { context: FormFillingReturnedContext };
>
> class ApiHttpError extends Error {
>   status: number;
>   url: string;
>   constructor(status: number, url: string, detail: string) {
>     super(`HTTP ${status} ${url}: ${detail}`);
>     this.status = status;
>     this.url = url;
>   }
> }
>
> async function patchJsonExpectObject(
>   url: string,
>   init: RequestInit,
>   expectStatus: number,
> ): Promise<Record<string, unknown>> {
>   const res = await fetch(url, init);
>   const text = await res.text();
>
>   if (res.status !== expectStatus) {
>     let msg = text.slice(0, 500);
>     try {
>       const data: unknown = text ? JSON.parse(text) : null;
>       if (data && typeof data === "object" && "message" in data) {
>         msg = String((data as { message?: string }).message ?? msg);
>       }
>     } catch {
>       // keep raw text
>     }
>     throw new ApiHttpError(res.status, url, msg || "(no body)");
>   }
>
>   if (!text) throw new ApiHttpError(res.status, url, "(empty body)");
>   const data: unknown = JSON.parse(text);
>   if (data && typeof data === "object" && !Array.isArray(data)) {
>     return data as Record<string, unknown>;
>   }
>   throw new ApiHttpError(res.status, url, "response JSON was not an object");
> }
>
> async function loginForSukiToken(body: {
>   partner_id: string;
>   partner_token: string;
>   provider_id?: string;
> }): Promise<string> {
>   const url = `${BASE_URL}/api/v1/auth/login`;
>   const json = await patchJsonExpectObject(
>     url,
>     {
>       method: "POST",
>       headers: { "Content-Type": "application/json" },
>       body: JSON.stringify(body),
>     },
>     200,
>   );
>   const token = json.suki_token;
>   if (typeof token !== "string" || !token) throw new Error(`${url}: missing suki_token`);
>   return token;
> }
>
> async function updateFormFillingSessionContext(
>   sukiToken: string,
>   ambientSessionId: string,
>   body: FormFillingUpdateContextRequest,
> ): Promise<FormFillingUpdateContextResponse> {
>   const url = `${BASE_URL}/api/v1/form-filling/session/${ambientSessionId}/context`;
>   const json = await patchJsonExpectObject(
>     url,
>     {
>       method: "PATCH",
>       headers: {
>         sdp_suki_token: sukiToken, sdp_provider_id: "<sdp_provider_id>",
>         "Content-Type": "application/json",
>       },
>       body: JSON.stringify(body),
>     },
>     200,
>   );
>   const context = json.context;
>   if (!context || typeof context !== "object" || Array.isArray(context)) {
>     throw new Error(`${url}: 200 response missing context`);
>   }
>   return { context: context as FormFillingReturnedContext };
> }
>
> async function main(): Promise<void> {
>   try {
>     const token = await loginForSukiToken({
>       partner_id: "<partner_id>",
>       partner_token: "<partner_token>",
>     });
>
>     // Example mixes one Suki template and one partner schema.
>     // Each values[] entry must use either form_template_id or schema, never both.
>     const out = await updateFormFillingSessionContext(token, "<ambient_session_id>", {
>       form_filling: {
>         values: [
>           { form_template_id: "019d4cdc-9319-7d81-ae2e-fd6de7f1b4f0" },
>           {
>             id: "partner-custom-1",
>             name: "Custom Partner Form",
>             type: "NEURO_ASSESSMENT",
>             schema: {
>               type: "object",
>               properties: { gcs: { type: "number" } },
>             },
>           },
>         ],
>       },
>     });
>
>     console.log(out.context.form_filling);
>   } catch (e) {
>     console.error(e instanceof Error ? e.message : e);
>   }
> }
>
> void main();
> ```


## OpenAPI

````yaml PATCH /api/v1/form-filling/session/{ambient_session_id}/context
openapi: 3.0.1
info:
  title: Suki Developer Platform
  description: >-
    REST and WebSocket APIs for the Suki Developer Platform. Authenticate with
    Login or Register to obtain a Suki access token, then integrate ambient
    clinical documentation, form filling, transcription, content rewrite, and
    reference metadata endpoints.
  contact: {}
  version: '1.0'
servers:
  - url: https://sdp.suki.ai
    description: >-
      Production base URL for Suki Developer Platform REST APIs. WebSocket
      endpoints use the same host with `wss://`.
security:
  - SukiTokenAuth: []
paths:
  /api/v1/form-filling/session/{ambient_session_id}/context:
    patch:
      tags:
        - /api/v1/form-filling/session
      summary: Update form-filling session context
      description: >-
        Updates Form filling session context. Use the same `values` rules as
        seed context: each entry is either a Suki template or a partner schema.
        On success, returns the updated `context.form_filling` value.
      parameters:
        - name: ambient_session_id
          in: path
          description: >-
            Form-filling session ID. The path parameter is named
            `ambient_session_id`, but this value identifies the form-filling
            session, not an ambient clinical documentation session. Use the ID
            returned from Create Form filling Session, or the UUID you supplied
            in that request.
          required: true
          schema:
            type: string
        - $ref: '#/components/parameters/ProviderIdHeader'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/controllers.FormFillingUpdateContextRequest'
            examples:
              static:
                summary: Update with static templates
                value:
                  form_filling:
                    values:
                      - form_template_id: 019d4cdc-9319-7d81-ae2e-fd6de7f1b4f0
              dynamic:
                summary: Update with a dynamic schema
                value:
                  form_filling:
                    values:
                      - id: partner-pain-1
                        name: Pain Form
                        type: PAIN_ASSESSMENT
                        schema:
                          title: Pain
                          type: object
                          properties:
                            pain_score:
                              type: number
              mixed:
                summary: Update with mixed entries
                value:
                  form_filling:
                    values:
                      - form_template_id: 019d4cdc-9319-7d81-ae2e-fd6de7f1b4f0
                      - id: partner-custom-1
                        name: Custom Partner Form
                        type: NEURO_ASSESSMENT
                        schema:
                          type: object
                          properties:
                            gcs:
                              type: number
        required: true
      responses:
        '200':
          description: Request succeeded.
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/controllers.FormFillingUpdateContextResponse
              examples:
                static:
                  summary: Static template context
                  value:
                    context:
                      form_filling:
                        values:
                          - form_template_id: 019d4cdc-9319-7d81-ae2e-fd6de7f1b4f0
                dynamic:
                  summary: Dynamic schema context
                  value:
                    context:
                      form_filling:
                        values:
                          - id: partner-wound-1
                            name: Wound Check
                            type: SKIN_ASSESSMENT
                            schema:
                              title: Wound Check
                              type: object
                              properties:
                                wound_status:
                                  type: string
                mixed:
                  summary: Mixed static and dynamic context
                  value:
                    context:
                      form_filling:
                        values:
                          - form_template_id: 019d4cdc-9319-7d81-ae2e-fd6de7f1b4f0
                          - id: partner-custom-1
                            name: Custom Partner Form
                            type: NEURO_ASSESSMENT
                            schema:
                              type: object
                              properties:
                                gcs:
                                  type: number
        '400':
          description: Bad request. The request body or parameters failed validation.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/controllers.BadRequestError'
        '401':
          description: Unauthorized. The Suki access token is missing, expired, or invalid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/controllers.AuthenticationError'
        '403':
          description: Forbidden. The authenticated user cannot access this resource.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/controllers.ForbiddenError'
        '404':
          description: Not found. The session, encounter, or resource ID does not exist.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/controllers.NotFoundError'
        '500':
          description: Internal server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/controllers.InternalServerError'
      security:
        - SukiTokenAuth: []
      x-codeSamples:
        - lang: bash
          label: cURL
          source: |-
            curl --request PATCH \
              --url https://sdp.suki.ai/api/v1/form-filling/session/<ambient_session_id>/context \
              --header 'Content-Type: application/json' \
              --header 'sdp_suki_token: <sdp_suki_token>' \
              --header 'sdp_provider_id: <sdp_provider_id>'
components:
  parameters:
    ProviderIdHeader:
      name: sdp_provider_id
      in: header
      description: >-
        **Optional** for standard partners.


        **Required** for:


        - **Bearer authentication.** Use the same `provider_id` returned by the
        Login or Register API.

        - **Single Auth Token authentication.** Include the same `provider_id`
        on every request as `sdp_provider_id`.
      required: false
      schema:
        type: string
        example: provider-123
  schemas:
    controllers.FormFillingUpdateContextRequest:
      type: object
      description: >-
        Partial update for Form filling session context. Send only the fields
        you want to change.
      properties:
        form_filling:
          description: Updated forms to fill for this session.
          allOf:
            - $ref: '#/components/schemas/controllers.FormFillingContext'
    controllers.FormFillingUpdateContextResponse:
      type: object
      properties:
        context:
          type: object
          description: Updated context for the form-filling session
          allOf:
            - $ref: '#/components/schemas/controllers.FormFillingReturnedContext'
      description: >-
        Response body for the
        /api/v1/form-filling/session/{ambient_session_id}/context PATCH endpoint
    controllers.BadRequestError:
      description: Bad Request Response
      type: object
      properties:
        code:
          type: integer
          example: 400
        message:
          type: string
          example: invalid request
    controllers.AuthenticationError:
      description: Authentication Failure Response
      type: object
      properties:
        code:
          type: integer
          example: 401
        message:
          type: string
          example: invalid token
    controllers.ForbiddenError:
      type: object
      properties:
        code:
          type: integer
          example: 403
          description: HTTP status code for the error.
        message:
          type: string
          example: forbidden
          description: Human-readable description of the authorization failure.
      description: Error response when the caller lacks permission.
    controllers.NotFoundError:
      description: Not Found Response
      type: object
      properties:
        code:
          type: integer
          example: 404
        message:
          type: string
          example: not found
    controllers.InternalServerError:
      description: Internal Server Error Response
      type: object
      properties:
        code:
          type: integer
          example: 500
        message:
          type: string
          example: internal server error
    controllers.FormFillingContext:
      type: object
      description: Form list for the Form filling session.
      required:
        - values
      properties:
        values:
          description: >-
            Forms to fill in this session. Include at least one entry. Each
            entry is either a Suki template or a partner schema. You can mix
            both types in the same list.
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/controllers.FormFillingMetadata'
    controllers.FormFillingReturnedContext:
      description: >-
        Updated session context returned by form-filling context PATCH.
        Form-filling only; not used by ambient session context APIs.
      type: object
      properties:
        form_filling:
          type: object
          description: '**Optional** - Form template metadata for the session'
          allOf:
            - $ref: '#/components/schemas/controllers.FormFillingContext'
    controllers.FormFillingMetadata:
      description: >-
        One form to fill. Send either `form_template_id` or `schema`. Do not
        send both, and do not leave both empty.
      oneOf:
        - title: Static template
          type: object
          required:
            - form_template_id
          additionalProperties: false
          properties:
            form_template_id:
              description: >-
                Suki Medical form template ID. Get this from `GET
                /api/v1/info/suki-medical-form-templates`.
              type: string
              format: uuid
              example: 019d4cdc-9319-7d81-ae2e-fd6de7f1b4f0
        - title: Dynamic schema
          type: object
          required:
            - schema
          additionalProperties: false
          properties:
            schema:
              description: >-
                Partner-defined form fields to fill. Use this when the form is
                not a Suki template.
              type: object
              additionalProperties: true
              example:
                title: Wound Check
                type: object
                properties:
                  wound_status:
                    type: string
            id:
              description: >-
                Optional partner ID for this form. If set, structured data
                returns it as `generated_values[].id`.
              type: string
              example: partner-wound-1
            name:
              description: >-
                Optional display name for this form. If set, structured data
                returns it as `generated_values[].title`.
              type: string
              example: Wound Check
            type:
              description: >-
                Optional form type name, such as `VITALS_ASSESSMENT`. Use the
                enum name, not a number. If omitted, Suki treats it as
                `FORM_TYPE_UNSPECIFIED`.
              type: string
              enum:
                - FORM_TYPE_UNSPECIFIED
                - SKIN_ASSESSMENT
                - NEURO_ASSESSMENT
                - VITALS_ASSESSMENT
                - RESPIRATORY_ASSESSMENT
                - GENITO_URINARY_ASSESSMENT
                - GASTRO_INTESTINAL_ASSESSMENT
                - CARDIAC_ASSESSMENT
                - MSK_ASSESSMENT
                - IO_ASSESSMENT
                - PAIN_ASSESSMENT
                - NIHSS_ASSESSMENT
                - BRADEN_ASSESSMENT
                - HRA_ASSESSMENT
                - LDA_GROUP
                - ROVER_NURSING_SCHEMA_LOAD
              example: VITALS_ASSESSMENT
  securitySchemes:
    SukiTokenAuth:
      type: apiKey
      in: header
      name: sdp_suki_token
      description: >-
        Suki access token (`suki_token`) from Login or Register. Expires after
        one hour.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.