# Replace a file

Source: https://docs.wabe.sh/api-reference/operations/writefile/

`PUT https://api.wabe.sh/v1/disks/{disk}/files/{path}`

## Request example

```sh
curl --fail-with-body -X PUT 'https://api.wabe.sh/v1/disks/demo/files/notes.txt' \
  -H 'Authorization: Bearer YOUR_PROJECT_API_KEY' \
  -H 'Content-Type: application/octet-stream' \
  --data-binary @./notes.txt
```

## Authorization

Project API key from the Wabe Dashboard or actor runtime access token for the disk URL supplied by the broker.

## Parameters

- `disk` (path, string, required) — Project disk name, or the disk ID in the actor runtime disk URL.

- `path` (path, string, required)

- `branch` (query, string)

- `commit` (query, string)

- `label` (query, string)

- `expected_id` (query, string)

- `expected_revision` (query, integer)

## Request body

`application/octet-stream`

Schema

```json
{
  "type": "string",
  "format": "binary"
}
```

## Responses

### 200

Complete replacement published according to configured durability.

`application/json`

Schema

```json
{
  "type": "object",
  "properties": {
    "bytes": {
      "type": "integer",
      "minimum": 0
    },
    "metadata": {
      "type": "object",
      "properties": {
        "version": {
          "const": 2
        },
        "kind": {
          "oneOf": [
            {
              "const": "Directory"
            },
            {
              "type": "object",
              "properties": {
                "File": {
                  "type": "object",
                  "properties": {
                    "size": {
                      "type": "integer",
                      "minimum": 0
                    },
                    "chunk_bytes": {
                      "type": "integer",
                      "minimum": 4096,
                      "maximum": 4194304
                    },
                    "content_root": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "pattern": "^[0-9a-f]{64}$"
                    }
                  },
                  "required": [
                    "content_root",
                    "size",
                    "chunk_bytes"
                  ],
                  "additionalProperties": false
                }
              },
              "required": [
                "File"
              ],
              "additionalProperties": false
            }
          ]
        },
        "object_id": {
          "type": "string",
          "format": "uuid"
        },
        "version_id": {
          "type": "string",
          "format": "uuid"
        },
        "branch_id": {
          "type": "string",
          "format": "uuid",
          "description": "Origin of the version; inherited or imported versions may refer to an internal or deleted branch absent from the branch list."
        },
        "revision": {
          "type": "integer",
          "minimum": 0
        },
        "first_edit_at_ms": {
          "type": "integer",
          "minimum": 0
        },
        "last_edit_at_ms": {
          "type": "integer",
          "minimum": 0
        },
        "mode": {
          "type": "integer",
          "enum": [
            16384,
            33188,
            33261,
            40960
          ]
        }
      },
      "required": [
        "version",
        "kind",
        "object_id",
        "version_id",
        "branch_id",
        "revision",
        "first_edit_at_ms",
        "last_edit_at_ms",
        "mode"
      ],
      "additionalProperties": false
    }
  },
  "required": [
    "bytes",
    "metadata"
  ],
  "additionalProperties": false
}
```

### 400

Invalid input.

`text/plain`

Schema

```json
{
  "type": "string"
}
```

### 401

Missing, invalid or revoked project API key, or an invalid runtime access token.

`application/json`

Schema

```json
{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "error",
    "message"
  ]
}
```

### 403

Actor runtime token does not authorize this disk or instance generation.

`application/json`

Schema

```json
{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "error",
    "message"
  ]
}
```

### 404

Object was not found.

`text/plain`

Schema

```json
{
  "type": "string"
}
```

### 409

Conflict, nonempty destination or referenced object.

`text/plain`

Schema

```json
{
  "type": "string"
}
```

### 500

Storage, I/O or corruption failure.

`text/plain`

Schema

```json
{
  "type": "string"
}
```

### 503

Disk unavailable.

`application/json`

Schema

```json
{
  "type": "object",
  "properties": {
    "error": {
      "type": "string"
    },
    "message": {
      "type": "string"
    }
  },
  "required": [
    "error",
    "message"
  ]
}
```
