# Document

Property Type: `document`

A Document can act in two ways. When configured as an array, it is a collection of documents with shared properties. When not defined as an array, the document properties are implemented as children.

Documents whose definition is configured as an array have an `_id` property which can be used to retrieve, update or remove individual documents from the array. For example, the Organization roles are defined as a document array. Retrieving the `_id` of all org roles could be done as follows:

`GET /orgs/5516ee1b34d8d934281699e3/roles?paths[]=_id`JSON

```
{
    "_id": "5516ee1b34d8d934281699e3",
    "object": "org",
    "roles": [{
        "_id": "000000000000000000000004"
    }, {
        "_id": "000000000000000000000005"
    }, {
        "_id": "000000000000000000000007"
    }]
}
```

{% hint style="info" %}
Notice the use of a relative path to the org roles identifiers in the query (paths\[]=\_id). Selection using paths, include and expand all work in this way.
{% endhint %}

An example of a non-array Document is the Account `name` property, having `first` and `last` child properties.

`GET /accounts/me`JSON

```
{
    "_id": "5516ee2634d8d93428169c0e",
    "object": "account",
    "name": {
        "first": "Jonas",
        "last": "Salk"
    }    
}
```

{% hint style="info" %}
When ACLs and filters are applied at the document level, they affect access to all its children.
{% endhint %}

#### Discriminators

Some Document arrays contain a discriminator, such as Post and Comment bodies. Because these arrays carry documents with potentially varying properties, the `name` property is used as a discriminator. When creating a Post, for example, the discriminator must be included in the json body.

`POST /c_vads/551f3515b8b206e835950b59/posts/c_heartrate`JSON

```
{
        "body": [{
            "name": "c_datapoint",
            "c_value": 65
        }] 
    }
```

When updating a document array that has a discriminator, the `_id` of the segment is sufficient:

`PUT /551f3a95b8b206e835950b6b`JSON

```
{
      "body": [{
          "_id": "551f3aa2b8b206e835950b6d",
          "c_value": 67
      }] 
  }
```

### Property Options

| Name       | Type                      | Description                                                                            |
| ---------- | ------------------------- | -------------------------------------------------------------------------------------- |
| properties | Property Definition Array | An array of property definitions. These can be properties of any type except Document. |

**Base property options not available:**

* uniqueValues
* indexed
* unique
* auditable


---

# 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.medable.com/cortex-api/objects-definition/object-properties/document.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.
