# Add a composition to a folder via openEHR REST API

**URL:** <https://discourse.openehr.org/t/add-a-composition-to-a-folder-via-openehr-rest-api/4388>\
**Category:** ITS\
**Tags:** rest-apis, rm\
**Created:** [28 August 2023 11:18 UTC](https://discourse.openehr.org/t/add-a-composition-to-a-folder-via-openehr-rest-api/4388 "2023-08-28T11:18:07Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![stefanspiska](https://discourse.openehr.org/user_avatar/discourse.openehr.org/stefanspiska/32/819_2.png) [@stefanspiska](https://discourse.openehr.org/u/stefanspiska)\
**Post date:** [28 August 2023 11:55 UTC](https://discourse.openehr.org/t/add-a-composition-to-a-folder-via-openehr-rest-api/4388/2 "2023-08-28T11:55:34Z")

</div>

Since the Directory endpoint always updates the whole structure you simple put it in the Folder structure which represents the directory .

So call [EHR API openEHR specs](https://specifications.openehr.org/releases/ITS-REST/latest/ehr.html#tag/DIRECTORY/operation/directory_update)

with

```auto
{
  "_type": "FOLDER",
  "name": {
    "_type": "DV_TEXT",
    "value": "root"
  },
  "archetype_node_id": "openEHR-EHR-FOLDER.generic.v1",
  "folders": [
    {
      "_type": "FOLDER",
      "name": {
        "_type": "DV_TEXT",
        "value": "history"
      },
      "archetype_node_id": "openEHR-EHR-FOLDER.generic.v1",
      "folders": [
        {
          "_type": "FOLDER",
          "name": {
            "_type": "DV_TEXT",
            "value": "family"
          },
          "archetype_node_id": "openEHR-EHR-FOLDER.generic.v1",
          "items": [
            {
          		"id": {
          			"_type": "HIER_OBJECT_ID",
          			"value": "d936409e-901f-4994-8d33-ed104d46015b"
          		},
          		"namespace": "my.system.id",
          		"type": "VERSIONED_COMPOSITION"
          	}
          ]
        }
      ]
    }
  ]
}

```

see also [https://github.com/ehrbase/integration-tests/blob/main/tests/robot/DIRECTORY\_TESTS/UPDATE\_DIRECTORY/H.1\_\_EHR\_with\_directory.robot](https://github.com/ehrbase/integration-tests/blob/main/tests/robot/DIRECTORY_TESTS/UPDATE_DIRECTORY/H.1__EHR_with_directory.robot)

---

_[View the full topic](https://discourse.openehr.org/t/add-a-composition-to-a-folder-via-openehr-rest-api/4388)._
