---
metadata:
  - name: generator
    content: Diplodoc Platform v5.44.0
alternate:
  - https://yandex.ru/dev/disk-api/doc/en/reference/meta-add.md
  - https://yandex.ru/dev/disk-api/doc/ru/reference/meta-add.md
---
> **Documentation Index:** Fetch the complete configuration index at https://yandex.ru/dev/disk-api/doc/en/llms.txt

# Adding resource meta information

You can specify additional custom attributes for any writable file or folder. These attributes will be returned in response to all requests for resource meta information ([list of all files](https://yandex.ru/dev/disk-api/doc/en/reference/all-files.md), [recently uploaded files](https://yandex.ru/dev/disk-api/doc/en/reference/recent-upload.md), and others).


## Request format {#format}

Use the PATCH method to send a request for adding meta information.
```
https://cloud-api.yandex.net/v1/disk/resources/
 ? [path](*popup-path)=<resource path>
 & [[fields](*popup-fields)=<properties to include in the response>]
```

path[*](*popup-a)
: The path to the resource relative to the Yandex Disk root directory. The path to the resource in Trash should be relative to the Trash root directory. <br>
  
  <!-- source: en/_includes/reference/parameters-warehouse/id-format/path-encoding.md -->
  The path in the parameter value should be encoded in URL format.
  <!-- endsource: en/_includes/reference/parameters-warehouse/id-format/path-encoding.md -->


fields
: List of JSON properties to include in the response. Keys not specified in this list are omitted when generating a response. If the parameter isn't specified, the response is returned in full without omitting anything. <br>
Key names should be separated by commas, and embedded keys should be separated by dots. For example: `name,_embedded.items.path`.


\* Required parameter.


#### Request body

Pass the added attributes within the `custom_properties` object in the response body (you can pass any parts of the [Resource](https://yandex.ru/dev/disk-api/doc/en/reference/response-objects.md#resource) object, but everything except for `custom_properties` will be ignored). Attributes can only be of the `name:value` type, so you can't use arrays or parent objects.


{% note alert "Restriction" %}

The length of the `custom_properties` object (the names and values of embedded keys along with syntactic symbols) is limited to 1024 characters.

{% endnote %}


The passed attributes are added to the existing ones. For example, you pass the following object with the `foo` and `bar` attributes:

```json
"custom_properties": {"foo":"1", "bar":"2"}
```

If the `custom_properties` object doesn't exist in the resource meta information, the API simply adds the passed object to it.

If this object already exists (for example, `"custom_properties": {"oof":"3", "bar":"0"}`),  the API updates the keys with the same names and adds the new ones. In the [resource meta information](https://yandex.ru/dev/disk-api/doc/en/reference/meta.md), the object will look like this:

```json
"custom_properties": {"oof": "3", "bar":"0", "foo":"1"}
```

To delete an attribute, pass it with the `null` value. For example:

```json
"custom_properties": {"foo": null}
```


## Response format {#response}

<!-- source: en/_includes/reference/meta/id-response/response-code.md -->
If the request is processed without errors, the API returns the `200 OK` code and meta information about the requested resource within the [Resource](https://yandex.ru/dev/disk-api/doc/en/reference/response-objects.md#resource) object in the response body.
<!-- endsource: en/_includes/reference/meta/id-response/response-code.md -->

<!-- source: en/_includes/reference/response-error.md -->
If the request caused an error, the relevant response code is returned, and the response body contains an [error description](https://yandex.ru/dev/disk-api/doc/en/reference/response-objects.md#error).
<!-- endsource: en/_includes/reference/response-error.md -->


For non-empty folders, the response includes a [ResourceList](https://yandex.ru/dev/disk-api/doc/en/reference/response-objects.md#resourcelist) object (under the `_embedded`name). Each resource in the folder is an element of the `items` array. Regardless of the requested sort, resources in the array are ordered by type: nested folders go first, followed by folder files.

```json
{
  "public_key": "HQsmHLoeyBlJf8Eu1jlmzuU+ZaLkjPkgcvmokRUCIo8=",
  "_embedded": {
    "sort": "",
    "path": "disk:/foo",
    "items": [
      {
        "path": "disk:/foo/bar",
        "type": "dir",
        "name": "bar",
        "modified": "2014-04-22T10:32:49+04:00",
        "created": "2014-04-22T10:32:49+04:00"
      },
      {
        "name": "photo.png",
        "preview": "https://downloader.disk.yandex.ru/preview/...",
        "created": "2014-04-21T14:57:13+04:00",
        "modified": "2014-04-21T14:57:14+04:00",
        "path": "disk:/foo/photo.png",
        "md5": "4334dc6379c8f95ddf11b9508cfea271",
        "type": "file",
        "mime_type": "image/png",
        "size": 34567
      }
    ],
    "limit": 20,
    "offset": 0
  },
  "name": "foo",
  "created": "2014-04-21T14:54:42+04:00",
  "custom_properties": {"foo":"1", "bar":"2"},
  "public_url": "https://yadi.sk/d/AaaBbb1122Ccc",
  "modified": "2014-04-22T10:32:49+04:00",
  "path": "disk:/foo",
  "type": "dir"
}
```

Response elements {#response}

<!-- source: en/_includes/reference/response-objects/id-link/resource-table.md -->


#|
|| **Element** | **Description** ||
||`public_key` | Key of a published resource.

It's included in the response only if the specified file or folder is published.||
||`public_url` | Link to a published resource.

It's included in the response only if the specified file or folder is published.||
||`_embedded` | The resources in the folder (contains the [ResourceList](https://yandex.ru/dev/disk-api/doc/en/reference/response-objects.md#resourcelist) object).

It's included in the response only when the folder meta information is requested.||
||`preview` | Link to a preview image of the file. It's included in the response only for supported image formats.

The preview can only be requested with the OAuth token of a user who has access to the file.||
||`name` | Resource name.||
||`custom_properties` | The object contains all attributes specified by the [Adding resource meta information](https://yandex.ru/dev/disk-api/doc/en/reference/meta-add.md) request. Contains only keys of the `name:value` type (can't contain objects or arrays).||
||`created` | The date and time when the resource was created, in [ISO 8601](http://en.wikipedia.org/wiki/ISO_8601) format.||
||`modified` | The date and time when the resource was modified, in [ISO 8601](http://en.wikipedia.org/wiki/ISO_8601) format.||
||`path` | Full path to the resource on Yandex Disk.

The meta information of the published folder indicates paths relative to the folder. For published files, the key value is always "/".

For a resource in Trash, this attribute may have a unique ID added to it (for example, `trash:/foo_1408546879`). This ID differentiates it from other deleted resources with the same name.||
||`origin_path` | Path to the resource before it was moved to Trash.

Only included in the response to a meta information request related to a resource in Trash.||
||`md5` | MD5 hash of the file.||
||`type` | Resource type:

- "dir" — folder.
- "file" — file.||
   ||`mime_type` | The MIME type of the file.||
   ||`size` | File size.||
   |#
<!-- endsource: en/_includes/reference/response-objects/id-link/resource-table.md -->

<!-- source: en/_includes/reference/response-objects/id-link/resourcelist-table.md -->


#|
|| **Element** | **Description** ||
||`sort` | The field by which the list is sorted.||
||`public_key` | The key of the published folder that contains resources from this list.

It's included in the response only if a [public folder's meta information](https://yandex.ru/dev/disk-api/doc/en/reference/public.md#meta) is requested.||
||`items` | Array of resources ([Resource](https://yandex.ru/dev/disk-api/doc/en/reference/response-objects.md#resource)) located in the folder.

Regardless of the requested sort, resources in the array are ordered by type: nested folders go first, followed by folder files.||
||`limit` | The maximum number of items in the `items` array set in the request.||
||`offset` | The offset from the first resource in the folder to the top of the list.||
||`path` | The path to the folder whose contents are described in the `ResourceList` object.

For a [public folder](https://yandex.ru/dev/disk-api/doc/en/reference/public.md#meta), the attribute value is always "/".||
||`total` | The total number of resources in the folder.||
|#
<!-- endsource: en/_includes/reference/response-objects/id-link/resourcelist-table.md -->

[*popup-path]: The path to the resource relative to the Yandex Disk root directory. The path to the resource in Trash should be relative to the Trash root directory. <br>
  
  
The path in the parameter value should be encoded in URL format.

[*popup-fields]: List of JSON properties to include in the response. Keys not specified in this list are omitted when generating a response. If the parameter isn't specified, the response is returned in full without omitting anything. <br>
Key names should be separated by commas, and embedded keys should be separated by dots. For example: `name,_embedded.items.path`.

[*popup-a]: Required parameter.