---
title: "Finalize a file upload and trigger analysis"
method: POST
path: "/workspaces/{workspaceId}/consultations/{consultationId}/uploaded-files/{fileName}/finalize"
tags: ["uploaded-files"]
---

# Finalize a file upload and trigger analysis

`POST /workspaces/{workspaceId}/consultations/{consultationId}/uploaded-files/{fileName}/finalize`

## Request

- Base URL: `https://vetnio.com/api/v2`
- URL: `https://vetnio.com/api/v2/workspaces/{workspaceId}/consultations/{consultationId}/uploaded-files/{fileName}/finalize`
- Auth: HTTP bearer

Confirms that the bytes were uploaded and starts background content extraction (status becomes `analyzing`). Only call this after the `PUT` to the presigned URL has completed: the API checks that the stored object exists and has exactly `sizeBytes` bytes, and returns `412 PRECONDITION_FAILED` until it does.

Safe to call multiple times: if the file is already `analyzing` or `analyzed`, the call does nothing and still returns `ok: true`. If the file is `failed`, calling it again retries extraction. Extraction runs after the response: Excel, CSV, plain-text and Word files are converted locally; PDFs go through OCR and images are described by an AI model. Poll `GET .../uploaded-files` for the result.

## Path parameters

- `workspaceId` string, required: Opaque identifier of the Vetnio workspace (veterinary clinic) that owns the resource. Scopes every request — callers can only access files under workspaces they are a member of.
- `consultationId` string, required: Identifier of the consultation (a single veterinary visit) the file is attached to. The consultation must belong to the same workspace as the authenticated caller.
- `fileName` string, required: Stable internal identifier for the file — a server-generated UUID returned by `initUpload`. Used in every subsequent endpoint (finalize, download, delete). Not intended for display; use `originalFileName` for that.

## Response `200`

Extraction scheduled (or already in progress / completed).

- OkResponse: Generic success envelope returned by mutations that do not produce a resource body.
  - `ok` boolean, required: Always `true` on success.

## Other responses

- `400`: Invalid input data
- `401`: Authorization not provided
- `403`: Insufficient access
- `500`: Internal server error

---

[API](https://skmtc.dev/vetnio/apis/vetnio-api.md) - [All operations](https://skmtc.dev/vetnio/apis/vetnio-api/llms.txt) - [OpenAPI document](https://skmtc.dev/vetnio/apis/vetnio-api/revisions/d004afd5617d?raw)
