# createFile

```graphql
mutation CreateFile($input: CreateFileInput!) {
  createFile(input: $input) {
    id
    path
    success
    error
    versionId
    type
    content
    sizeBytes
    checksum
    updatedAt
  }
}
```

Create a file. Requires project.files.write.

## Arguments

| Name             | Type             | Required | Description                                                                                                                                                                                                                                                              |
| ---------------- | ---------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `input`          | CreateFileInput! | Yes      |                                                                                                                                                                                                                                                                          |
| `input.filePath` | String!          | Yes      | File path to create in main or the selected branch. Atomically fails if the path already exists, including concurrent creation; it does not overwrite.                                                                                                                   |
| `input.content`  | String!          | Yes      |                                                                                                                                                                                                                                                                          |
| `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 CreateFilePayload! in data.createFile. |

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

## Example response

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