> For the complete documentation index, see [llms.txt](https://docs.blynk.io/en/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.blynk.io/en/blynk-library-firmware-api/metadata.md).

# Metadata

[Metadata](/en/blynk.console/templates/metadata.md) is a `key:value` set of data applied to every device using the same template. Unlike Datastreams, this data stays mostly unchanged, however, if you need to read/write it, here is how to do it:

### Get device Metadata

The device can request the value of its own metadata from the cloud using the key (name) of Metadata.

{% hint style="info" %}
Double-check that you have a Metadata field with a correct name configured in the Device Template.
{% endhint %}

First, you need to send a request to Blynk.Cloud

```cpp
BLYNK_CONNECTED() {
  // Send requests for different metadata
  Blynk.sendInternal("meta", "get", "Serial Number");
  Blynk.sendInternal("meta", "get", "Device Model");
  
  //"Auth Token" is a reserved metadata name, if you have your own metadata
  //with that name it will override the default implementation
  //which returns device.token field
  //you can't change the value of reserved metadata field, only if you override it
  Blynk.sendInternal("meta", "get", "Auth Token");
}
```

Then, parse the data stored in `InternalPinMETA`, which a system pin to store metadata values.

```cpp
BLYNK_WRITE(InternalPinMETA) {
    String field = param[0].asStr();
    if (field == "Serial Number") {
        String value = param[1].asStr();
        // Do something with Metadata value
    } else if (field == "Device Model") {
        String value = param[1].asStr();
        // Do something with Metadata value
    } else if (field == "Auth Token") {
        String value = param[1].asStr();
        // Do something with Metadata value
    }
}
```

### Write device metadata

The device can update the value of the metadata using the metadata key (name).

For example, if your device stores Serial Number and Device Model internally, you can write these values to corresponding metadata fields.

```cpp
sn_value = "123456789"       //imaginary serial number
model_value = "RX-1-2789"    // imaginary device model name

Blynk.sendInternal("meta", "set", "Serial Number", sn_value);
Blynk.sendInternal("meta", "set", "Device Model", model_value);
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.blynk.io/en/blynk-library-firmware-api/metadata.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
