# Replace a file's contents

Put new bytes under an existing file and keep its id, so every record it is on, its classification, folder and requests stay as they are. Send name, contentType and sizeBytes as for a new upload; the answer is the same — the file and a signed upload URL (15 minutes) the client PUTs the new bytes to. The bytes it replaced are kept, and until the new ones land in storage a download still serves the old ones. Refused with 409 while a ported file's bytes are still being moved in.

Access class: `workspace`.

## Endpoint

`POST /v1/files/{id}/replace`

## Parameters

| Name | In | Type | Required |
| --- | --- | --- | --- |
| id | path | string | Yes |

## Request body

Content type: `application/json`.

```json
{
  "contentType": "string",
  "documentType": "string",
  "name": "string",
  "periodEnd": "string",
  "periodStart": "string",
  "sizeBytes": 1
}
```

## Responses

### 201

the action's answer

Content type: `application/json`.

```json
{
  "data": {
    "contentType": "string",
    "createdAt": "2026-01-01T00:00:00Z",
    "documentType": "string",
    "folderId": "",
    "id": "",
    "landedAt": "2026-01-01T00:00:00Z",
    "landingFailed": true,
    "links": [
      {
        "definitionKey": "string",
        "id": "",
        "label": "string",
        "rowId": ""
      }
    ],
    "name": "string",
    "no_advertising": true,
    "periodEnd": "string",
    "periodStart": "string",
    "rowId": "",
    "sizeBytes": 1,
    "source": "string",
    "sourceDetail": "string",
    "source_provider": "string",
    "starred": true,
    "statementStatus": "string",
    "submissionUnavailableReason": "string",
    "uploadedBy": 1
  },
  "uploadUrl": "string"
}
```

### default

a refusal: `{"error": "<what a person needs to read>"}`. 401 no credential, 402 the plan does not include this, 403 the seat does not, 404 the thing does not exist or is not yours to see.

Content type: `application/json`.

```json
{
  "error": "string"
}
```
