> For the complete documentation index, see [llms.txt](https://docs.redivis.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.redivis.com/api/client-libraries/redivis-js/reference/workflow.md).

# Workflow

## *class* <mark style="color:purple;">Workflow</mark>

Workflows are where data analysis happens on Redivis. Workflows are owned by a user or organization, and contain datasources, transforms, notebooks, parameters, and the tables they produce. Various methods allow you to create and delete workflows, to construct and list the entities within a workflow, and to query its tables.

## Constructors

| Method                                                                                                                                                           | Description                                                                                                                                                                                                                      |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [**`redivis.workflow`**](https://docs.redivis.com/api/client-libraries/redivis-js/reference/redivis/redivis.workflow.md)(name\[, options])                       | Return a Workflow, given its qualified reference (e.g., `jane.my_workflow`), or its name within the [default user or organization](https://docs.redivis.com/api/client-libraries/redivis-js/reference.md#environment-variables). |
| [**`redivis.currentWorkflow`**](https://docs.redivis.com/api/client-libraries/redivis-js/reference/redivis/redivis.currentworkflow.md)()                         | Return the [default workflow](https://docs.redivis.com/api/client-libraries/redivis-js/reference.md#environment-variables), if one is set.                                                                                       |
| [**`Organization.workflow`**](https://docs.redivis.com/api/client-libraries/redivis-js/reference/organization/organization.workflow.md)(name)                    | Return a Workflow owned by an [organization](https://docs.redivis.com/api/client-libraries/redivis-js/reference/organization.md).                                                                                                |
| [**`User.workflow`**](https://docs.redivis.com/api/client-libraries/redivis-js/reference/user/user.workflow.md)(name)                                            | Return a Workflow owned by a [user](https://docs.redivis.com/api/client-libraries/redivis-js/reference/user.md).                                                                                                                 |
| [**`Organization.listWorkflows`**](https://docs.redivis.com/api/client-libraries/redivis-js/reference/organization/organization.listworkflows.md)(\[maxResults]) | List the Workflows owned by an organization.                                                                                                                                                                                     |
| [**`User.listWorkflows`**](https://docs.redivis.com/api/client-libraries/redivis-js/reference/user/user.listworkflows.md)(\[maxResults])                         | List the Workflows owned by a user.                                                                                                                                                                                              |

## Examples

{% tabs %}
{% tab title="Basics" %}

```javascript
const workflow = redivis.user('jane').workflow('my_workflow');

await workflow.exists(); // -> true
await workflow.get(); // workflow.properties is now populated with the workflow resource definition

workflow.table('output_table'); // -> Returns a Table
workflow.query('SELECT * FROM output_table'); // -> Returns a Query, scoped to the workflow
await workflow.listTables(); // -> Returns an array of Tables
```

{% endtab %}

{% tab title="Build a workflow" %}

```javascript
const workflow = await redivis.workflow('jane.my_workflow').create();

// Add a dataset as a source of the workflow
const datasource = await workflow.datasource('demo.iris_species').create();

// Create and run a transform
const transform = await workflow.transform().create({
  sourceTable: 'demo.iris_species.iris',
  query: 'SELECT Species, AVG(SepalLengthCm) AS avg_sepal_length FROM _source_ GROUP BY Species',
});
await transform.run();

const rows = await (await transform.outputTable()).toRowsArray();

// Clean up
await transform.delete();
await datasource.delete();
await workflow.delete();
```

{% endtab %}

{% tab title="List entities" %}

```javascript
const workflow = redivis.workflow('jane.my_workflow');

await workflow.listDatasources();
await workflow.listTransforms();
await workflow.listNotebooks();
await workflow.listParameters();
await workflow.listTables({ includeDatasources: true });
```

{% endtab %}
{% endtabs %}

## Attributes

| Name                     | Description                                                                                                                                                                                                                                                            |
| ------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **`name`**               | The workflow's name.                                                                                                                                                                                                                                                   |
| **`organization`**       | A reference to the [Organization](https://docs.redivis.com/api/client-libraries/redivis-js/reference/organization.md) that owns the workflow. Will be `undefined` if the workflow is owned by a user.                                                                  |
| **`user`**               | A reference to the [User](https://docs.redivis.com/api/client-libraries/redivis-js/reference/user.md) that owns the workflow. Will be `undefined` if the workflow is owned by an organization.                                                                         |
| **`properties`**         | An object containing the [API resource representation of the workflow](https://docs.redivis.com/api/resource-definitions/workflow.md). This will only be populated after certain methods are called, particularly the `get` method, and will otherwise be `undefined`. |
| **`qualifiedReference`** | The [fully qualified reference](https://docs.redivis.com/api/referencing-resources.md) to this workflow, e.g. `jane.my_workflow`                                                                                                                                       |
| **`scopedReference`**    | The canonical reference for the workflow, without its owner.                                                                                                                                                                                                           |

## Methods

| Method                                                                                                                                                   | Description                                                                                                                  |
| -------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| [**`Workflow.create`**](https://docs.redivis.com/api/client-libraries/redivis-js/reference/workflow/workflow.create.md)(\[options])                      | Create the workflow.                                                                                                         |
| [**`Workflow.datasource`**](https://docs.redivis.com/api/client-libraries/redivis-js/reference/workflow/workflow.datasource.md)(source)                  | Return a [Datasource](https://docs.redivis.com/api/client-libraries/redivis-js/reference/datasource.md) within the workflow. |
| [**`Workflow.delete`**](https://docs.redivis.com/api/client-libraries/redivis-js/reference/workflow/workflow.delete.md)()                                | Delete the workflow.                                                                                                         |
| [**`Workflow.exists`**](https://docs.redivis.com/api/client-libraries/redivis-js/reference/workflow/workflow.exists.md)()                                | Check whether the workflow exists.                                                                                           |
| [**`Workflow.get`**](https://docs.redivis.com/api/client-libraries/redivis-js/reference/workflow/workflow.get.md)()                                      | Fetch the workflow's metadata, populating `workflow.properties`.                                                             |
| [**`Workflow.listDatasources`**](https://docs.redivis.com/api/client-libraries/redivis-js/reference/workflow/workflow.listdatasources.md)(\[maxResults]) | List the workflow's [Datasources](https://docs.redivis.com/api/client-libraries/redivis-js/reference/datasource.md).         |
| [**`Workflow.listNotebooks`**](https://docs.redivis.com/api/client-libraries/redivis-js/reference/workflow/workflow.listnotebooks.md)(\[maxResults])     | List the workflow's [Notebooks](https://docs.redivis.com/api/client-libraries/redivis-js/reference/notebook.md).             |
| [**`Workflow.listParameters`**](https://docs.redivis.com/api/client-libraries/redivis-js/reference/workflow/workflow.listparameters.md)(\[maxResults])   | List the workflow's [Parameters](https://docs.redivis.com/api/client-libraries/redivis-js/reference/parameter.md).           |
| [**`Workflow.listTables`**](https://docs.redivis.com/api/client-libraries/redivis-js/reference/workflow/workflow.listtables.md)(\[maxResults, options])  | List the workflow's [Tables](https://docs.redivis.com/api/client-libraries/redivis-js/reference/table.md).                   |
| [**`Workflow.listTransforms`**](https://docs.redivis.com/api/client-libraries/redivis-js/reference/workflow/workflow.listtransforms.md)(\[maxResults])   | List the workflow's [Transforms](https://docs.redivis.com/api/client-libraries/redivis-js/reference/transform.md).           |
| [**`Workflow.notebook`**](https://docs.redivis.com/api/client-libraries/redivis-js/reference/workflow/workflow.notebook.md)(name)                        | Return a [Notebook](https://docs.redivis.com/api/client-libraries/redivis-js/reference/notebook.md) within the workflow.     |
| [**`Workflow.parameter`**](https://docs.redivis.com/api/client-libraries/redivis-js/reference/workflow/workflow.parameter.md)(name)                      | Return a [Parameter](https://docs.redivis.com/api/client-libraries/redivis-js/reference/parameter.md) within the workflow.   |
| [**`Workflow.query`**](https://docs.redivis.com/api/client-libraries/redivis-js/reference/workflow/workflow.query.md)(query)                             | Return a [Query](https://docs.redivis.com/api/client-libraries/redivis-js/reference/query.md) scoped to the workflow.        |
| [**`Workflow.table`**](https://docs.redivis.com/api/client-libraries/redivis-js/reference/workflow/workflow.table.md)(name)                              | Return a [Table](https://docs.redivis.com/api/client-libraries/redivis-js/reference/table.md) within the workflow.           |
| [**`Workflow.transform`**](https://docs.redivis.com/api/client-libraries/redivis-js/reference/workflow/workflow.transform.md)(\[name])                   | Return a [Transform](https://docs.redivis.com/api/client-libraries/redivis-js/reference/transform.md) within the workflow.   |
| [**`Workflow.updateVariables`**](https://docs.redivis.com/api/client-libraries/redivis-js/reference/workflow/workflow.updatevariables.md)(variables)     | Batch update variable metadata across the workflow's tables.                                                                 |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.redivis.com/api/client-libraries/redivis-js/reference/workflow.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
