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

# Jinba Flows

> Run Jinba Flows

## Overview

You can run Jinba Flows using the Jinba Flow tool. This tool allows you to execute flows that have been published on Jinba within another flow. Jinba tools also let you manage files in Jinba storage and read/write records in Jinba tables.

## Key Features

* `JINBA_FLOW_RUN`
  * This tool allows you to run Jinba Flows by providing the flow ID and any necessary arguments.
* `JINBA_FILE_UPLOAD` / `JINBA_FILE_GET` / `JINBA_FILE_SEARCH` / `JINBA_FILE_DELETE`
  * Upload, retrieve, search, and delete files in Jinba storage.
* `JINBA_TABLE_ADD_RECORD` / `JINBA_TABLE_GET_RECORDS` / `JINBA_TABLE_UPDATE_RECORD`
  * Insert, read, and update records in Jinba tables.

## Authentication

`JINBA_FLOW_RUN` requires no tool configuration. It runs a published flow in the same workspace: authentication uses the workspace API key (`secrets.JINBAFLOW_WS_API_KEY`), which is handled automatically on the server, and the API base URL is resolved from the server environment. Make sure the target flow is published before running it.

**Note**: Treat API keys as sensitive information and never commit them to public repositories.

### Example: Run Other Jinba Flows

```yaml theme={null}
- name: Run flow
  id: run_flow
  tool: JINBA_FLOW_RUN
  input:
    - name: id
      value: ecd528ac-fc53-44ad-8535-7051507e4958
- name: Run flow with args
  id: run_flow_with_args
  tool: JINBA_FLOW_RUN
  input:
    - name: id
      value: ecd528ac-fc53-44ad-8535-7051507e4958
    - name: args
      value: '[{"name":"input_1","value":"Hello, world!"}]'
```

## File Tools

The file tools authenticate with a Jinba Flow Workspace API Token via the `token` config, which defaults to `{{ secrets.JINBAFLOW_WS_API_KEY }}` — you usually do not need to set it explicitly.

### JINBA\_FILE\_UPLOAD

Upload a file to Jinba storage.

**Input**:

| Parameter     | Type   | Required | Description                                                                        |
| ------------- | ------ | -------- | ---------------------------------------------------------------------------------- |
| `file`        | string | Yes      | Base64 encoded file content or file URL starting with `https://` or `jinbaflow://` |
| `filename`    | string | Yes      | Name of the file (extension will be auto-detected from the file)                   |
| `workspaceId` | string | Yes      | Target workspace ID                                                                |

**Output**: File metadata including `id`, `name`, `size`, `extension`, `mimeType`, `createdAt`, `updatedAt`, `workspaceId`, `userId`, and `signedUrl`.

### JINBA\_FILE\_GET

Retrieve a file's metadata and a signed URL by file ID.

**Input**:

* `fileId` (string, required): The ID of the file to retrieve

**Output**: Same file metadata fields as `JINBA_FILE_UPLOAD`, including `signedUrl`.

### JINBA\_FILE\_SEARCH

Search files in Jinba storage.

**Input**:

| Parameter     | Type   | Required | Description                                     |
| ------------- | ------ | -------- | ----------------------------------------------- |
| `workspaceId` | string | No       | Optional workspace ID to filter files           |
| `query`       | string | No       | Query to search for                             |
| `limit`       | number | No       | Maximum number of files to return (default: 50) |
| `cursor`      | string | No       | Cursor for pagination                           |

**Output**: `items` (array of file metadata) and `nextCursor` for pagination.

### JINBA\_FILE\_DELETE

Delete a file from Jinba storage.

**Input**:

* `fileId` (string, required): The ID of the file to delete

**Output**: `id` and `success`.

### Example: Upload and Retrieve a File

```yaml theme={null}
- id: upload_file
  tool: JINBA_FILE_UPLOAD
  input:
    - name: file
      value: "{{steps.generate_report.result.url}}"
    - name: filename
      value: "monthly_report.pdf"
    - name: workspaceId
      value: "{{secrets.WORKSPACE_ID}}"

- id: get_file
  tool: JINBA_FILE_GET
  input:
    - name: fileId
      value: "{{steps.upload_file.id}}"
```

## Table Tools

The table tools are workspace-scoped: the workspace's API key is injected automatically, so no config is required.

### JINBA\_TABLE\_ADD\_RECORD

Insert a record into a Jinba table.

**Input**:

| Parameter | Type   | Required | Description                                                                                                                                                             |
| --------- | ------ | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `tableId` | string | Yes      | The table to insert a record into                                                                                                                                       |
| `fields`  | object | Yes      | Map of column name → value for the new record (e.g. `{ "Status": "done", "Score": 42 }`). Omitted columns default to the column's default value, or NULL if none is set |

**Output**: `result.recordId` — the ID of the newly inserted record.

### JINBA\_TABLE\_GET\_RECORDS

Read records from a Jinba table.

**Input**:

| Parameter       | Type   | Required | Description                                                                          |
| --------------- | ------ | -------- | ------------------------------------------------------------------------------------ |
| `tableId`       | string | Yes      | The table to read records from                                                       |
| `filter`        | object | No       | Equality filter: `{ <columnName>: <expectedValue> }`. Multiple keys are AND-combined |
| `sortColumn`    | string | No       | Column display name to sort by (defaults to `__updated_at`)                          |
| `sortDirection` | string | No       | `asc` or `desc` (default: `desc`)                                                    |
| `limit`         | number | No       | Number of records to return (1-500, default: 100)                                    |
| `offset`        | number | No       | Number of records to skip (default: 0)                                               |

**Output**: `result` with `items` (records as `{ __id, __created_at, __updated_at, __version, <columnName>: <value>, ... }`), `total`, `limit`, and `offset`. NUMBER columns are serialized as strings to preserve precision — coerce with `Number(value)` downstream if you need numeric arithmetic.

### JINBA\_TABLE\_UPDATE\_RECORD

Update a record in a Jinba table.

**Input**:

| Parameter  | Type   | Required | Description                                                                                                                   |
| ---------- | ------ | -------- | ----------------------------------------------------------------------------------------------------------------------------- |
| `tableId`  | string | Yes      | The table containing the record                                                                                               |
| `recordId` | string | Yes      | The ID of the record to update                                                                                                |
| `fields`   | object | Yes      | Map of column name → new value (e.g. `{ "Status": "done" }`). Omitted columns are left unchanged; pass null to clear a column |

**Output**: `result.recordId`.

### Example: Add and Update Table Records

```yaml theme={null}
- id: add_record
  tool: JINBA_TABLE_ADD_RECORD
  input:
    - name: tableId
      value: "{{secrets.TABLE_ID}}"
    - name: fields
      value: '{ "Status": "pending", "Title": "New task" }'

- id: get_records
  tool: JINBA_TABLE_GET_RECORDS
  input:
    - name: tableId
      value: "{{secrets.TABLE_ID}}"
    - name: filter
      value: '{ "Status": "pending" }'
    - name: limit
      value: 100

- id: update_record
  tool: JINBA_TABLE_UPDATE_RECORD
  input:
    - name: tableId
      value: "{{secrets.TABLE_ID}}"
    - name: recordId
      value: "{{steps.add_record.result.recordId}}"
    - name: fields
      value: '{ "Status": "done" }'
```
