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

# Poll Session Status Before Fetching Content

> Poll ambient session status until completed before calling content APIs

**Problem:** Content or note APIs return empty or incomplete results right after end session.

**Solution:** Poll [Get ambient session status](/api-reference/ambient-content/status) until `completed`, then retrieve. Treat `skipped`, `failed`, and `aborted` as terminal.

<Note>
  This cookbook assumes you already have your Partner ID, authentication tokens, and the other prerequisites for Ambient APIs.
</Note>

<Tabs>
  <Tab title="TypeScript">
    ```typescript theme={"theme":{"light":"github-dark","dark":"material-theme-darker"}}
    async function waitUntilCompleted(ambientSessionId: string) {
      for (let i = 0; i < 60; i++) {
        const res = await fetch(
          `https://sdp.suki.ai/api/v1/ambient/session/${ambientSessionId}/status`,
          {
            headers: {
              sdp_suki_token: sdpSukiToken,
              sdp_provider_id: sdpProviderId,
            },
          }
        );

        if (!res.ok) {
          throw new Error(`Get ambient session status failed: ${res.status}`);
        }

        const { status } = await res.json();
        if (status === "completed") return "completed";
        if (status === "skipped" || status === "failed" || status === "aborted") {
          return status;
        }

        await new Promise((r) => setTimeout(r, 2000));
      }

      throw new Error("Timed out waiting for session status");
    }

    const outcome = await waitUntilCompleted(ambientSessionId);
    if (outcome === "completed") {
      // Call session content or note content APIs
    }
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={"theme":{"light":"github-dark","dark":"material-theme-darker"}}
    import time
    import requests

    def wait_until_completed(ambient_session_id: str) -> str:
        for _ in range(60):
            res = requests.get(
                f"https://sdp.suki.ai/api/v1/ambient/session/{ambient_session_id}/status",
                headers={
                    "sdp_suki_token": sdp_suki_token,
                    "sdp_provider_id": sdp_provider_id,
                },
            )
            res.raise_for_status()
            status = res.json().get("status")
            if status == "completed":
                return "completed"
            if status in ("skipped", "failed", "aborted"):
                return status
            time.sleep(2)
        raise TimeoutError("Timed out waiting for session status")

    outcome = wait_until_completed(ambient_session_id)
    if outcome == "completed":
        # Call session content or note content APIs
        pass
    ```
  </Tab>
</Tabs>

## Common mistakes

* Sessions under \~**1 minute** often return `skipped`.
* WebSocket close alone does not mean the note is ready.

## Other cookbooks

<div className="cookbook-hub-wrap">
  <div className="hp-io-method-grid tut-hub-card-grid" data-cookbook-related-grid>
    <a className="hp-io-method-card tut-hub-method-card" href="/documentation/cookbooks/get-note-content-by-composition-id">
      <div className="tut-hub-card-media" aria-hidden="true" />

      <div className="hp-io-method-card-body">
        <div className="tut-hub-card-badges">
          <span className="hp-wn-badge hp-wn-badge-new">Ambient</span>
          <span className="hp-wn-badge cookbook-hub-badge-surface cookbook-hub-badge-surface--api">API</span>
        </div>

        <h3 className="hp-io-method-card-title">Fetch Note Content with composition\_id</h3>

        <p className="hp-io-method-card-desc cookbook-hub-card-desc">
          Retrieve the note with composition\_id.
        </p>

        <div className="hp-io-method-card-meta tut-hub-card-foot" aria-label="5 min">
          <div className="tut-hub-card-foot-meta">
            <span className="hp-io-method-card-meta-time">5 min</span>
          </div>
        </div>
      </div>
    </a>

    <a className="hp-io-method-card tut-hub-method-card" href="/documentation/cookbooks/resolve-session-conflict">
      <div className="tut-hub-card-media tut-hub-card-media--blue" aria-hidden="true" />

      <div className="hp-io-method-card-body">
        <div className="tut-hub-card-badges">
          <span className="hp-wn-badge hp-wn-badge-new">Ambient</span>
          <span className="hp-wn-badge cookbook-hub-badge-surface cookbook-hub-badge-surface--api">API</span>
        </div>

        <h3 className="hp-io-method-card-title">Clear a Remote Session Conflict</h3>

        <p className="hp-io-method-card-desc cookbook-hub-card-desc">
          End remote session, then retry.
        </p>

        <div className="hp-io-method-card-meta tut-hub-card-foot" aria-label="5 min">
          <div className="tut-hub-card-foot-meta">
            <span className="hp-io-method-card-meta-time">5 min</span>
          </div>
        </div>
      </div>
    </a>
  </div>
</div>
