# Update metadata

{% put /%}
{% path text="/v1-beta/document/updateMetaData" /%}

The metadata can be used to store additional information about the document in the form of key-value pairs. Up to 50 key-value pairs can be added. The key is limited to 50 characters, and the value is limited to 500 characters. The stored metadata will be included in the webhooks and document properties API to be retrieved later.

## Code snippet

{% codetab %}

cURL

```shell
curl --location --request PUT 'https://api.boldsign.com/v1-beta/document/updateMetaData?documentId=2f8b6aa7-xxxx-xxxx-xxxx-74edab513999' \
--header 'accept: */*' \
--header 'X-API-KEY: {apikey}' \
--header 'Content-Type: application/json' \
--data '{
    "MetaData": {
        "DocumentType": "new",
        "DocumentCategory": "software"
    }
}'
```

C#

```csharp
var apiClient = new ApiClient("https://api.boldsign.com", "{apikey}");
var documentClient = new DocumentClient(apiClient);

var metaData = new Dictionary<string, string>()
{
    ["DocumentType"] = "new",
    ["DocumentCategory"] = "software",
};

var updateDocumentMetaData = new UpdateDocumentMetaData("2f8b6aa7-xxxx-xxxx-xxxx-74edab513999", metaData);

await documentClient.UpdateDocumentMetaDataAsync(updateDocumentMetaData.DocumentId, updateDocumentMetaData);
```

Python

```python
import requests

url = 'https://api.boldsign.com/v1-beta/document/updateMetaData?documentId=2f8b6aa7-xxxx-xxxx-xxxx-74edab513999'

headers = {
    'accept': '*/*',
    'X-API-KEY': '{apikey}',
    'Content-Type': 'application/json'
}

data = {
    "metaData": {
        "DocumentType": "new",
        "DocumentCategory": "software"
    }
}

response = requests.put(url, headers=headers, json=data)
```

NodeJS

```js
const axios = require("axios");

const url =
  "https://api.boldsign.com/v1-beta/document/updateMetaData?documentId=2f8b6aa7-xxxx-xxxx-xxxx-74edab513999";

const headers = {
  accept: "*/*",
  "X-API-KEY": "{apikey}",
  "Content-Type": "application/json",
};

const data = {
  metaData: {
    DocumentType: "new",
    DocumentCategory: "software",
  },
};

axios
  .put(url, data, { headers: headers })
  .then((response) => {
    console.log(response);
  })
  .catch((error) => {
    console.error(error);
  });
```

PHP

```php
<?php

require 'vendor/autoload.php';

use GuzzleHttp\Client;

$client = new Client();

$url = 'https://api.boldsign.com/v1-beta/document/updateMetaData?documentId=2f8b6aa7-xxxx-xxxx-xxxx-74edab513999';

$headers = [
    'accept' => '*/*',
    'X-API-KEY' => '{apikey}',
    'Content-Type' => 'application/json'
];

$data = [
    'metaData' => [
        'DocumentType' => 'new',
        'DocumentCategory' => 'software'
    ]
];

$response = $client->request('PUT', $url, [
    'headers' => $headers,
    'json' => $data
]);
```

{% /codetab %}

## Request parameters

{% nestedtable %}

- {% arguments name="documentId" /%}{% batch datatype="string" /%}{% required /%}
- The document whose metadata needs to be updated with the help of Document ID.

{% /nestedtable %}

## Request body

{% nestedtable %}

- {% arguments name="MetaData" /%}{% batch datatype="dictionary" /%}{% required /%}
- Additional information about the document in the form of key-value pairs. Up to 50 key-value pairs can be added. The key is limited to 50 characters, and the value is limited to 500 characters.

---

- {% arguments name="OnBehalfOf" /%}{% batch datatype="string" /%}
- Email address of the sender if you are updating metadata of the on behalf of documents.

{% /nestedtable %}

## Partial update

The metadata update always performs a partial update. If the metadata already exists, it will be updated with the new value. If the metadata does not exist, it will be added to the document. If any of the existing metadata is not passed in the request, the existing key-value pairs will not be affected.

## Deleting metadata

The metadata can be deleted by passing an empty string as the value for the key. The key-value pair will be removed from the metadata.

