> ## Documentation Index
> Fetch the complete documentation index at: https://docs.platform.toloka.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# client.datasets.finalizeUpload()

> Finalize a dataset file upload.

After uploading the file to `uploadUrl`, call this endpoint to begin importing its rows. Returns the upload status to poll. A missing file or an already finalized, failed, or canceled upload returns 400. Exceeding the declared size or 1 GiB limit returns 409 and cancels the upload.

## Signature

Method signature on `client.datasets`:

```ts theme={null}
finalizeUpload(args: {
  uploadId: string;
}): Promise<UploadJob>;
```

## Parameters

**uploadId** `string` *required*

Dataset upload ID with prefix `dfu.`.

## Returns

`Promise<UploadJob>`

A dataset upload and its import status. After finalizing, poll until `status` is `succeeded` or `failed`.

**id** `UploadId` *required*

Dataset upload ID with prefix `dfu.`.

**status** `"pending" | "running" | "succeeded" | "failed"` *required*

Upload state: `pending` before finalization, `running` while rows are imported, `succeeded` when complete, or `failed` after failure or cancellation.

**createdAt** `string` *required*

Time the upload was started, as an ISO 8601 timestamp.

**error** `string | null` *required*

Failure or cancellation message, or null when no error is recorded.

**result** `object` *required*

Progress of the dataset import.

**Fields**

**itemsIngested** `number` *required*

Number of rows imported so far, including rows imported before a partial failure.

## Errors

HTTP errors throw [`PotatoApiError`](https://docs.platform.toloka.ai/docs/sdk/errors). The endpoint documents these error responses:

| Status | Description |
| - | - |
| 404 | Upload not found |
| 409 | Uploaded file exceeds the declared size or the 1 GiB limit |
| 429 | Rate limit exceeded |

HTTP endpoint: [`POST /uploads/{uploadId}/finalize`](https://docs.platform.toloka.ai/docs/api-reference/dataset-uploads/finalize-dataset-upload).

```ts finalizeUpload() theme={null}
import { createClient } from "@toloka-platform/sdk";

const client = createClient({
  baseUrl: "https://platform.toloka.ai",
  apiKey: process.env.TOLOKA_API_KEY!,
});

const upload = await client.datasets.finalizeUpload({
  uploadId: "dfu.019a0000-0000-7000-8000-000000000001"
});
console.log(upload);
```

```json finalizeUpload() theme={null}
{
  "id": "dfu.019a0000-0000-7000-8000-000000000001",
  "status": "pending",
  "createdAt": "2026-01-01T00:00:00Z",
  "error": null,
  "result": {
    "itemsIngested": 0
  }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.