> For the complete documentation index, see [llms.txt](https://docs.tonic.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tonic.ai/fabricate/fabricate-api/using-the-fabricate-npm-package/running-a-database-workflow.md).

# Running a database workflow

## Getting the parameter names for the workflow

When you run a workflow, you must provide any parameter values that the workflow requires.

On the workflow details panel, to get the parameter names, hover over each field label.

<figure><img src="https://4109733485-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmoU4gTR9LxlzHeWmQCUZ%2Fuploads%2FuyAiZ9AvnGnkxQEw2l1E%2FDataAgent_WorkflowParameterTooltip.png?alt=media&amp;token=b797f464-490f-4ac4-a5c7-d58bdf243095" alt=""><figcaption><p>Tooltip with the workflow parameter name</p></figcaption></figure>

The script view also lists the parameters.

<figure><img src="https://4109733485-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmoU4gTR9LxlzHeWmQCUZ%2Fuploads%2FD8q15I0x93dhvcJQxU9b%2FDataAgent_WorkflowParameterScript.png?alt=media&amp;token=f76e7478-3337-443a-8f69-7213d0cf1d1a" alt=""><figcaption><p>Parameters list on script view for a workflow</p></figcaption></figure>

## Making the run request

From the npm package, to run a workflow:

```
import { runWorkflow } from '@fabricate-tools/client'


const { result, task } = await runWorkflow({
  apiKey: 'your-api-key',
  apiUrl: 'https://fabricate.tonic.ai/api/v1',
  workspace: 'my_workspace',
  database: 'my_database',
  workflow: 'my_workflow',
  params: {
    paramName: 'paramValue'
  }
})
```

You can optionally request progress updates:

```
const { result, task } = await runWorkflow({
  apiKey: 'your-api-key',
  apiUrl: 'https://fabricate.tonic.ai/api/v1',
  workspace: 'my_workspace',
  database: 'my_database',
  workflow: 'my_workflow',
  params: {
    paramName: 'paramValue'
  },
  onProgress: ({ status, message }) => {
    console.log(`[${status}] ${message}`)
  },
})
```

## Listing and downloading workflow generated files

### **Listing the generated files**

To run the workflow and then list the files that the workflow generates:

```
const { result, task, downloadFile, downloadAllFiles } = await runWorkflow({
  apiKey: 'your-api-key',
  apiUrl: 'https://fabricate.tonic.ai/api/v1',
  workspace: 'my_workflow',
  database: 'my_database',
  workflow: 'export_report',
  params: { format: 'csv' },
})

if (task.files && task.files.length > 0) {
  console.log('Generated files:')
  for (const file of task.files) {
    console.log(`  - ${file.name} (${file.content_type}, ${file.size} bytes)`)
  }
}
```

### **Downloading all of the generated files**

To run a workflow and then download all of the generated files:

```
const { result, task, downloadFile, downloadAllFiles } = await runWorkflow({
  apiKey: 'your-api-key',
  apiUrl: 'https://fabricate.tonic.ai/api/v1',
  workspace: 'my_workflow',
  database: 'my_database',
  workflow: 'export_report',
  params: { format: 'csv' },
})

  await downloadAllFiles('./output')
}
```

### **Downloading a specific file**

To run a workflow and then download a specific generated file based on its identifier to a specified file name:

```
const { result, task, downloadFile, downloadAllFiles } = await runWorkflow({
  apiKey: 'your-api-key',
  apiUrl: 'https://fabricate.tonic.ai/api/v1',
  workspace: 'my_workflow',
  database: 'my_database',
  workflow: 'export_report',
  params: { format: 'csv' },
})


  const file = task.files[0]
  await downloadFile(file.id, `./output/${file.name}`)
}
```


---

# 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.tonic.ai/fabricate/fabricate-api/using-the-fabricate-npm-package/running-a-database-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.
