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

# List Workflow Runs

> List runs of a Workflow.

This endpoint allows you to fetch the runs of a given [workflow](/api-reference/objects/workflow).

This endpoint returns a paginated response. You can use the `nextPageToken` to fetch subsequent pages.

Each workflow run object contains a *summary* of the run. Full details are available by calling the [Get WorkflowRun](/api-reference/endpoint/get_workflow_run) endpoint.

### Query Parameters

<ParamField query="status" type="string" optional>
  Filters workflow runs by their status.

  Possible values include:

  * `PENDING`
  * `PROCESSING`
  * `NEEDS_REVIEW`
  * `REJECTED`
  * `PROCESSED`
  * `FAILED`
</ParamField>

<ParamField query="workflowId" type="string" optional>
  Filters workflow runs by the workflow ID.
</ParamField>

<ParamField query="batchId" type="string" optional>
  Filters workflow runs by the batch ID. This is useful for fetching all runs for a given batch created via the [Batch Run Workflow](/api-reference/endpoint/run_workflow_batch) endpoint.
</ParamField>

<ParamField query="sortBy" default="updatedAt" optional>
  Sorts the workflow runs by the given field.

  Possible values include:

  * `updatedAt`
  * `createdAt`
</ParamField>

<ParamField query="sortDir" default="desc" optional>
  Sorts the workflow runs in ascending or descending order.

  Possible values include:

  * `asc`: sort in ascending order
  * `desc`: sort in descending order
</ParamField>

<ParamField query="nextPageToken" optional>
  The token used to fetch the page of results from a previous request.

  **Note**: if parameters other than `nextPageToken` change in subsequent requests, you are likely to receive incomplete results.
</ParamField>

<ParamField query="maxPageSize" default="10" optional>
  The maximum number of results to return per page.

  You are not guaranteed to receive this many results per page, but you will not receive more than this.

  * Max: 1000
  * Min: 1
</ParamField>

### Response

<ResponseField name="success" type="boolean">
  A true or false value indicating whether the request was successful or not.
</ResponseField>

<ResponseField name="workflowRuns" type="array">
  An array of [WorkflowRun summary](/api-reference/objects/workflow_run_summary)
  objects.
</ResponseField>

<ResponseField name="nextPageToken" type="string" optional>
  The token used to fetch the next page of results.

  If there are no more pages, the token will not be present.

  The general pattern for collecting all results is to keep calling the endpoint with the `nextPageToken` and the same parameters, until the token is not present, for example:

  ```
  workflow_runs = []
  token = None
  while True:
    response = list_workflow_runs(nextPageToken=token)
    workflow_runs.extend(response.workflowRuns)
    token = response.nextPageToken
    if not token:
      break
  ```
</ResponseField>

### Error Responses

<ResponseField name="success" type="boolean">
  Will be `false` if the request failed.
</ResponseField>

<ResponseField name="error" type="string">
  A description of the error that occurred.
</ResponseField>

#### Possible Errors

* **404 Not Found**: If the specified workflow does not exist.
* **400 Bad Request**: If invalid query parameters are provided.

<ResponseExample>
  ```json Example Success Response theme={null}
  {
    "success": true,
    "nextPageToken": "abc123",
    "workflowRuns": [
    {
      "id": "workflow_run_1234",
      "status": "PROCESSED",
      "initialRunAt": "2023-01-01T09:41:00.000Z",
      "reviewedByUser": "user@example.com",
      "reviewedAt": "2023-01-10T05:39:14.500Z",
      "startTime": "2023-01-01T09:41:00.000Z",
      "endTime": "2023-01-10T05:39:24.500Z",
      "workflowId": "workflow_1234",
      "workflowName": "My Workflow",    
      "workflowVersionId": "workflow_version_1234",
      "batchId": "batch_1234",
      "rejectionNote": "This workflow run was rejected because it was not valid.",
      "createdAt": "2023-01-01T09:41:00.000Z",
      "updatedAt": "2023-01-10T05:39:24.500Z"
    },
    {
      "id": "workflow_run_1235",
      "status": "FAILED",
      "initialRunAt": "2023-01-01T09:41:00.000Z",
      "reviewedByUser": "user@example.com",
      "reviewedAt": "2023-01-10T05:39:14.500Z",
      "startTime": "2023-01-01T09:41:00.000Z",
      "endTime": "2023-01-10T05:39:24.500Z",
      "workflowId": "workflow_1234",
      "workflowName": "My Workflow",    
      "workflowVersionId": "workflow_version_1234",
      "batchId": "batch_1234",
      "rejectionNote": "This workflow run was rejected because it was not valid.",
      "createdAt": "2023-01-01T09:41:00.000Z",
        "updatedAt": "2023-01-10T05:39:24.500Z"
      }
    ]
  }
  ```
</ResponseExample>
