Functions

client.logs

The logs method retrieves workflow run logs using the List Workflow Runs API.

Arguments

cursorbodystring

A pagination cursor from a previous request. Use this to fetch the next set of results.

countbodynumber

Maximum number of runs to return. Defaults to a system-defined value if not specified.

filterbodyobject

Filter options for narrowing down workflow run logs.

Response

cursorstring

A cursor to use for pagination. If no cursor is returned, there are no more workflow runs.

runsArray

Usage

import { Client } from "@upstash/workflow";const client = new Client({ token: "<QSTASH_TOKEN>" })const { runs, cursor } = await client.logs()

Paginate with cursor

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

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

Filter by label and date range

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

Filter by multiple labels

Passing an array matches runs that have any of the given labels (OR semantics). For example, with runs labelled ["label-1", "label-2"] and ["label-2", "label-3"], filtering by ["label-1", "label-2"] returns both.

const { runs } = await client.logs({  filter: {    label: ["label-1", "label-2"],  }})
Loading search…