Skip to content

Commit 01752bd

Browse files
committed
feat(#10221): add documentation to create/update a person
Signed-off-by: apoorvapendse <apoorvavpendse@gmail.com>
1 parent 5ca03b1 commit 01752bd

1 file changed

Lines changed: 167 additions & 0 deletions

File tree

  • content/en/building/reference

content/en/building/reference/api.md

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,6 +1259,173 @@ Content-Type: application/json; charset=utf-8
12591259
}
12601260
```
12611261

1262+
### POST /api/v1/person
1263+
1264+
*Added in x.x.x*
1265+
#### Description
1266+
Used to create a person.
1267+
1268+
#### Supported Properties
1269+
1270+
Use JSON in the request body to specify a person’s details.
1271+
1272+
#### Permissions
1273+
Should have `can_edit` or both `can_view_contacts` and `can_create_people`.
1274+
1275+
#### Required
1276+
| Field | Description | Format |
1277+
| ---- | ----------------------------------- | -------- |
1278+
| name | Name of the person. | string |
1279+
| type | ID of the `contact_type` for the new person. Pass in `person` for older versions. | string |
1280+
| parent | ID of the parent document, which is a place, for the new person. The type of the parent must belong to one of the allowed `parents` for the `contact_type` id in the settings config. | UUID string |
1281+
1282+
#### Optional
1283+
1284+
| Field | Description | Format |
1285+
| ------------- | ---------------------------------------------------------------------- | ----------- |
1286+
| reported_date | Timestamp of when the record was reported or created. Defaults to now. | 'YYYY-MM-DDTHH:mm:ssZ', 'YYYY-MM-DDTHH:mm:ss.SSSZ', or unix epoch. |
1287+
| _id | ID of the new person document to be created. | UUID string |
1288+
| short_name | String to denote short name of the person. | string |
1289+
| phone | Phone number of the person in string format. | string |
1290+
| role | Role of the person in string format. | string |
1291+
1292+
1293+
#### Examples
1294+
Create a person with a clinic as its parent place.
1295+
1296+
```bash
1297+
POST /api/v1/person
1298+
Content-type: application/json
1299+
1300+
{
1301+
"name": "dummyuser",
1302+
"type": "person",
1303+
"parent":"01992f01-f155-4386-8538-5080c3155585"
1304+
}
1305+
```
1306+
1307+
Example response:
1308+
```json
1309+
{
1310+
"_id": "4dcd842e813fd1bcabec03f98f002a98",
1311+
"_rev": "1-bf4ecb779a3a369f6162a149853cbb02",
1312+
"name": "dummyuser",
1313+
"type": "contact",
1314+
"parent": {
1315+
"_id": "01992f01-f155-4386-8538-5080c3155585",
1316+
"parent": {
1317+
"_id": "35a2f31e-705c-4833-b385-efd069b1ce3f",
1318+
"parent": {
1319+
"_id": "29368c93-d267-4e80-8fbe-6543f702ff30"
1320+
}
1321+
}
1322+
},
1323+
"reported_date": 1755519112122,
1324+
"contact_type": "person"
1325+
}
1326+
```
1327+
1328+
### PUT /api/v1/person
1329+
1330+
*Added in x.x.x*
1331+
#### Description
1332+
Used to update mutable fields of a person, or delete them if they are not part of update payload.
1333+
1334+
#### Supported Properties
1335+
1336+
Use JSON in the request body to specify a person’s details.
1337+
1338+
#### Permissions
1339+
Either of the two:
1340+
1. `can_edit`
1341+
2. `can_view_contacts` and `can_update_people`
1342+
1343+
#### Required immutable fields
1344+
| Field | Description | Format |
1345+
| ---- | ----------------------------------- | -------- |
1346+
| _id | ID of the person doc to be updated. | UUID string |
1347+
| _rev | Revision ID of the person doc to be updated. | string |
1348+
| reported_date | Timestamp of when the record was reported or created. | 'YYYY-MM-DDTHH:mm:ssZ', 'YYYY-MM-DDTHH:mm:ss.SSSZ', or unix epoch |
1349+
| contact_type| Required if the type of the person is `contact`. | string |
1350+
| type | The type of the person. | string |
1351+
| parent | The parent lineage of the person to be updated. | Minified or hydrated parent lineage |
1352+
1353+
#### Required mutable fields
1354+
| Field | Description |
1355+
| ---- | ----------------------------------- |
1356+
| name | Name of the person. |
1357+
1358+
#### Examples
1359+
Updating `sex` from "male" to "female" and deleting the `short_name` field
1360+
1361+
Original Doc:
1362+
```json
1363+
{
1364+
"_id": "4dcd842e813fd1bcabec03f98f004c96",
1365+
"_rev": "1-1492a8ddf25a350cdd35c217a561f27a",
1366+
"name": "dummyuser",
1367+
"type": "contact",
1368+
"parent": {
1369+
"_id": "01992f01-f155-4386-8538-5080c3155585",
1370+
"parent": {
1371+
"_id": "35a2f31e-705c-4833-b385-efd069b1ce3f",
1372+
"parent": {
1373+
"_id": "29368c93-d267-4e80-8fbe-6543f702ff30"
1374+
}
1375+
}
1376+
},
1377+
"sex": "male",
1378+
"short_name": "userX",
1379+
"reported_date": 1755519752958,
1380+
"contact_type": "person"
1381+
}
1382+
```
1383+
1384+
Request Body:
1385+
```bash
1386+
PUT /api/v1/person
1387+
{
1388+
"_id": "4dcd842e813fd1bcabec03f98f004c96",
1389+
"_rev": "1-1492a8ddf25a350cdd35c217a561f27a",
1390+
"name": "dummyuser",
1391+
"type": "contact",
1392+
"parent": {
1393+
"_id": "01992f01-f155-4386-8538-5080c3155585",
1394+
"parent": {
1395+
"_id": "35a2f31e-705c-4833-b385-efd069b1ce3f",
1396+
"parent": {
1397+
"_id": "29368c93-d267-4e80-8fbe-6543f702ff30"
1398+
}
1399+
}
1400+
},
1401+
"sex": "female",
1402+
"reported_date": 1755519752958,
1403+
"contact_type": "person"
1404+
}
1405+
```
1406+
1407+
Response:
1408+
```json
1409+
{
1410+
"_id": "4dcd842e813fd1bcabec03f98f004c96",
1411+
"_rev": "2-3100df4acfd79b641173ff7d0d53e871",
1412+
"name": "dummyuser",
1413+
"type": "contact",
1414+
"parent": {
1415+
"_id": "01992f01-f155-4386-8538-5080c3155585",
1416+
"parent": {
1417+
"_id": "35a2f31e-705c-4833-b385-efd069b1ce3f",
1418+
"parent": {
1419+
"_id": "29368c93-d267-4e80-8fbe-6543f702ff30"
1420+
}
1421+
}
1422+
},
1423+
"sex": "female",
1424+
"reported_date": 1755519752958,
1425+
"contact_type": "person"
1426+
}
1427+
```
1428+
12621429
## People
12631430

12641431
### Supported Properties

0 commit comments

Comments
 (0)