# 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="/files/D7dh3FYjsdFP3P5T4iIn" alt=""><figcaption><p>Tooltip with the workflow parameter name</p></figcaption></figure>

The script view also lists the parameters.

<figure><img src="/files/lurXkwvLZW0arco8WhKM" 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: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tonic.ai/fabricate/fabricate-api/using-the-fabricate-npm-package/running-a-database-workflow.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
