# upsertFileChunks

```graphql
mutation UpsertFileChunks($input: UpsertFileChunksInput!) {
  upsertFileChunks(input: $input) {
    chunks {
      id
      index
      content
    }
    created
    updated
    deleted
  }
}
```

Upsert file chunks. Requires project.knowledge.write.

## Arguments

| Name                  | Type                   | Required | Description                                                                                       |
| --------------------- | ---------------------- | -------- | ------------------------------------------------------------------------------------------------- |
| `input`               | UpsertFileChunksInput! | Yes      |                                                                                                   |
| `input.fileVersionId` | ID!                    | Yes      | Selected project file-version UUID. Mutation requires exclusive branch ownership of that version. |
| `input.chunks`        | \[FileChunkInput!]!    | Yes      | Replacement chunk set, at most 500 entries. An empty array removes the existing chunks.           |

## Variables

```json
{
  "input": {
    "fileVersionId": "string",
    "chunks": [
      {
        "chunkIndex": 0,
        "content": "string",
        "startOffset": 0,
        "endOffset": 0,
        "tokenCount": 0
      }
    ]
  }
}
```

## Responses

| Status | Description                                            |
| ------ | ------------------------------------------------------ |
| 200    | The UpsertFileChunksPayload! in data.upsertFileChunks. |

## Call it

```bash
curl -X POST "https://api.veryfront.com/graphql" \
  -H "Authorization: Bearer $VERYFRONT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "query": "mutation UpsertFileChunks($input: UpsertFileChunksInput!) {\n  upsertFileChunks(input: $input) {\n    chunks {\n      id\n      index\n      content\n    }\n    created\n    updated\n    deleted\n  }\n}",
  "variables": {
    "input": {
      "fileVersionId": "string",
      "chunks": [
        {
          "chunkIndex": 0,
          "content": "string",
          "startOffset": 0,
          "endOffset": 0,
          "tokenCount": 0
        }
      ]
    }
  }
}'
```

## Example response

```json
{
  "data": {
    "upsertFileChunks": {
      "chunks": [
        {
          "id": "string",
          "index": 0,
          "content": "string"
        }
      ],
      "created": 0,
      "updated": 0,
      "deleted": 0
    }
  }
}
```
