# Work with data containers

Every object in **Flexible Intake** is preserved in a Data Container. Data containers define the [policies](/libsafe-flexible-intake/get-started/work-with-data-containers.md), [functions](/libsafe-flexible-intake/get-started/work-with-data-containers.md), [permissions ](/libsafe-flexible-intake/get-started/work-with-data-containers.md)and the underlying [storage policy](/libsafe-flexible-intake/get-started/work-with-data-containers.md) for the files they contain, and have many similarities with Amazon S3 buckets or Azure containers, as they can hold files, folders, metadata, etc.

{% hint style="info" %}
To know more about how you can organize your content, see [Organize your content](/libsafe-flexible-intake/concepts/organize-your-content.md).
{% endhint %}

{% hint style="info" %}
Data containers can be arranged in a hierarchical structure (Archival Structure) that is comprised of a series of nodes and sub-nodes. Learn how to configure it in the [Archive organization](/libsafe-flexible-intake/configuration/archive-organization.md) section.
{% endhint %}

It is possible to create, edit or delete data containers using the platform's Management Interface or using the API. It is also possible to share some content or a whole container publicly, so users without platform's credentials can access it.

## Working with Management Interface

### Create a data container

1. Sign in to the platform's Management Interface
2. Select **Containers** and *\*\**

**3.** Select **New Container:**

![](/files/-MgzL-1YsumOMwLxHjv5)

1. In the **Container name**, enter a descriptive name for the content you plan to have in your container (like "Albert Einstein's Correspondence"). This name allows you and other users to easily locate the container when using the platform's Management Interface.

You can leave any other field as default and select **Create.** The platform will now open the data container details page. If you plan to work with your data container using any of the file transfer methods the platform supports or with the API, it is important that you remember the data container identifier that is shown next to the container name.

![](/files/-MgzL-1ZEPNy7FSqnjqo)

### Edit or change a data container

1. Sign in to the platform's Management Interface
2. Select **Containers**

![](/files/-MgzL-1_-M-N_l21hL4x)

1. Select **Containers by Archive Structure** and select the one you want to edit.
2. In the Data container view, select **Edit Container**

![](/files/-MgzL-1adRE_Pc_N8F5V)

1. Change the options as desired and select **Save.**

### Delete a data container

Two distinct deletion processes exist in the platform:

* **Soft-delete:** The platform marks all content and metadata as deleted and hides them in the interface and search results. Users with permissions to see deleted containers are still able to see them, and they can be reverted (undeleted) easily. The storage continues in use as the content is still there, but hidden.
* **Hard-delete:** Once a data container has been soft-deleted, it is possible to hard-delete it for the users with the hard-delete permission. Content, metadata and related events are finally deleted from the platform.&#x20;

{% hint style="danger" %}
It is impossible to recover a hard-deleted container. **Hard-deleted data is lost forever.**
{% endhint %}

1. Sign in to the platform's Management Interface
2. Select **Containers**

![](/files/-MgzL-1blReHFqtm1xmY)

1. Select **Containers by Archive Structure** and select the one you want to delete.
2. In the Data container view, select **Edit Container**

![](/files/-MgzL-1c0WwlWsyzuN3h)

1. And select the Delete option.&#x20;

![](/files/-MgzL-1dyQMTw-1u6v3z)

1. Now the container is **soft-deleted** and hidden from users and search. If the user/group has the **View deleted containers** permission, in the Containers by archive structure view, a button is available (**View deleted containers** button), that only shows the deleted ones.
2. If you want fo permanently delete one, open the container, select **Details** and select **Permanently delete.**
3. If you want to revert the soft-delete action and make the container accesible again, select **Restore**.

### Sharing: Making content externally accesible

The platform's permissions allow for providing or restricting access to platform's users, but the content can also be shared to any external user publicly, without needing authentication or a platform account.

This can be achieved for some items in the container (files or folders) or for the whole container.

{% hint style="info" %}
When you share a container this way, your content is publicly available to any internet user.
{% endhint %}

{% hint style="warning" %}
When you share a folder, every item and subitem contained in the folder is also shared. Future items you place in the folder (in any subfolder) are also shared.
{% endhint %}

Proceed as follows:

1. Sign in to the platform's Management Interface
2. Select **Containers**

![](/files/-MgzL-1eFwNOf3Dj3kWf)

1. Select **Containers by Archive Structure** and select the one you want to share
2. Go to the **Explore content** tab and select any item or items you want to share. Selecting multiple elements is possible, and any item inside a folder you select will also be publicly shared

![](/files/-MgzL-1fEGHNrNxWzKrN)

{% hint style="warning" %}
Remember that if you share a folder, all EXISTING and **FUTURE** items (files and folders) inside it are also shared.
{% endhint %}

1. The option **Share selected content** appears in the **Functions** area. Select it.

![](/files/-MgzL-1ggiwI1uM7GLRp)

1. Select the sharing method you would like to use, select the **Share** option and select **OK**.&#x20;

![](/files/-MgzL-1h0df_Zyoit2mc)

1. In the **Shared column** you can see if a file is shared or not, and you can always select files and un-share them in the same way.

{% hint style="info" %}
This interface is showing direct shares only. Even if the content you have selected is inside a shared folder (thus indirectly shared), the platform will show that the items are not shared in the Shared column.
{% endhint %}

1. The Shared tab in the data container allows you to see what is shared in the container:

![](/files/-MgzL-1iXObKG1KlD05P)

1. When a folder or item has been shared, you can get the HTTP URL by looking at the sidebar when in the data container Explore tab:

![](/files/-MgzL-1jouPUc90p7T8u)

If you open the preceding link of a shared **folder** (even if the user opening it has not authenticated in LIBSAFE), a **read-only** interface is shown to the user:

![](/files/-MgzL-1kIE738hpXnhON)

Anonymous users **can:**

* Open the files to preview using the advanced file viewer (including any subfolder and its files or folders),&#x20;
* Download them individually,
* Group them in a ZIP file to download all of them at once (select multiple files, right click and download) and
* Perform file name searching and filtering.

But they **cannot:**

* Change **files or folders**,
* Remove them in any way or &#x20;
* See or change your metadata, with the exception of the file size, file type and last modification date.

{% hint style="info" %}
When you share a folder, any item in the folder is accesible using the name/path in the container.‌
{% endhint %}

## Working with the API

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

### Create a data container

1. Sign in to the platform's Management Interface
2. Obtain your API key by selecting your name and then **Access Methods:**

![](/files/-MgzKyIsJbx7-YRS0fv9)

1. Use this method:

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

```
curl --request POST \
  --url "$your_platform_url/api/container" \
  --header "Authorization: Bearer $your_platform_api_key" \
  --form "name=My Container" \
  --form "description=Some fancy description" \
  --form container_metadata_id=1 \
  --form metadata_schema_id=1 \
  --form workflow_id=1 \
  --form archival_structure_id=1 \
  --form storage_id=1
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
Use:

* **url**: Your platform address
* **header**: Your API Token (add Bearer prefix)
* **name**: The name of the container that will be created
* **description**: A short description (optional)
* **container Metadata ID**: The ID of the metadata schema to use for the container's metadata
* **metadata Schema ID**: The ID of the metadata schema to use for the container's files/objects
* **workflow ID**: The ID of the workflow that you would like to associate with this container
* **archival Structure ID**: The ID of the archival node to which you would like to add this container
* **storage ID**: The ID of the storage that this container will use.
  {% endhint %}

If you plan to work with your data container using any of the file transfer methods that the platform supports, or with the API, it is important that you remember the data container identifier that is delivered in the response:

```javascript
{
  "success": true,
  "result": {
    "id": "6321", //<-- this will be your container's ID
    "parent": null,
    "name": "My Container",
    "description": "Some fancy description",
    "creator": "1",
    "checked_in_user": null,
    "date_create": "2021-03-01 09:42:10.123456",
    "date_update": "2021-03-01 09:42:00",
    "file_total": "0",
    "size_total": "0",
    "archived": "0",
    "storage_id": "1",
    "container_metadata_id": "1",
    "metadata_schema_id": "1",
    "workflow_id": "1",
    "workflow_step_id": "1",
    "archival_structure_id": "1",
    "submission_area_id": null,
    "permission_source": "INHERIT"
  }
}
```

### Edit or change a data container

1. Sign in to the platform's Management Interface
2. Obtain your API key by selecting your name and then **Access Methods:**

![](/files/-MgzL-1ldvQrwSMmvnvg)

1. If you want to edit the container name or description, use this method:

```javascript
curl --request PUT \
  --url "http://$your_platform_url/api/container/<container id>" \
  --header "authorization: Bearer $your_platform_api_key" \
  --header "content-type: application/json" \
  --data '{
    "name": "Container name",
    "description": "My container description"
}'
```

1. If you want to edit the **container metadata**, you can use this method:

```javascript
    curl --request PUT \
    --url "$your_platform_url/api/container/6255/metadata" \
    --header "Content-Type: application/json" \
    --header "authorization: Bearer $your_platform_api_key" \
    --data '{
        "metadata": [
            {
                "iecode": "donor_city",
                "value": "Tokyo"
            }
        ]
    }'
```

{% hint style="info" %}
Use:

* **url**: Your platform address
* **header**: Your API Token (add Bearer prefix)
* **iecode**: The Import/Export code for the metadata descriptor you want to edit
* **value**: The value you want to set.

Multi-evaluated fields are not available for containers. Containers can only have string-type fields.
{% endhint %}

### Delete a data container

1. Sign in to the platform's Management Interface
2. Obtain your API key by selecting your name and then **Access Methods:**

![](/files/-MgzL-1m-d_wBbUvHJK-)

1. Understand the deletion method to use: Two distinct deletion processes exist in the platform:
2. **Soft-delete:** The platform marks all content and metadata as deleted and hides it in the interface and search results. Users with permissions to see deleted containers are still able to see them, and they can be reverted (undeleted) easily. The storage continues in use as the content is still there, but hidden.
3. **Hard-delete:** Once a data container has been soft-deleted, it is possible to hard-delete it for the users with the hard-delete permission. Content, metadata and related events are finally deleted from the platform.&#x20;

{% hint style="danger" %}
It is impossible to recover a hard-deleted container. **Hard-deleted data is lost forever.**
{% endhint %}

1. If you want to soft-delete a container, use this method:

```javascript
curl --request DELETE \
    --url "$your_platform_url/api/container/122" \
    --header "Authorization: Bearer $your_platform_api_key"
    --data ''
```

1. If you want to hard-delete it, use this method:

```javascript
curl --request DELETE \
    --url "$your_platform_url/api/container/122/delete/permanent" \
    --header "Authorization: Bearer $your_platform_api_key"
    --data ''
```

### Sharing: Making content externally accesible

The platform's permissions allow for providing or restricting access to platform's users, but the content can also be shared with any external user publicly, without needing authentication or a platform's account.

This can be achieved for some items in the container (files or folders) or for the whole container.

{% hint style="info" %}
When you share a container this way, your content is publicly available to any internet user.
{% endhint %}

{% hint style="warning" %}
When you share a folder, every item and subitem contained in the folder is also shared. Future items you place in the folder (in any subfolder) are also shared.
{% endhint %}

#### List shared elements in the container

1. Sign in to the platform's Management Interface
2. Obtain your API key by selecting your name and then **Access Methods:**

![](/files/-MgzL-1n0PIPN6MM4_wT)

1. Use the following method

```javascript
curl --request GET \
     --url "$your_platform_url/api/container/6520/shared" \
     --header "Content-Type: application/json" \
     --header "authorization: Bearer $your_platform_api_key" \
     --data '{
       "limit": 10,
       "offset": 0
}'
```

{% hint style="info" %}
If you are sharing a folder, only the shared folder appears as the result of the preceding method. Every item contained on it is also shared, but not shown in this list.
{% endhint %}

#### Share or un-share a file or folder

1. Sign in to the platform's Management Interface
2. Obtain your API key by selecting your name and then **Access Methods:**

![](/files/-MgzL-1ofowAjxiyiEUI)

1. Use the following method

```javascript
curl --request POST \
  --url "$your_platform_url/api/container/<your container id>/files/share" \
  --header "authorization: Bearer $your_platform_api_key" \
  --header 'content-type: application/json' \
  --data '{
    "files_id": [
        1929517
    ],
    "action": "SHARE"
}'
```

{% hint style="info" %}

* **files\_id** is an array that contains the identifiers of the items to apply the action to. Note that it could be a file or a folder, as folders are just another type of file in the platform.
* **action** could be **SHARE** or **UNSHARE.**
  {% endhint %}

When you obtain the details of a file using:

```javascript
$ curl --request GET \
      --url "$your_platform_url/api/file/60733" \
      --header "Content-Type: application/json" \
      --header "authorization: Bearer $your_platform_api_key" \
      --data ''
```

The sharing status of the file and the HTTP endpoint is also delivered under the `sharing` section:

![](/files/-MgzL-1pKLVL7RCmvill)

If the result is false, file is not shared:

![](/files/-MgzL-1q92AtCkwnOunO)

{% hint style="info" %}
When you share a folder, any **PRESENT or FUTURE** item in the folder is accesible using the name/path in the container.‌
{% endhint %}


---

# 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.libnova.com/libsafe-flexible-intake/get-started/work-with-data-containers.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.
