> ## 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 stored in Affinity by keyword, optionally limited to one company or specific files. Includes inputs, outputs, SDK V2 examples, and Deepline cost.

Search files stored in Affinity by keyword, optionally limited to one company or specific files.

> [!NOTE]
>
> Tool ID: `affinity_v2_files_search_post`

## Run this action

Use the TypeScript SDK for one call. Use `ctx.tools.execute(...)` inside a Play for durable calls, scheduled calls, or CSV processing.

```ts theme={"languages":{"custom":["/languages/deepline-prompt.json"]}}
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={"languages":{"custom":["/languages/deepline-prompt.json"]}}
deepline tools execute affinity_v2_files_search_post --input '{
  "prompt": "example"
}' --json
```

## Example response

The SDK returns this shape at `result.toolResponse.raw`. The example values illustrate the response.

```json theme={"languages":{"custom":["/languages/deepline-prompt.json"]}}
{
  "data": {
    "data": [
      {
        "file": {
          "id": 123,
          "name": "Example"
        },
        "pageNumber": 1,
        "preview": "example"
      }
    ]
  }
}
```

Use `deepline describe 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={"languages":{"custom":["/languages/deepline-prompt.json"]}}
  {
    "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={"languages":{"custom":["/languages/deepline-prompt.json"]}}
  {
    "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](https://deepline.com/docs/providers/affinity/guide.md)
* [SDK V2 quickstart](https://deepline.com/docs/sdk-v2/quickstart.md)
* [SDK reference](https://deepline.com/docs/sdk-v2/sdk-reference.md)
* [Run tools across a CSV](https://deepline.com/docs/sdk-v2/batch-csv.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.