
# Upload a project file

Use [authentication and write headers](actions.md#write-contract). For a connected Drive without a project folder, [create the folder first](forms.md#save-into-project-files).

## Reserve and upload

POST `files/uploads/reserve` with the `x-operat-write-contract` header and the nested content descriptor below. It takes no `write` envelope; its `operationId` identifies the upload. Use `reservation = reserveResponse`: the entire reserve response object, with `operationId`, `parent`, `name`, `content` and `payload`. There is no nested `reservation` property; do not send only `payload`. Then POST the raw bytes to the `project-file` POST URL returned by `GET /api/v1/resources?kind=action&owner=files/uploads/reserve` (substitute `{projectId}`), with `x-operat-write-contract: <writeContract.value returned by GET /api/v1/actions>` (also required on this non-`/api/v1` byte route), `x-operat-project-file-reservation: encodeURIComponent(JSON.stringify(reservation))`, `Content-Type` and `Content-Length` matching `reservation.content`. Use the response’s entry and `files/list` to confirm the file. [Byte protocols](https://tarvena.pl/api/v1/resources?kind=action&owner=files/uploads/reserve).

```json
{"projectId":"<project-id>","parent":null,"name":"survey.pdf","operationId":"<uuid>","content":{"contentType":"application/pdf","size":12345,"sha256":"<sha256-of-input-bytes>"}}
```

If the response is lost, POST `files/uploads/reconcile` with `{"projectId":"<project-id>","reservation":<original-reservation>}`. A committed receipt identifies the existing file. If indeterminate, resend the same bytes with the original reservation. Keep its identity until the result is known.

There is no replace: reserving a name already in the folder returns `name (2).ext`. To replace a file, first POST `files/trash` with `{"projectId":"<project-id>","entry":"<locator from files/list>","write":{"sessionId":"<uuid>","lane":"project-files","sequence":1}}`, then upload.

[Document assets](documents.md) use a separate byte protocol.
