# Metadata

The metadata for a process allows you to store arbitrary JSON data with that process, e.g. if you have an app that uses the datarhei Core API you can store app-specific information in the metadata.

In order not to conflict with other apps that might write to the metadata as well, you have to provide a key under which your metadata is stored. Think of a namespace or similar.

## Create, Update

Add or update the metadata for a process and key.

Example: Write a metadata object into the metadata for the process `test` and key `desc`.

{% tabs %}
{% tab title="Curl" %}

```bash
curl http://127.0.0.1:8080/api/v3/process/test/metadata/desc \
   -H 'accept: application/json' \
   -H 'Content-Type: application/json' \
   -X POST \
   -d '{
         "title": "My title",
         "description": "My description."
      }'
```

{% endtab %}

{% tab title="PyClient" %}

```python
from core_client import Client

client = Client(
    base_url="http://127.0.0.1:8080"
)
client.login()

client.v3_process_put_metadata(
    id="test",
    key="desc",
    data={
        "title": "My title",
        "description": "My description."
    }
)
```

{% endtab %}

{% tab title="GoClient" %}

```go
import (
    "github.com/datarhei/core-client-go/v16"
)

client, _ := coreclient.New(coreclient.Config{
    Address: "https://127.0.0.1:8080",
})

data := map[string]string{
    "title": "My title",
    "description": "My description.",
}

err := client.ProcessMetadataSet("test", "desc", data)
if err != nil {
    ...
}
```

{% endtab %}
{% endtabs %}

Description:

{% openapi src="/files/AUmcih4nC1IX6QuhfO8m" path="/api/v3/process/{id}/metadata/{key}" method="put" %}
[doc.json](https://951110271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAQRvnKSkK1SsZB0HeYhh%2Fuploads%2F3duUHhkhwH69BGLlHYga%2Fdoc.json?alt=media\&token=dcd2b063-c826-4652-9a98-c265ec41a469)
{% endopenapi %}

## Read

Read out the stored metadata. The key is optional. If the key is not provided, all stored metadata for that process will be in the result.

Example: read the metadata object for process `test` that is stored under the key `desc`.

{% tabs %}
{% tab title="Curl" %}

```bash
curl http://127.0.0.1:8080/api/v3/process/test/metadata/desc \
   -H 'accept: application/json' \
   -X GET
```

{% endtab %}

{% tab title="PyClient" %}

```python
from core_client import Client

client = Client(
    base_url="http://127.0.0.1:8080"
)
client.login()

client.v3_process_get_metadata(
    id="test",
    key="desc"
)
```

{% endtab %}

{% tab title="GoClient" %}

```go
import (
    "fmt"
    "github.com/datarhei/core-client-go/v16"
)

client, _ := coreclient.New(coreclient.Config{
    Address: "https://127.0.0.1:8080",
})

metadata, err := client.ProcessMetadata("test", "desc")
if err != nil {
    ...
}

fmt.Printf("%+v\n", metadata)
```

{% endtab %}
{% endtabs %}

Description:

{% openapi src="/files/AUmcih4nC1IX6QuhfO8m" path="/api/v3/process/{id}/metadata/{key}" method="get" %}
[doc.json](https://951110271-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAQRvnKSkK1SsZB0HeYhh%2Fuploads%2F3duUHhkhwH69BGLlHYga%2Fdoc.json?alt=media\&token=dcd2b063-c826-4652-9a98-c265ec41a469)
{% endopenapi %}


---

# Agent Instructions: 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.datarhei.com/core/api-ffmpeg/process/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.
