Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Nhãn là siêu dữ liệu mà bạn xác định để giúp người dùng sắp xếp, tìm và áp dụng chính sách cho các tệp trong Google Drive. Drive Labels API là một API RESTful hỗ trợ các quy trình kinh doanh bằng cách đính kèm siêu dữ liệu vào các tệp trên Drive. Các trường hợp sử dụng phổ biến cho API này là:
Phân loại nội dung để tuân theo chiến lược quản trị thông tin – Tạo nhãn để xác định nội dung hoặc dữ liệu nhạy cảm cần được xử lý đặc biệt.
Ví dụ: bạn có thể tạo một nhãn có huy hiệu (nhãn có các giá trị lựa chọn được mã hoá bằng màu) có tiêu đề "Độ nhạy cảm" với các giá trị "Tuyệt mật", "Bí mật" và "Công khai".
Áp dụng chính sách cho các mục trong Drive – Tạo nhãn để quản lý nội dung trên Drive trong suốt vòng đời của nội dung đó và đảm bảo nội dung tuân thủ các phương pháp lưu giữ hồ sơ của tổ chức bạn. Ví dụ: sử dụng nhãn để quản lý chính sách ngăn chặn mất dữ liệu (DLP), theo đó, bạn không thể tải các tệp có nhãn "Mức độ nhạy cảm" được đặt thành "Tuyệt mật" xuống máy tính.
Sắp xếp và tìm tệp – Tạo nhãn để tăng khả năng tìm kiếm nội dung của công ty bằng cách cho phép mọi người trong tổ chức tìm các mục dựa trên nhãn và trường của nhãn. Ví dụ: một người trong tổ chức của bạn có thể sử dụng các lựa chọn tìm kiếm trên Drive để tìm tất cả hợp đồng đang chờ chữ ký trước một ngày cụ thể.
Dưới đây là danh sách các thuật ngữ thường dùng trong Drive Labels API:
Siêu dữ liệu có cấu trúc được đặt trên một tệp trên Drive.
Người dùng Drive có thể chỉ định nhãn và đặt giá trị trường nhãn cho tệp. Nhãn bao gồm:
Tên nhãn
Tên tài nguyên của nhãn. Mã nhận dạng nhãn là một phần của tên nhãn. Tuỳ thuộc vào yêu cầu, tên sẽ có dạng như sau: labels/{id} hoặc labels/{id}@{revisionId}. Để biết thêm thông tin, hãy xem phần Sửa đổi nhãn bên dưới.
Mã nhận dạng nhãn
Giá trị nhận dạng duy nhất trên toàn cầu cho nhãn. Mã nhận dạng này là một phần của tên nhãn, nhưng không giống như tên, mã nhận dạng này nhất quán giữa các bản sửa đổi.
Có 2 kiểu nhãn:
Nhãn có huy hiệu
Một nhãn có loại trường SelectionOptions chứa các lựa chọn có thể được mã hoá bằng màu để cho biết mức độ quan trọng. Bạn có thể thực hiện việc này bằng cách đặt badgeConfig thông qua Properties của Choice.
Drive hiển thị màu của lựa chọn đã chọn cho từng tệp để người dùng hiểu rõ trạng thái, mức phân loại, v.v. của tệp.
Ví dụ: lựa chọn "Tuyệt mật" cho nhãn có huy hiệu "Mức độ nhạy cảm" có thể hiển thị bằng màu đỏ. Mỗi lần, bạn chỉ có thể có một nhãn được gắn huy hiệu.
Nhãn tiêu chuẩn
Một nhãn chứa từ 0 loại trường trở lên. Nhãn tiêu chuẩn có thể có tiêu đề nhãn, chẳng hạn như "Dự án Moonshot" và cho biết tất cả các tệp liên quan đến dự án. Nhãn tiêu chuẩn cũng có thể có một số trường có cấu trúc. Ví dụ: nhãn có tiêu đề "Hợp đồng" có thể chứa các trường "Công ty", "Ngày đến hạn", "Trạng thái" và "Bên ký kết". Mỗi trường thuộc một loại cụ thể (văn bản, ngày, lựa chọn hoặc người dùng).
Một thành phần riêng lẻ có thể đặt và nhập của nhãn. Một nhãn có thể không có hoặc có nhiều trường được liên kết với nhãn đó.
Loại trường
Loại dữ liệu của giá trị được liên kết với trường. Có thể định cấu hình dưới dạng văn bản, số nguyên, ngày, người dùng hoặc lựa chọn. Nếu định cấu hình trường bằng ListOptions, bạn có thể đặt trường người dùng và trường lựa chọn bằng nhiều giá trị. Loại được chọn sẽ ảnh hưởng đến cả các giá trị hợp lệ áp dụng cho các mục trên Drive và các lựa chọn về cụm từ tìm kiếm có sẵn.
Để tạo và chỉnh sửa nhãn do quản trị viên sở hữu, bạn phải là quản trị viên tài khoản có đặc quyền Quản lý nhãn.
Quản trị viên có thể chia sẻ nhãn quản trị với bất kỳ người dùng nào để cấp cho người dùng đó quyền xem và áp dụng nhãn cho các mục trên Drive. Để sửa đổi hoặc đọc giá trị nhãn trên các mục trong Drive, bạn cần có các quyền sau:
Sửa đổi – Để sửa đổi siêu dữ liệu của mục trên Drive liên quan đến một nhãn nhất định, người dùng phải có cấp độ quyền phù hợp:
Mục trên Drive: EDITOR
Nhãn: APPLIER
Đọc – Để đọc hoặc tìm kiếm siêu dữ liệu của mục trên Drive liên quan đến một nhãn nhất định, người dùng phải có cấp quyền phù hợp:
Mục trên Drive: READER
Nhãn: READER
Shared (Dùng chung)
Người dùng không phải là quản trị viên có thể tạo nhãn dùng chung để người khác có thể áp dụng cho các mục trên Drive. Các nhóm có thể tạo và sắp xếp nhãn riêng để sử dụng trong nhóm mà không cần quản trị viên.
Hệ thống phân loại nhãn
Các trường nhãn hiện được định cấu hình mà người dùng có thể áp dụng cho tệp trên Drive. Còn được gọi là giản đồ nhãn.
Ví dụ về hệ thống phân loại nhãn:
Độ nhạy – Đỏ, Cam, Vàng, Xanh lục
Trạng thái – Chưa bắt đầu, Bản nháp, Đang xem xét, Bản cuối cùng
Loại nội dung – Hợp đồng, Tài liệu thiết kế, Bản mô phỏng
Nhãn trải qua một vòng đời, trong đó nhãn được tạo, xuất bản, cập nhật, v.v. Khi một nhãn trải qua vòng đời, bản sửa đổi nhãn của nhãn đó sẽ tăng lên. Để biết thêm thông tin, hãy xem bài viết Vòng đời của nhãn.
Sửa đổi nhãn
Một phiên bản của nhãn. Mỗi khi nhãn được tạo, cập nhật, xuất bản hoặc không dùng nữa, số phiên bản nhãn sẽ tăng lên.
Bản sửa đổi nháp
Số phiên bản của bản nháp hiện tại của nhãn. Bạn có thể thực hiện một số nội dung cập nhật cho nhãn, mỗi lần cập nhật sẽ tăng số phiên bản nháp mà không ảnh hưởng đến phiên bản đã xuất bản. Tính năng nhãn nháp cho phép bạn kiểm tra các nội dung cập nhật nhãn trước khi xuất bản.
Bản sửa đổi đã xuất bản
Số phiên bản sửa đổi của phiên bản nhãn đã xuất bản. Nhãn đã xuất bản là phiên bản nhãn mà người dùng hiện có thể thấy.
[null,null,["Cập nhật lần gần đây nhất: 2025-08-29 UTC."],[],[],null,["# Drive Labels API overview\n\n*Labels* are metadata that you define to help users organize, find, and apply\npolicy to files in Google Drive. The Drive Labels API is a RESTful API that\nsupports business processes by attaching metadata to your Drive\nfiles. Common uses for this API are:\n\n- **Classify content to follow an information governance strategy**---Create a\n label to identify sensitive content or data that requires special handling.\n For example, you might create a badged label (a label with color-coded\n option values) titled \"Sensitivity\" with the values of \"Top Secret,\"\n \"Confidential,\" and \"Public.\"\n\n- **Apply policy to items in Drive**---Create labels to manage\n Drive content throughout its lifecycle and ensure it adheres\n to your organization's record keeping practices. For example, use labels to\n manage a data loss policy (DLP) whereby files with a \"Sensitivity\" label set\n to \"Top Secret\" can't be downloaded to a computer.\n\n- **Curate and find files**---Create labels to increase searchability of your\n company's content by letting people in your organization find items based on\n labels and their fields. For example, someone in your organization could use\n Drive search options to find all contracts awaiting signature\n by a specific date.\n\nBelow is a list of common terms used in the Drive Labels API:\n\n[*Label*](/workspace/drive/labels/reference/rest/v2/labels#resource:-label)\n\n: Structured metadata placed on a Drive file.\n Drive users can assign labels and set label field values for\n files. Labels are composed of:\n\n *Label name*\n : The resource name of the label. The *label ID* makes up part of the\n Label name. Depending on the request, the name is in the form of either:\n `labels/{id}` or `labels/{id}@{revisionId}`. For more information, see\n [Label revision](#revision) below.\n\n *Label ID*\n : A globally unique identifier for the label. The ID makes up part of the\n label name, but unlike the name, it's consistent between revisions.\n\n There are 2 styles of labels:\n\n *Badged label*\n\n : A label with a\n [`SelectionOptions`](/workspace/drive/labels/reference/rest/v2/labels#selectionoptions)\n field type containing *choices* that can be color-coded to indicate\n importance. This is done by setting\n [`badgeConfig`](/workspace/drive/labels/reference/rest/v2/labels#BadgeConfig)\n through the\n [`Properties`](/workspace/drive/labels/reference/rest/v2/labels#properties_1) of a\n [`Choice`](/workspace/drive/labels/reference/rest/v2/labels#choice).\n\n Drive displays the color of the chosen option for each file so users\n clearly understand the status, classification, and so on, of the file.\n For example, the \"Top Secret\" option for the \"Sensitivity\" badged label\n might display in red. You can only have one badged label at a time.\n\n *Standard label*\n\n : A label containing zero or more *field type*s. A standard label might\n have a label title, such as \"Project Moonshot,\" and indicate all files\n related to the project. A standard label might also have several\n structured fields. For example, a label with the title \"Contract\" might\n contain the fields for \"Company,\" \"Due Date,\" \"Status,\" and\n \"Signatories.\" Each field is of a specific type (text, date,\n selection, or user).\n\n|----------------------------|------------------------------|\n| **Figure 1.** Badged label | **Figure 2.** Standard label |\n\n[*Field*](/workspace/drive/labels/reference/rest/v2/labels#field)\n\n: An individual typed, settable component of a label. A label can have zero or\n more fields associated with it.\n\n *Field type*\n : The data type of the value associated with the *field* . Configurable as\n text, integer, date, user, or selection. If you configure the field with\n `ListOptions`, you can set the user and selection fields with multiple\n values. The type chosen impacts both the valid values applicable to\n Drive items and the search query options available.\n\n[*Choice*](/workspace/drive/labels/reference/rest/v2/labels#choice)\n\n: One of several options a user can choose from within a `SelectionOptions`\n field.\n\n[*Label type*](/workspace/drive/labels/reference/rest/v2/labels#labeltype)\n\n: All labels include a `LabelType`. There are 2 types of labels:\n\n *Admin*\n\n : To create and edit admin-owned labels, you must be an account\n administrator with the\n [Manage Labels](https://support.google.com/a/answer/1219251#drive_and_docs)\n privilege.\n\n Admins can share admin labels with any user to grant that user the\n ability to view and apply them to Drive items. Modifying or reading\n label values on Drive items requires the following permissions:\n\n - Modifying---For a user to modify the Drive item metadata related to a\n given label, the user must have the appropriate permission levels:\n\n - Drive item: `EDITOR`\n - Label: `APPLIER`\n - Reading---For a user to read or search for the Drive item metadata\n related to a given label, the user must have the appropriate\n permission levels:\n\n - Drive item: `READER`\n - Label: `READER`\n\n *Shared*\n\n : Non-administrator users can create shared labels that others can apply\n to Drive items. Teams can create and organize their own labels for use\n within the team without requiring an administrator.\n\n | **Note:** Shared labels are only available in a closed beta that isn't currently accepting new customers.\n\n*Label taxonomy*\n\n: The currently configured label fields available to users for application to\n Drive files. Also known as the label schema.\n\n Example label taxonomies:\n\n - Sensitivity---Red, Orange, Yellow, Green\n - Status---Not Started, Draft, In Review, Final\n - Content type---Contract, Design Doc, Mockup\n - Department---Marketing, Finance, Human Resources, Sales\n\n[*Label lifecycle*](/workspace/drive/labels/reference/rest/v2/labels#lifecycle)\n\n: Labels go through a lifecycle where they're created, published, updated, and\n so on. As a label makes it through the lifecycle, its *label revision* is\n incremented. For more information, see [Label lifecycle](/workspace/drive/labels/guides/label-lifecycle).\n\n*Label revision*\n\n: An instance of the label. Anytime a label is created, updated, published, or\n deprecated, the label revision increments.\n\n *Draft revision*\n : The revision number of the current draft instance of the label. You can\n make several updates to a label, each incrementing its draft revision\n number, without affecting the published revision. The ability to have\n draft labels lets you test label updates before publishing.\n\n *Published revision*\n : The revision number of the published version of a label. The published\n label is the instance of the label currently available to users.\n\nRelated topics\n--------------\n\n- To learn about developing with Google Workspace APIs, including handling\n authentication and authorization, refer to [Get started as a\n Google Workspace\n developer](/workspace/guides/getstarted-overview).\n\n- To learn how to configure and run a simple Labels API app, try the\n [Python quickstart](/workspace/drive/labels/quickstart/python)."]]