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

# Affinity: V2 Files Search Post

> Search Files by Keyword. Includes SDK V2 and CLI requests, input constraints, response fields, and Deepline credit cost.

Search Files by Keyword.

<Info>
  Tool ID: `affinity_v2_files_search_post`
</Info>

## Run this action

Use the TypeScript SDK for a single call. Put `ctx.tools.execute(...)` inside a Play when the call should be durable, scheduled, or run across a CSV.

```ts theme={null}
import { Deepline } from 'deepline';

const deepline = await Deepline.connect();
const result = await deepline.tools.execute(
  'affinity_v2_files_search_post',
  {
    "prompt": "example"
  },
);

console.log(result.toolResponse.raw);
```

### CLI

```bash theme={null}
deepline tools execute affinity_v2_files_search_post --input '{
  "prompt": "example"
}' --json
```

## Example response

The SDK exposes this shape at `result.toolResponse.raw`. Values below are representative.

```json theme={null}
{
  "data": {
    "data": [
      {
        "file": {
          "id": 123,
          "name": "Example"
        },
        "pageNumber": 1,
        "preview": "example"
      }
    ]
  }
}
```

Use `deepline tools get affinity_v2_files_search_post --json` for the latest machine-readable contract.

## Input reference

Search files by keyword. The scope of the search is controlled by the request body: - Provide `fileIds` to limit the search to specific files. - Provide `companyId` to limit the search to files associated with a specific company. - Omit both to search across your entire account. `fileIds` and `companyId` are mutually exclusive. Returns up to `limit` files ordered by relevance. Prompts with no strong matches may still return low-relevance results. Each result contains a matched file and a single representative excerpt (a matching passage from that file). Even if a file contains multiple matching passages, it appears exactly once in the response with one excerpt.

| Name                | Type      | Required | Default | Details                                                                                                                                                                            |
| ------------------- | --------- | -------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `payload.prompt`    | `string`  | Yes      | —       | The search query. Returns up to `limit` files ordered by relevance. Prompts with no strong matches may still return low-relevance results. Minimum length: 3. Maximum length: 500. |
| `payload.fileIds`   | `array`   | No       | —       | Limit search to these specific files. Omit for org-wide search. Maximum items: 100.                                                                                                |
| `payload.limit`     | `integer` | No       | `20`    | Maximum number of files to return. Format: `int32`. Minimum: 1. Maximum: 100.                                                                                                      |
| `payload.companyId` | `integer` | No       | —       | Restrict search to files associated with this company. Format: `int64`. Minimum: 1. Maximum: 9007199254740991.                                                                     |

<details>
  <summary>Show raw input schema</summary>

  ### Input JSON Schema

  ```json theme={null}
  {
    "type": "object",
    "description": "Search files by keyword. The scope of the search is controlled by the request body: - Provide `fileIds` to limit the search to specific files. - Provide `companyId` to limit the search to files associated with a specific company. - Omit both to search across your entire account. `fileIds` and `companyId` are mutually exclusive. Returns up to `limit` files ordered by relevance. Prompts with no strong matches may still return low-relevance results. Each result contains a matched file and a single representative excerpt (a matching passage from that file). Even if a file contains multiple matching passages, it appears exactly once in the response with one excerpt.",
    "properties": {
      "prompt": {
        "type": "string",
        "description": "The search query. Returns up to `limit` files ordered by relevance. Prompts with no strong matches may still return low-relevance results.",
        "minLength": 3,
        "maxLength": 500
      },
      "fileIds": {
        "type": "array",
        "description": "Limit search to these specific files. Omit for org-wide search.",
        "maxItems": 100,
        "items": {
          "type": "integer",
          "minimum": 1,
          "maximum": 2147483647,
          "format": "int32"
        }
      },
      "limit": {
        "type": "integer",
        "description": "Maximum number of files to return.",
        "default": 20,
        "minimum": 1,
        "maximum": 100,
        "format": "int32"
      },
      "companyId": {
        "type": "integer",
        "description": "Restrict search to files associated with this company.",
        "minimum": 1,
        "maximum": 9007199254740991,
        "format": "int64"
      }
    },
    "required": [
      "prompt"
    ],
    "additionalProperties": false
  }
  ```
</details>

## Output reference

| Name                            | Type              | Required | Default | Details                                           |
| ------------------------------- | ----------------- | -------- | ------- | ------------------------------------------------- |
| `result.data`                   | `object`          | Yes      | —       | —                                                 |
| `result.data.data`              | `array`           | Yes      | —       | Maximum items: 100.                               |
| `result.data.data[].file`       | `object`          | Yes      | —       | —                                                 |
| `result.data.data[].file.id`    | `integer`         | Yes      | —       | Format: `int32`. Minimum: 1. Maximum: 2147483647. |
| `result.data.data[].file.name`  | `string`          | Yes      | —       | —                                                 |
| `result.data.data[].pageNumber` | `integer \| null` | Yes      | —       | Format: `int32`. Minimum: 1. Maximum: 10000.      |
| `result.data.data[].preview`    | `string`          | Yes      | —       | Maximum length: 2000.                             |
| `result.meta`                   | `object`          | No       | —       | —                                                 |

<details>
  <summary>Show raw output schema</summary>

  ### Output JSON Schema

  ```json theme={null}
  {
    "type": "object",
    "properties": {
      "data": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "maxItems": 100,
            "items": {
              "type": "object",
              "properties": {
                "file": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "integer",
                      "minimum": 1,
                      "maximum": 2147483647,
                      "format": "int32"
                    },
                    "name": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "name"
                  ],
                  "additionalProperties": false
                },
                "pageNumber": {
                  "type": [
                    "integer",
                    "null"
                  ],
                  "minimum": 1,
                  "maximum": 10000,
                  "format": "int32"
                },
                "preview": {
                  "type": "string",
                  "maxLength": 2000
                }
              },
              "required": [
                "file",
                "pageNumber",
                "preview"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "data"
        ],
        "additionalProperties": false
      },
      "meta": {
        "type": "object",
        "additionalProperties": true
      }
    },
    "required": [
      "data"
    ],
    "additionalProperties": false
  }
  ```
</details>

## Deepline cost

* Pricing model: `fixed` (per call).
* Estimated Deepline credits: `0` per pricing unit.
* Provider-native pricing may still exist outside Deepline credit billing.

## Related documentation

* [Affinity provider guide](/docs/providers/affinity/guide)
* [SDK V2 quickstart](/docs/sdk-v2/quickstart)
* [SDK reference](/docs/sdk-v2/sdk-reference)
* [Run tools across a CSV](/docs/sdk-v2/batch-csv)
