# knowledgeSearch

```graphql
query KnowledgeSearch($projectReference: ID!, $input: KnowledgeSearchInput!) {
  knowledgeSearch(projectReference: $projectReference, input: $input) {
    query
    mode
    data {
      path
      matchedFields
    }
    pageInfo {
      hasNextPage
      hasPreviousPage
      startCursor
      endCursor
    }
    returned
    totalMatches
    shard {
      shardIndex
      shardCount
      totalItems
    }
    limit
  }
}
```

Search knowledge files.

## Arguments

| Name                 | Type                       | Required | Description                                                                                                                                                                                                                                                                                                                                                                                               |
| -------------------- | -------------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `projectReference`   | ID!                        | Yes      | Project whose knowledge is selected. Ordinary callers require project.knowledge.read. A run-bound MCP service credential instead must match the persisted run's project and agent plus its actor or runtime transport binding; its effective sealed authority must grant the invoked tool and a knowledge selector. On project-scoped MCP endpoints, the scoped project supplies this value when omitted. |
| `input`              | KnowledgeSearchInput!      | Yes      |                                                                                                                                                                                                                                                                                                                                                                                                           |
| `input.query`        | String                     |          | Text to match against knowledge file paths and frontmatter, up to 500 characters. Omit query to list knowledge files.                                                                                                                                                                                                                                                                                     |
| `input.cursor`       | String                     |          | The previous page's pageInfo.endCursor.                                                                                                                                                                                                                                                                                                                                                                   |
| `input.lookupTarget` | KnowledgeLookupTargetInput |          | Source to search; omit for the main preview branch.                                                                                                                                                                                                                                                                                                                                                       |
| `input.limit`        | Int                        |          | Files per page, 1 to 12; default 6.                                                                                                                                                                                                                                                                                                                                                                       |
| `input.shardCount`   | Int                        |          | Number of shards, 1 to 8; default 1.                                                                                                                                                                                                                                                                                                                                                                      |
| `input.shardIndex`   | Int                        |          | Shard to read, 0 to shardCount - 1.                                                                                                                                                                                                                                                                                                                                                                       |

## Variables

```json
{
  "projectReference": "string",
  "input": {}
}
```

## Responses

| Status | Description                                         |
| ------ | --------------------------------------------------- |
| 200    | The KnowledgeSearchResult! in data.knowledgeSearch. |

## Call it

```bash
curl -X POST "https://api.veryfront.com/graphql" \
  -H "Authorization: Bearer $VERYFRONT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "query": "query KnowledgeSearch($projectReference: ID!, $input: KnowledgeSearchInput!) {\n  knowledgeSearch(projectReference: $projectReference, input: $input) {\n    query\n    mode\n    data {\n      path\n      matchedFields\n    }\n    pageInfo {\n      hasNextPage\n      hasPreviousPage\n      startCursor\n      endCursor\n    }\n    returned\n    totalMatches\n    shard {\n      shardIndex\n      shardCount\n      totalItems\n    }\n    limit\n  }\n}",
  "variables": {
    "projectReference": "string",
    "input": {}
  }
}'
```

## Example response

```json
{
  "data": {
    "knowledgeSearch": {
      "query": "string",
      "mode": "search",
      "data": [
        {
          "path": "string",
          "matchedFields": [
            "string"
          ]
        }
      ],
      "pageInfo": {
        "hasNextPage": false,
        "hasPreviousPage": false,
        "startCursor": "string",
        "endCursor": "string"
      },
      "returned": 0,
      "totalMatches": 0,
      "shard": {
        "shardIndex": 0,
        "shardCount": 0,
        "totalItems": 0
      },
      "limit": 0
    }
  }
}
```
