[null,null,["最后更新时间 (UTC):2025-08-29。"],[],[],null,["# Add custom file properties\n\n*Custom file properties* are key-value pairs used to store custom metadata for a\nGoogle Drive file (such as tags), IDs from other data stores, information\nshared between workflow applications, and so on. For example, you can add file\nproperties to all documents generated by the sales department in Q1.\n\nTo add properties visible to all applications, use the `properties` field of the\n[`files`](/workspace/drive/api/reference/rest/v3/files) resource. To add properties\nrestricted to your app, use the `appProperties` field of the `files` resource.\n| **Note:** If you're using the older version of Google Drive API (v2), utilize the [`properties`](/workspace/drive/api/reference/rest/v2/properties) resource to add properties to your app using [`properties.insert`](/workspace/drive/api/reference/rest/v2/properties/insert). For a complete list of differences between versions, see the [Drive API v2 \\&\n| v3 comparison reference](/workspace/drive/api/guides/v2-to-v3-reference).\n\nProperties can also be used in [search\nexpressions](/workspace/drive/api/guides/search-files#custom).\n\nThis is the structure of a typical property that might be used to store a\nDrive file's database ID on the file. \n\n### Drive API v3\n\n \"appProperties\": {\n \"additionalID\": \"\u003cvar translate=\"no\"\u003eID\u003c/var\u003e\",\n }\n\n### Drive API v2\n\n {\n 'key': 'additionalID',\n 'value': '\u003cvar translate=\"no\"\u003eID\u003c/var\u003e',\n 'visibility': 'PRIVATE'\n }\n\nWorking with custom file properties\n-----------------------------------\n\nThe section explains how to perform some custom file property-related tasks that\naffect all applications.\n| **Note:** The Google Drive UI doesn't include a built-in way for you to edit custom properties.\n\n### Add or update custom file properties\n\nTo add or update properties visible to all applications, use the\n[`files.update`](/workspace/drive/api/reference/rest/v3/files/update) method to set the\n`properties` field of the [`files`](/workspace/drive/api/reference/rest/v3/files)\nresource. \n\n PATCH https://www.googleapis.com/drive/v3/files/\u003cvar translate=\"no\"\u003eFILE_ID\u003c/var\u003e\n\n```text\n{\n \"properties\": {\n \"name\": \"wrench\",\n \"mass\": \"1.3kg\",\n \"count\": \"3\"\n }\n}\n```\n\nYou can also add a custom property to a file using the advanced\nDrive service in Google Apps Script. For more information, see\n[Adding custom\nproperties](/apps-script/advanced/drive#adding_custom_properties).\n\n### Get or list custom file properties\n\nTo view properties visible to all applications, use the\n[`files.get`](/workspace/drive/api/reference/rest/v3/files/get) method to retrieve the\ncustom file properties for the file. \n\n GET https://www.googleapis.com/drive/v3/files/\u003cvar translate=\"no\"\u003eFILE_ID\u003c/var\u003e?fields=properties\n\nThe response consists of a `properties` object that contains a collection of\nkey-value pairs. \n\n```text\n{\n \"properties\": {\n \"name\": \"wrench\",\n \"mass\": \"1.3kg\",\n \"count\": \"3\"\n }\n}\n```\n\n### Delete custom file properties\n\nTo delete property values visible to all applications, use the\n[`files.update`](/workspace/drive/api/reference/rest/v3/files/update) method to set the\n`properties` field of the [`files`](/workspace/drive/api/reference/rest/v3/files)\nresource to null. \n\n PATCH https://www.googleapis.com/drive/v3/files/\u003cvar translate=\"no\"\u003eFILE_ID\u003c/var\u003e\n\n```text\n{\n \"name\": null\n}\n```\n\nTo view the change, call the\n[`files.get`](/workspace/drive/api/reference/rest/v3/files/get) method to retrieve the\n`properties` object for the file. \n\n```text\n{\n \"properties\": {\n \"mass\": \"1.3kg\",\n \"count\": \"3\"\n }\n}\n```\n\nLimits of custom file properties\n--------------------------------\n\nCustom properties have the following limits:\n\n- Maximum of 100 custom properties per file, totaled from all sources.\n- Maximum of 30 public properties per file, totaled from all sources.\n- Maximum of 30 private properties per file from any one application.\n- Maximum of 124 bytes per property string (including both key and value) in UTF-8 encoding. For example, a property with a key that's 10 characters long can only have 114 characters in the value. Similarly, a property that requires 100 characters for the value can use up to 24 characters for the key.\n\nFor more information, see the [`files`](/workspace/drive/api/reference/rest/v3/files)\nresource. For Drive API v2, see the\n[`properties`](/workspace/drive/api/v2/reference/properties) resource.\n\nAccess private custom file properties\n-------------------------------------\n\nYou can only retrieve private properties using the `appProperties` field through\nan authenticated request that uses an access token obtained with an OAuth 2.0\nclient ID. You cannot use an API key to retrieve private properties."]]