# updateDraftContent

```graphql
mutation UpdateDraftContent($input: UpdateDraftContentInput!) {
  updateDraftContent(input: $input) {
    entityId
    entityType
    body
    version
  }
}
```

Update draft content. Requires project.files.write.

## Arguments

| Name                         | Type                     | Required | Description                                                                                                                                                                 |
| ---------------------------- | ------------------------ | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `input`                      | UpdateDraftContentInput! | Yes      |                                                                                                                                                                             |
| `input.projectReference`     | String                   |          |                                                                                                                                                                             |
| `input.entityId`             | ID!                      | Yes      | Existing source-file path or UUID whose pending full-body draft is replaced.                                                                                                |
| `input.entityType`           | DraftEntityType!         | Yes      | Must match the existing source-file type. One of `page`, `component`, `function`, `virtual_file`.                                                                           |
| `input.branchId`             | ID                       |          |                                                                                                                                                                             |
| `input.body`                 | String!                  | Yes      | Empty bodies are valid. Saves a durable draft and repairs Yjs state without creating an immutable version.                                                                  |
| `input.branchReference`      | String                   |          | Branch name or UUID; equivalent branchId aliases are accepted, conflicting ones rejected. Omit/null for main.                                                               |
| `input.expectedDraftVersion` | Int                      |          | Expected current draft sequence (0 means no prior draft), not a committed-file version ID. Omit/null for unconditional replacement; stale values are concurrency errors409. |

## Variables

```json
{
  "input": {
    "entityId": "string",
    "entityType": "page",
    "body": "string"
  }
}
```

## Responses

| Status | Description                                                |
| ------ | ---------------------------------------------------------- |
| 200    | The UpdateDraftContentPayload! in data.updateDraftContent. |

## 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 UpdateDraftContent($input: UpdateDraftContentInput!) {\n  updateDraftContent(input: $input) {\n    entityId\n    entityType\n    body\n    version\n  }\n}",
  "variables": {
    "input": {
      "entityId": "string",
      "entityType": "page",
      "body": "string"
    }
  }
}'
```

## Example response

```json
{
  "data": {
    "updateDraftContent": {
      "entityId": "string",
      "entityType": "page",
      "body": "string",
      "version": 0
    }
  }
}
```
