Search…
Property Access
The Medable API affords developers the ability to access and update property data in flexible and convenient ways.
Although Property Selection can reduce the number of paths returned while maintaining the structure of the document. One way to do it
1
// GET /accounts/5516ee2634d8d93428169c0e?paths[]=name.first
2
3
{
4
"_id": "5516ee2634d8d93428169c0e",
5
"name": {
6
"first": "Jonas"
7
},
8
"object": "account"
9
}
Copied!
A single property can also be directly accessed, resulting in a result response.
Even Simpler
1
// GET /accounts/5516ee2634d8d93428169c0e/name/first
2
3
{
4
"object": "result",
5
"data": "Sarah Jones"
6
}
Copied!
A property within a document array can be directly accessed, using its _id ("551f34c8b8b206e835950b57"). For example, retrieving the name of a custom role:
Custom Role
1
// GET /orgs/5516ee1b34d8d934281699e3/roles/551f34c8b8b206e835950b57/name
2
3
{
4
"object": "result",
5
"data": "Care Giver"
6
}
Copied!
Properties may be updated in the same way. The following are both valid ways to update the name of the above role:
PUT Example
1
// PUT /orgs/5516ee1b34d8d934281699e3
2
3
Request:
4
{
5
"roles": [{
6
"_id": "551f34c8b8b206e835950b57",
7
"name": "Third Party"
8
}]
9
}
10
Response:
11
{
12
"_id": "5516ee1b34d8d934281699e3",
13
"object": "org",
14
"code": "example",
15
"roles": [{
16
"_id": "551f3515b8b206e835950b59",
17
"name": "Care Giver",
18
"all": [],
19
"include": []
20
},
21
...
22
],
23
...
24
}
Copied!
The above response includes the entire updated context.
PUT Example
1
// PUT /orgs/5516ee1b34d8d934281699e3/roles/551f34c8b8b206e835950b57/name
2
3
Request:
4
"Third Party"
5
Response:
6
{
7
"object": "result",
8
"data": "Third Party"
9
}
Copied!
Property and Document arrays can be configured to allow overwrite, append-only, and/or pull. Arrays can also be configured to ensure unique values within the array, or in the case of a Document array, a property can have a validator that ensures it is unique within the rest of the parent array's documents.
    Appending items to an array using the API must be done using the POST method.
    Overwriting an array is done using PUT.
    Array elements can be directly access by index (GET /orgs/5516ee1b34d8d934281699e3/roles/0).
    Array elements cannot be updated by index.
    When removing elements from a document array, use the _id (DELETE /orgs/5516ee1b34d8d934281699e3/roles/551f34c8b8b206e835950b57)
    When removing elements from a primitive array, all matching values are removed (DELETE /c_custom/c_tags/MyTag)
Last modified 1mo ago
Copy link