---
sourceType: api-reference
sourceTypeMatchedRule: openApis
slug: MA/openApis/partner/kyb/uploadDocumentFile
title: Tải lên tệp giấy tờ
---
Được sử dụng để tải lên tệp giấy tờ và lấy fileId. Đây là bước 1 trong quy trình tải lên giấy tờ doanh nghiệp (two-phase process).

### Parameters

| Property      | Type    | Required | Description                                                               |
| ------------- | ------- | -------- | ------------------------------------------------------------------------- |
| miniAppId     | Long    | true     | ID của Mini App                                                           |
| file          | File    | true     | Tệp giấy tờ cần tải lên                                                   |
| fileName      | String  | true     | Tên tệp (SDK Node.js yêu cầu, server sử dụng để hiển thị/fileName trả về) |
| documentType  | String  | false    | Tên loại giấy tờ (legacy, tương ứng với `documentTypeId` nếu có)          |
| subCategoryId | Integer | false    | ID danh mục con liên quan tới giấy tờ                                     |

:::info Định dạng và kích thước tệp

- **Kích thước tối đa**: 5 MB
- **Định dạng được hỗ trợ**: pdf, png, jpg, jpeg
  :::

### Return Values

| Property | Type   | Description                                              |
| -------- | ------ | -------------------------------------------------------- |
| error    | int    | Mã lỗi của kết quả trả về, bằng 0 nếu request thành công |
| message  | String | Lời nhắn chi tiết tương ứng với mã lỗi                   |
| data     | Object | Thông tin tệp đã tải lên                                 |

#### Data Object

| Property | Type   | Description                             |
| -------- | ------ | --------------------------------------- |
| fileId   | String | ID của tệp đã tải lên (dùng cho bước 2) |
| fileName | String | Tên của tệp đã tải lên                  |

#### Sample Code


### Code sample — Java

```js
import java.io.File;

import com.vng.zalo.miniapp.openapi.sdk.models.documents.request.UploadDocumentFileRequest;
import com.vng.zalo.miniapp.openapi.sdk.models.documents.response.UploadDocumentFileResponse;

File testFile = new File("/path/to/your/document.pdf");

UploadDocumentFileRequest request = new UploadDocumentFileRequest();
request.setMiniAppId(YOUR_MINI_APP_ID);
request.setFile(testFile);

UploadDocumentFileResponse response = client.uploadDocumentFile(request);

// Lấy fileId để sử dụng trong bước tiếp theo
String fileId = response.getData().getFileId();
String fileName = response.getData().getFileName();
```

### Code sample — Node.js

```js
import fs from "fs";

const file = fs.readFileSync("/path/to/your/document.pdf");

const { error, message, fileId, fileName } = await client.uploadDocumentFile({
  miniAppId: YOUR_MINI_APP_ID,
  file,
  fileName: "document.pdf",
  // optional metadata
  documentType: "BUSINESS_LICENSE",
  subCategoryId: 1109,
});
```
