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

# CapturesResource: Manage Recordings, Screenshots, and Cookies

> Use the Figranium JavaScript SDK to list captures, delete recordings, manage browser cookies, and clear screenshots. Covers every CapturesResource method with typed examples.

The `CapturesResource` gives you access to recordings, screenshots, and browser cookies produced during task executions. You can list captures for a specific run, delete individual files, inspect stored cookies, and bulk-clear screenshots or cookies when you need to reclaim space or reset state.

```ts theme={null}
import { Figranium } from "@figranium/sdk";

const figranium = new Figranium({ apiKey: process.env.FIGRANIUM_API_KEY! });
```

## Methods

<AccordionGroup>
  <Accordion title="list">
    Returns all captures, including recordings and screenshots. Optionally filter by `runId`.

    * **HTTP endpoint:** `GET /api/data/captures` (with `runId` query parameter when set)
    * **Signature:** `captures.list(input: { runId?: string } = {}, options?: RequestOptions)`
    * **Returns:** `{ captures: Capture[] }`

    Each `Capture` has the following shape:

    ```ts theme={null}
    interface Capture {
      name: string;
      url: string;
      size: number;
      modified: number;
      type: "recording" | "screenshot";
    }
    ```

    ```ts list-captures.ts theme={null}
    const { captures } = await figranium.captures.list({ runId: "run_abc123" });

    for (const capture of captures) {
      console.log(`${capture.type}: ${capture.name} (${capture.size} bytes)`);
    }
    ```
  </Accordion>

  <Accordion title="screenshots">
    Returns only screenshot captures, omitting recordings.

    * **HTTP endpoint:** `GET /api/data/screenshots`
    * **Signature:** `captures.screenshots(options?: RequestOptions)`
    * **Returns:** `{ screenshots: Capture[] }`

    ```ts list-screenshots.ts theme={null}
    const { screenshots } = await figranium.captures.screenshots();

    for (const shot of screenshots) {
      console.log(`${shot.name}: ${shot.url}`);
    }
    ```
  </Accordion>

  <Accordion title="delete">
    Delete a single capture by its name.

    * **HTTP endpoint:** `DELETE /api/data/captures/:name`
    * **Signature:** `captures.delete(name: string, options?: RequestOptions)`
    * **Returns:** `{ success: boolean }`

    ```ts delete-capture.ts theme={null}
    const { success } = await figranium.captures.delete("run_abc123_recording.webm");
    ```
  </Accordion>

  <Accordion title="cookies">
    List stored browser cookies and their origins.

    * **HTTP endpoint:** `GET /api/data/cookies`
    * **Signature:** `captures.cookies(options?: RequestOptions)`
    * **Returns:** `{ cookies: UnknownRecord[]; origins: UnknownRecord[] }`

    ```ts list-cookies.ts theme={null}
    const { cookies, origins } = await figranium.captures.cookies();

    console.log(`Found ${cookies.length} cookies across ${origins.length} origins`);
    ```
  </Accordion>

  <Accordion title="deleteCookie">
    Remove a specific cookie by name, optionally scoped to a domain and path.

    * **HTTP endpoint:** `POST /api/data/cookies/delete`
    * **Signature:** `captures.deleteCookie(cookie: { name: string; domain?: string; path?: string }, options?: RequestOptions)`
    * **Returns:** `{ success: boolean }`

    ```ts delete-cookie.ts theme={null}
    const { success } = await figranium.captures.deleteCookie({
      name: "session_id",
      domain: "example.com",
      path: "/",
    });
    ```
  </Accordion>

  <Accordion title="clear">
    Delete all screenshots at once.

    * **HTTP endpoint:** `POST /api/data/clear-screenshots`
    * **Signature:** `captures.clear(options?: RequestOptions)`
    * **Returns:** `{ success: boolean }`

    ```ts clear-screenshots.ts theme={null}
    const { success } = await figranium.captures.clear();
    ```
  </Accordion>

  <Accordion title="clearCookies">
    Delete all stored cookies.

    * **HTTP endpoint:** `POST /api/data/clear-cookies`
    * **Signature:** `captures.clearCookies(options?: RequestOptions)`
    * **Returns:** `{ success: boolean }`

    ```ts clear-cookies.ts theme={null}
    const { success } = await figranium.captures.clearCookies();
    ```
  </Accordion>
</AccordionGroup>

## Working example: list captures for a run and delete cookies

This example combines `list` and `deleteCookie` to clean up after a run: it lists captures for a specific run, then removes a session cookie for the target domain.

```ts cleanup-after-run.ts theme={null}
const { captures } = await figranium.captures.list({ runId: "run_abc123" });

const recording = captures.find((c) => c.type === "recording");
if (recording) {
  console.log(`Recording: ${recording.name} (${recording.size} bytes)`);
}

const { success } = await figranium.captures.deleteCookie({
  name: "auth_token",
  domain: "example.com",
});

console.log("Cookie deleted:", success);
```

## Related resources

<CardGroup cols={2}>
  <Card title="Request options" icon="sliders" href="/docs/sdk/js/request-options">
    Pass `signal`, `timeoutMs`, and custom headers.
  </Card>

  <Card title="Errors" icon="triangle-exclamation" href="/docs/sdk/js/errors">
    Handle `FigraniumError` responses.
  </Card>

  <Card title="Executions" icon="bolt" href="/docs/sdk/js/resources/executions">
    Start runs that produce captures.
  </Card>
</CardGroup>
