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

# Upload Form Filling Pre-Recorded Audio

> Create a Form filling session with input_type audio_file, seed a template, mint the shared upload URL, and PUT one WAV without calling end session

# Upload Form Filling Pre-Recorded Audio

Create a Form filling session with `input_type` `audio_file`, seed at least one template, mint the shared Ambient upload URL, PUT one WAV, and skip end session. Processing starts when the upload succeeds.

## Problem

Form filling partners often already have an archived WAV from telephony or a telehealth system. They then try to stream that file live on `/ws/stream`, or they call end session after upload. Those steps belong to live `stream` sessions, not `audio_file` input.

For Form filling `audio_file` sessions, create with that `input_type`, seed at least one template, mint the shared Ambient upload URL with the Form filling session id, PUT one WAV, and skip end session.

## Architecture

![Flowchart: Create audio\_file, Seed template, PUT WAV, GET structured-data.](https://mintcdn.com/suki-1e08f176/Srzj30gTyAYo6M-z/documentation/assets/diagrams/cookbooks-upload-prerecorded-form-filling-audio-1-light.svg?fit=max\&auto=format\&n=Srzj30gTyAYo6M-z\&q=85\&s=c09d7a8a521ee86e5c7214e14db83517)

```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[Create audio_file] --> B[Seed template] --> C[PUT WAV] --> D[GET structured-data]
```

## Prerequisites

> [!TIP]
>
> Completed [Partner onboarding](https://developer.suki.ai/documentation/get-started/partner-onboarding.md) and can obtain `sdp_suki_token` from Login.

> [!TIP]
>
> A real Suki `FORM_TEMPLATE_ID` for your partner account. Do not invent template UUIDs.

> [!TIP]
>
> One WAV file, at most 500 MB.

## Solution

> [card] Before
>
> [Seed Form Filling with a Suki Template](https://developer.suki.ai/documentation/cookbooks/seed-form-filling-template-context.md)

> [card] This Recipe
>
> Create with `audio_file`, seed template context, PUT one WAV, skip end session.

> [card] Next
>
> Poll Form filling status, then retrieve structured data in [Form filling basic usage](https://developer.suki.ai/documentation/how-to/form-filling/form-filling-basic-usage.md).

Use the Form filling create `ambient_session_id` on the shared file-uploadurl endpoint. Do not reuse an Ambient clinical-note session id. Seed at least one template before you upload. Required PUT headers are `Content-Type: audio/wave` and `x-goog-if-generation-match: 0`. Full Form filling staging scripts live in [Upload pre-recorded audio](https://developer.suki.ai/documentation/how-to/form-filling/upload-prerecorded-audio.md).

> [tab] TypeScript
>
> ```typescript theme={"theme":{"light":"one-light","dark":"material-theme-darker"}}
> // upload-prerecorded-form-filling-audio.ts
> // Flow: create (audio_file) → seed context → GET file-uploadurl → PUT WAV → poll status
> import fs from "node:fs";
>
> const BASE_URL = process.env.SUKI_BASE_URL ?? "https://sdp.suki.ai";
> const SDP_SUKI_TOKEN = process.env.SDP_SUKI_TOKEN!; // from Login (suki_token)
> const SDP_PROVIDER_ID = process.env.SDP_PROVIDER_ID!; // required for Bearer / Single Auth
> const FORM_TEMPLATE_ID = process.env.FORM_TEMPLATE_ID!;
> const AUDIO_PATH = process.env.AUDIO_PATH ?? "visit.wav";
>
> function restHeaders(): Record<string, string> {
>   return {
>     sdp_suki_token: SDP_SUKI_TOKEN,
>     sdp_provider_id: SDP_PROVIDER_ID,
>     "Content-Type": "application/json",
>   };
> }
>
> async function createAudioFileSession(): Promise<string> {
>   const res = await fetch(`${BASE_URL}/api/v1/form-filling/session/create`, {
>     method: "POST",
>     headers: restHeaders(),
>     body: JSON.stringify({ input_type: "audio_file" }),
>   });
>   if (res.status !== 201) {
>     throw new Error(`Create Form filling session failed: ${res.status}`);
>   }
>   const { ambient_session_id } = (await res.json()) as {
>     ambient_session_id: string;
>   };
>   return ambient_session_id;
> }
>
> async function seedTemplateContext(
>   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({
>         values: [{ form_template_id: formTemplateId }],
>       }),
>     }
>   );
>   if (!res.ok) {
>     throw new Error(`Seed Form filling context failed: ${res.status}`);
>   }
> }
>
> async function mintUploadUrl(ambientSessionId: string): Promise<string> {
>   const res = await fetch(
>     `${BASE_URL}/api/v1/ambient/audio/file-uploadurl/${ambientSessionId}`,
>     { headers: restHeaders() }
>   );
>   if (!res.ok) {
>     throw new Error(`Mint upload URL failed: ${res.status}`);
>   }
>   const { presigned_url_response } = (await res.json()) as {
>     presigned_url_response: { url: string };
>   };
>   return presigned_url_response.url;
> }
>
> async function putWav(uploadUrl: string, audioPath: string): Promise<void> {
>   const res = await fetch(uploadUrl, {
>     method: "PUT",
>     headers: {
>       "Content-Type": "audio/wave",
>       "x-goog-if-generation-match": "0",
>     },
>     body: fs.readFileSync(audioPath),
>   });
>   if (!res.ok) {
>     throw new Error(`Upload failed: ${res.status} ${await res.text()}`);
>   }
> }
>
> const ambientSessionId = await createAudioFileSession();
> await seedTemplateContext(ambientSessionId, FORM_TEMPLATE_ID);
> const uploadUrl = await mintUploadUrl(ambientSessionId);
> await putWav(uploadUrl, AUDIO_PATH);
> console.log("Upload complete. Do not call end session.", ambientSessionId);
> // Next: poll Form filling status, then GET structured-data.
> ```

> [tab] Python
>
> ```python theme={"theme":{"light":"one-light","dark":"material-theme-darker"}}
> # upload_prerecorded_form_filling_audio.py
> # Flow: create (audio_file) → seed context → GET file-uploadurl → PUT WAV → poll status
> # pip install requests
>
> import os
>
> import requests
>
> BASE_URL = os.environ.get("SUKI_BASE_URL", "https://sdp.suki.ai")
> SDP_SUKI_TOKEN = os.environ["SDP_SUKI_TOKEN"]  # from Login (suki_token)
> SDP_PROVIDER_ID = os.environ["SDP_PROVIDER_ID"]  # required for Bearer / Single Auth
> FORM_TEMPLATE_ID = os.environ["FORM_TEMPLATE_ID"]
> AUDIO_PATH = os.environ.get("AUDIO_PATH", "visit.wav")
>
>
> def rest_headers() -> dict[str, str]:
>     return {
>         "sdp_suki_token": SDP_SUKI_TOKEN,
>         "sdp_provider_id": SDP_PROVIDER_ID,
>         "Content-Type": "application/json",
>     }
>
>
> def create_audio_file_session() -> str:
>     res = requests.post(
>         f"{BASE_URL}/api/v1/form-filling/session/create",
>         headers=rest_headers(),
>         json={"input_type": "audio_file"},
>         timeout=60,
>     )
>     if res.status_code != 201:
>         raise RuntimeError(f"Create Form filling session failed: {res.status_code}")
>     return res.json()["ambient_session_id"]
>
>
> def seed_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={"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}")
>
>
> def mint_upload_url(ambient_session_id: str) -> str:
>     res = requests.get(
>         f"{BASE_URL}/api/v1/ambient/audio/file-uploadurl/{ambient_session_id}",
>         headers=rest_headers(),
>         timeout=60,
>     )
>     res.raise_for_status()
>     return res.json()["presigned_url_response"]["url"]
>
>
> def put_wav(upload_url: str, audio_path: str) -> None:
>     with open(audio_path, "rb") as audio_file:
>         res = requests.put(
>             upload_url,
>             data=audio_file,
>             headers={
>                 "Content-Type": "audio/wave",
>                 "x-goog-if-generation-match": "0",
>             },
>             timeout=300,
>         )
>     res.raise_for_status()
>
>
> ambient_session_id = create_audio_file_session()
> seed_template_context(ambient_session_id, FORM_TEMPLATE_ID)
> upload_url = mint_upload_url(ambient_session_id)
> put_wav(upload_url, AUDIO_PATH)
> print("Upload complete. Do not call end session.", ambient_session_id)
> # Next: poll Form filling status, then GET structured-data.
> ```

**1. Create the Form filling session with audio\_file input**

Call Form filling create with `input_type` set to `audio_file`. Store `ambient_session_id`. See [Create Form filling session](https://developer.suki.ai/form-filling-api-reference/form-filling-sessions/create.md).

**2. Seed at least one form template**

`POST /api/v1/form-filling/session/{ambient_session_id}/context` with `{ "values": [{ "form_template_id": "..." }] }`. See [Seed Form Filling with a Suki Template](https://developer.suki.ai/documentation/cookbooks/seed-form-filling-template-context.md).

**3. Mint the upload URL and PUT one WAV**

Use the Form filling session id on the shared Ambient file-uploadurl endpoint, then PUT the WAV with `Content-Type: audio/wave` and `x-goog-if-generation-match: 0`. Do not call end session. See [Get file upload URL](https://developer.suki.ai/api-reference/ambient-sessions/file-uploadurl.md).

**4. Poll, then retrieve structured data**

Poll Form filling status until `completed`, then call structured-data.

## Try it

> [card]
>
> * **Create returns a Form filling audio\_file session**
>
>   Create with `input_type: "audio_file"` returns HTTP 201 and an `ambient_session_id`. Use that id on file-uploadurl, not an Ambient clinical-note session id.
>
> * **Context must include a template**
>
>   Seed with `values` and a real `form_template_id` before upload. Empty context means structured results stay empty.
>
> * **PUT starts processing**
>
>   A successful WAV upload starts generation. Do not call Form filling REST end after the PUT. Both signed headers are required on the PUT.

## Common mistakes

> [!WARNING]
>
> * Reuse an Ambient clinical-note session id on the shared file-uploadurl endpoint.
> * Seed after upload, or skip template context entirely.
> * Stream the WAV on `/ws/stream` or call end session after upload.

## Related cookbooks

Form Filling
API

### [Submit Form Filling Finished Transcript](https://developer.suki.ai/documentation/cookbooks/submit-finished-transcript-form-filling.md)

Form filling transcript create, seed, submit text.

10 min

Form Filling
API

### [Seed Form Filling with a Suki Template](https://developer.suki.ai/documentation/cookbooks/seed-form-filling-template-context.md)

List templates, then seed form\_template\_id.

10 min

Run This Recipe

[Open Full Tutorial](https://developer.suki.ai/documentation/tutorials/form-filling-websocket-code-example.md)
[View API Reference](https://developer.suki.ai/api-reference/ambient-sessions/file-uploadurl.md)

Step-by-step tutorial and API reference for this workflow.


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