# Configure metadata

**Metadata** is data that describes other data. "Meta" here means "an underlying definition or description". Metadata summarizes basic information about your data, which can make finding and working with your data easier.

Every item in a LIBSAFE Go data container has a unique item identifier and, by using this unique identifier, the platform is capable of associating metadata to it.

Metadata can be used for searching (even using complex queries) or to be exported or consumed by other systems. See [Search and Queries](../get-started/search) for more details.

Metadata can be associated to the objects:

* Manually, using the LIBSAFE Go Management Interface (for a single item or in bulk),
* Loaded from a CSV, XML or JSON file,
* Using the LIBSAFE Go API,
* Using the LIBSAFE Go Lambda Functions (you can define code functions that will do rich and advanced extraction and processing to your metadata).

There are some metadata types like the file name, associated events or the container an item is in, that the platform is creating and maintaining for you, while there are metadata types that you can easily add to your objects using multiple methods.

All metadata in LIBSAFE Go is indexed and searchable.

![](https://gblobscdn.gitbook.com/assets%2F-MVFE6MnOK93sACDCxxx%2F-MWmoiIvljLdE3vzv_a6%2F-MWn3vZkeBIXqlesNO15%2Fimage.png?alt=media\&token=1d262a19-0028-4efa-8b61-6eae50666c09)

Metadata fields that you would like to have assigned to your items are called **Descriptors** in LIBSAFE Go.

**Descriptors** are grouped into **Metadata Schemas.** For instance, when two departments with different metadata needs share a single LIBSAFE Go instance, each department can create its own schema. Eg: the Physics lab will have "Experiment ID", "Date" and "Creator" in their "Physics" metadata schema while the Biology department will have "Specimen name" and "Date" as their metadata schema. When the schema is assigned to a data container, they can use their own fields to describe the content they place in it.

Each **Descriptor** has a:

* **Name**: That is shown in the Management Interface and helps users to easily identify them.
* **Description**: That is shown in the Management Interface and helps users to understand context or instructions on how to fill certain descriptors.
* **IECode (Import/export code)**: That is used as a field identifier for the API and Functions, as a _friendly_ name for the Descriptor.
*   **Data type:** is the type of data the field accepts:

    * String,
    * Multi-line string,
    * Date,
    * Linked field (includes a link to another item or to any HTTP external resource)
    * or Value list (enumerated list of possible values).

    ​
* **Category:** Descriptors can be grouped visually in the Management Interface. Category defines this grouping, e.g. create a "Descriptive" category and create "Title " and "Author" inside. Create a "Rights" category and create the "Usage rights description" and "License" inside.

{% hint style="info" %}
Field types are not yet validated when using the API (e.g. introducing a value for a Value list type descriptor that is not in the list of possible values). It is the user's responsibility to use them properly.
{% endhint %}

## Using the web interface <a href="#using-the-web-interface" id="using-the-web-interface"></a>

To create a metadata schema:

1.- Go to **Configuration** and then to **Object metadata**

![](https://gblobscdn.gitbook.com/assets%2F-MVFE6MnOK93sACDCxxx%2F-MWnKWqrvMj2tY0UDtC7%2F-MWnRd6nd43mpy7NHity%2Fimage.png?alt=media\&token=c8fc7e24-ce07-412f-a0a1-50d5364fa465)

1. In the submenu, select **Categories** first and use the Add Category button to create a category. You will need to have at least one for the next step.
2. Go to **Configuration** and then to **Object metadata (**&#x61;gain), but this time select **Metadata** instead.
3. Create a new schema using **Add Schema.** Give it a meaningful name related to the content you are going to use or the type of metadata that it will contain, e.g. "High energy experiments" or "Dublin Core".
4. Select the option **Show Descriptors** for the one you have created.
5. A new button **Add Descriptor** will appear to create your new descriptor. Select it.
6. Fill in the form with the definition for the descriptor (see above for a description of each field in the descriptor):
7. **Name**.
8. **Description.**
9. **IECode (Import/export code)**.
10. **Data type:**
    * String,
    * Multi-line string,
    * Date,
    * Linked field (includes a link to another item or to any HTTP external resource)
    * or Value list (enumerated list of possible values).
11. **Category:** Select the category you created previously.

Select **OK** to save your new descriptor.

1. Continue creating the descriptors you need.

Now, when you create a new container, LIBSAFE Go will ask you what is the declared metadata schema you want to use:

![](https://gblobscdn.gitbook.com/assets%2F-MVFE6MnOK93sACDCxxx%2F-MWnRx32tfnKA80BMw4b%2F-MWnVpni7CfRmbWR_qZz%2Fimage.png?alt=media\&token=aaa7789e-f251-410b-a4c1-bc35e4e00342)

If you add an item to your container, you can right-click it, go to the Metadata tab, and you will find all descriptors you have created:

![](https://gblobscdn.gitbook.com/assets%2F-MVFE6MnOK93sACDCxxx%2F-MWnRx32tfnKA80BMw4b%2F-MWnW9MVV0KirILXRMbV%2Fimage.png?alt=media\&token=b241adc9-7d6a-49b9-ae42-5f1a1f61c983)

​

## Using the API <a href="#using-the-api" id="using-the-api"></a>

{% hint style="info" %}
API examples here are shown just for illustrative purposes. Check the [LIBSAFE Go API documentation](../developers-guide/using-the-api) for additional information and all available methods.
{% endhint %}

To create a metadata schema using the API:

1. Sign in to the LIBSAFE Go Management Interface
2. Obtain your LIBSAFE Go API key selecting your name and then **Access Methods:**

![](https://gblobscdn.gitbook.com/assets%2F-MVFE6MnOK93sACDCxxx%2F-MVaHSX-G_bFFXPQn-Od%2F-MVaJWnwSfyMMFbO42X1%2Fimage.png?alt=media\&token=7047e304-094c-4c46-a50e-102ba2513abe)

1. Use the following method to create the new metadata schema:

```
    curl 
    --request POST \    
    --url "$your_platform_url/api/containers/metadata/schema" \    
    --header 'Content-Type: application/json' \    
    --header "authorization: Bearer $your_platform_api_key" \    
    --data '{      "name": "New metadata schema",      "description": "Schema description"    }'
```

LIBSAFE Go answers you with the identifier of the created schema:

![](https://gblobscdn.gitbook.com/assets%2F-MVFE6MnOK93sACDCxxx%2F-MY1G7YNFGbxURDS3Odp%2F-MY3N07bDRbOL1110vSw%2Fimage.png?alt=media\&token=a5f897b7-b207-4a39-9a26-70dbd9d6512a)

Alternatively, if you already created the schema, it is possible to get a list of them using:

```
curl 
--request GET \      
--url "$your_platform_url/api/containers/metadata/schema" \      
--header 'Content-Type: application/json' \      
--header "authorization: Bearer $your_platform_api_key" \
```

![](https://gblobscdn.gitbook.com/assets%2F-MVFE6MnOK93sACDCxxx%2F-MY1G7YNFGbxURDS3Odp%2F-MY3QUX9FQpadRgVAunW%2Fimage.png?alt=media\&token=a597840a-07e8-4e32-ae96-bba20bd61ad8)

1. Metadata fields are grouped into categories (to group them visually when using the Management Interface). As every metadata field needs to belong to one category, we need to create them in advance using the following method:

```
curl 
--request POST \      
--url "$your_platform_url/api/containers/metadata/category" \      
--header 'Content-Type: application/json' \      
--header "authorization: Bearer $your_platform_api_key" \      
--data '{        "name": "New metadata category",        "collapse": "no"      }'
```

LIBSAFE Go answers with the category id:

![](https://gblobscdn.gitbook.com/assets%2F-MVFE6MnOK93sACDCxxx%2F-MY1G7YNFGbxURDS3Odp%2F-MY3PGRsnvnuNV6_AS8-%2Fimage.png?alt=media\&token=6fb077cf-a9c0-467b-84e0-e407998aa695)

Alternatively, if you already created the category, it is possible to get a list of them using:

```
curl 
--request GET \      
--url "$your_platform_url/api/containers/metadata/category" \      
--header 'Content-Type: application/json' \      
--header "authorization: Bearer $your_platform_api_key" \
```

1. Now, using the schema identifier and the metadata category identifier, you can create the item metadata field:

```
curl 
--request POST \     
--url "$your_platform_url/api/containers/metadata/schema/5/descriptor" \     
--header 'Content-Type: application/json' \     
--header "authorization: Bearer $your_platform_api_key" \     
--data '{"name": "New descriptor", "description": "Additional description for this field","iecode": "new_descriptor","container_metadata_category_id": 4,"data_type": "STRING"}'
```

{% hint style="info" %}
The **data\_type** parameter indicates the type of value the field contains, and possible values for it are:

* **STRING**
* **LONGSTRING** (for a multi-line text box)
* **NUMBER**
* **DATE** (in YYYY-MM-DD format)
* **BOOL** (true or false)
* **LINK\_FIELDS** (a link to other system file)
* **ENUM** (the management interface offers a selection for the possible values for the field. (The API DOES NOT ENFORCE OR VALIDATE THEM).

For using the ENUM, you should include an additional parameter in the query with the possible values using "enum\_values": \[ "Value 1", "Value 2" ]
{% endhint %}

