# updateFile

```graphql
mutation UpdateFile($input: UpdateFileInput!) {
  updateFile(input: $input) {
    path
    success
    error
    id
    versionId
    type
    content
    sizeBytes
    checksum
    updatedAt
  }
}
```

Update a file. Requires project.files.write.

## Arguments

| Name                      | Type             | Required | Description                                                                                                                                                                                                                                                              |
| ------------------------- | ---------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `input`                   | UpdateFileInput! | Yes      |                                                                                                                                                                                                                                                                          |
| `input.filePath`          | String!          | Yes      |                                                                                                                                                                                                                                                                          |
| `input.content`           | String!          | Yes      | Replacement textual content in main or the selected branch, stored as a new immutable version. Source-file MIME type is not writable.                                                                                                                                    |
| `input.expectedChecksum`  | String           |          | Expected current content checksum. Null or omission disables this guard.                                                                                                                                                                                                 |
| `input.expectedVersionId` | String           |          | Expected current version ID. Null or omission disables this guard.                                                                                                                                                                                                       |
| `input.ref`               | String           |          | Canonical content selector: main, branch:<name-or-id>, release:<version> or env:<name>. An unresolvable reference is rejected; it never falls back to main. A release or environment is read-only, so a write addressed to one is refused rather than applied elsewhere. |
| `input.branchId`          | String           |          | Legacy alias for ref=branch:<value>. Supplying both is accepted when they name the same content and rejected when they do not.                                                                                                                                           |

## Variables

```json
{
  "input": {
    "filePath": "string",
    "content": "string"
  }
}
```

## Responses

| Status | Description                                |
| ------ | ------------------------------------------ |
| 200    | The UpdateFilePayload! in data.updateFile. |

## 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 UpdateFile($input: UpdateFileInput!) {\n  updateFile(input: $input) {\n    path\n    success\n    error\n    id\n    versionId\n    type\n    content\n    sizeBytes\n    checksum\n    updatedAt\n  }\n}",
  "variables": {
    "input": {
      "filePath": "string",
      "content": "string"
    }
  }
}'
```

## Example response

```json
{
  "data": {
    "updateFile": {
      "path": "string",
      "success": false,
      "error": "string",
      "id": "string",
      "versionId": "string",
      "type": "string",
      "content": "string",
      "sizeBytes": 0,
      "checksum": "string",
      "updatedAt": "2026-01-01T00:00:00Z"
    }
  }
}
```
