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

# client.logs

The `logs` method retrieves workflow run logs using the [List Workflow Runs API](/workflow/api-reference/logs/list-workflow-run-logs).

## Arguments

<ParamField body="cursor" type="string" optional>
  A pagination cursor from a previous request.
  Use this to fetch the next set of results.
</ParamField>

<ParamField body="count" type="number" optional>
  Maximum number of runs to return. Defaults to a system-defined value if not specified.
</ParamField>

<ParamField body="filter" type="object" optional>
  Filter options for narrowing down workflow run logs.

  <Expandable defaultOpen>
    <ParamField body="workflowRunId" type="string" optional>
      Filter by a specific workflow run ID.
    </ParamField>

    <ParamField body="state" type="string" optional>
      Filter workflow runs by execution state.

      | State          | Description                              |
      | -------------- | ---------------------------------------- |
      | `RUN_STARTED`  | The workflow run is in progress.         |
      | `RUN_SUCCESS`  | The workflow run completed successfully. |
      | `RUN_FAILED`   | The run failed after all retries.        |
      | `RUN_CANCELED` | The run was manually canceled.           |
    </ParamField>

    <ParamField body="workflowUrl" type="string" optional>
      Filter by the exact workflow URL.
    </ParamField>

    <ParamField body="label" type="string" optional>
      Filter by workflow label.
    </ParamField>

    <ParamField body="workflowCreatedAt" type="number" optional>
      Filter by the workflow creation time (Unix timestamp).
    </ParamField>

    <ParamField body="messageId" type="string" optional>
      Filter by a specific message ID.
    </ParamField>

    <ParamField body="fromDate" type="Date | number" optional>
      Filter workflow runs created after this date.
    </ParamField>

    <ParamField body="toDate" type="Date | number" optional>
      Filter workflow runs created before this date.
    </ParamField>

    <ParamField body="callerIp" type="string" optional>
      Filter by the IP address that triggered the workflow.
    </ParamField>

    <ParamField body="flowControlKey" type="string" optional>
      Filter by flow control key.
    </ParamField>
  </Expandable>
</ParamField>

## Response

<ResponseField name="cursor" type="string">
  A cursor to use for pagination.
  If no cursor is returned, there are no more workflow runs.
</ResponseField>

<Snippet file="workflow/logs.mdx" />

***

## Usage

```ts theme={"system"}
import { Client } from "@upstash/workflow";

const client = new Client({ token: "<QSTASH_TOKEN>" })

const { runs, cursor } = await client.logs()
```

### Paginate with cursor

```ts theme={"system"}
const allRuns = [];
let cursor: string | undefined;
do {
  const result = await client.logs({ cursor });
  allRuns.push(...result.runs);
  cursor = result.cursor;
} while (cursor);
```

### Filter by state

```ts theme={"system"}
const { runs } = await client.logs({
  filter: {
    state: "RUN_FAILED",
  }
})
```

### Filter by label and date range

```ts theme={"system"}
const { runs } = await client.logs({
  filter: {
    label: "my-workflow",
    fromDate: new Date("2024-01-01"),
    toDate: new Date("2024-06-01"),
  }
})
```
