---
orphan: true
---

# Trigger file workflow

Triggers the workflow associated with the specified file and returns the actual number triggered.

```text
POST https://moi.matrixorigin.cn/newmoi/catalog/file/trigger_workflow
```

## Preparation before calling

First [query the file list](list-files.md) to obtain the target file and the volume to which it belongs. Prepare a list of personal access tokens, target workspace IDs, volume IDs, and file IDs that have access to the target workspace.

The example below uses:

- `$AI_STUDIO_API_KEY`: The actual personal access token, passed through the `X-API-Key` Header.
- `$WORKSPACE_ID`: Target workspace ID, passed through `X-Workspace-ID` Header.
- `$VOLUME_ID`: ID of the root volume to which the file belongs.
- `$FILE_ID`: The file ID to trigger the associated workflow.

## Request example

```bash
curl -X POST "https://moi.matrixorigin.cn/newmoi/catalog/file/trigger_workflow" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H "Content-Type: application/json" \
  -d '{
    "volume_id": '"$VOLUME_ID"',
    "file_ids": ["'"$FILE_ID"'"]
  }'
```

## Request body

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `volume_id` | integer | Yes | ID of the root volume to which the file belongs. |
| `file_ids` | string[] | Yes | List of file IDs to trigger. |

`[]` after a type means an array. For example, `string[]` is an array of strings.

## Successful response

When successful, `200` is returned. `triggered` indicates the number of associated workflows actually triggered this time.

```json
{
  "code": "OK",
  "msg": "OK",
  "data": {
    "triggered": 1
  }
}
```

The response fields are as follows.

| Field | Type | Description |
| --- | --- | --- |
| `data.triggered` | integer | The number of associated workflows actually triggered this time. |

## Error response

```json
{
  "code": "ErrParamInvalid",
  "msg": "请求参数无效",
  "data": null
}
```

### Common HTTP errors

```{list-table}
:header-rows: 1
:widths: 12 22 32 34

* - HTTP status code
  - error code
  - Common causes
  - Recommended actions
* - `400`
  - `ErrParamInvalid`
  - Invalid volume ID or file ID list.
  - Check the resource identifier in the request body.
* - `403`
  - `ErrForbidden`
  - The current identity does not have read permission to the target volume.
  - Use credentials with read permissions.
* - `500`
  - `ErrServer`
  - The server failed to trigger the associated workflow.
  - Try again later and confirm the execution status via the relevant workflow page.
```
