How they fit together
- There are two kinds:
organizationandclinic. Thekindfield says which one an item is. - An organization can contain sub-organizations and clinics, to any depth. A clinic contains nothing: it holds the patients, providers and orders.
parentIdis the organization above (ornullfor the top), andlevelis how deep the item is (0 at the top).- A person who works in an organization can see and work in everything beneath it. Reading from an organization combines the data of all the clinics beneath it; to write, choose one clinic (see Choosing a clinic).
- Owners and admins of an organization can create clinics beneath it. Creating an organization needs a permission,
canCreateOrganizations, that only a super admin can give. A super admin can always create organizations.
The clinic object
| Field | Type | Description |
|---|---|---|
id | string | The id. |
name | string | The display name. |
kind | string | organization or clinic. |
parentId | string or null | The organization above this one. |
level | integer | Depth in the tree. 0 is the top. |
status | string | approved, or pending for a clinic that registered itself and awaits approval. |
organization | string | A free-text organization name, set at registration. |
city, state, address, addressLine2, zip | string | The address. state is two letters. |
timezone | string | A time zone name. Defaults to America/New_York. |
legalName, taxId, description, tagline, website, phone, email, supportEmail | string | Profile details. Only fields that are set appear. |
logoUrl, iconUrl, brandColor, accentColor | string | Branding. The colours are #rrggbb. |
List organizations and clinics
GET/v1/clinics
Returns everything you can see, as a tree: parents come before their children and siblings are sorted by name. A person sees the organizations and clinics they belong to and everything beneath them; a super admin sees everything. The full list adds owners and counts; ?brief=1 returns names and the tree only and is much cheaper, so use it for pickers.
Who can call it
Any signed-in role.
Query parameters
| Name | Type | Description |
|---|---|---|
brief | string | Send 1 for names and the tree only (no owners or counts). |
Response
200 A list of items. In the full list each item adds owners (people with the owner or admin role), subOrganizations (how many organizations are directly beneath it) and counts (patients, providers and orders30, the orders of the last 30 days in the chosen environment).
{
"data": [
{
"id": "6aeb0da3503a52507f605e76",
"name": "HomelyMd",
"kind": "clinic",
"organization": "Ola Digital Health",
"city": "Tampa",
"state": "FL",
"address": "10575 Bloomingdale Ridge Dr, Riverview, FL 33578",
"timezone": "America/New_York",
"status": "approved",
"parentId": null,
"level": 0,
"owners": [
{ "id": "6afe9b3c3a44248dcd845972", "name": "Rohit Suthar", "email": "[email protected]", "role": "owner", "canCreateOrganizations": false }
],
"subOrganizations": 0,
"counts": { "patients": 9, "providers": 1, "orders30": 14 }
}
]
}Errors
| Status | Code | When it happens |
|---|---|---|
| 401 | unauthenticated | There is no session. |
Examples
curl -b cookies.txt "https://app-api.homelyrx.com/v1/clinics?brief=1"Get one organization or clinic
GET/v1/clinics/:id
Returns one item you are allowed to see.
Who can call it
Any signed-in role.
Response
200 The item, with the fields above.
{
"id": "6b0430e6cc8f4730ebbf8a8c",
"name": "Docs Example Org",
"kind": "organization",
"city": "Tampa",
"state": "FL",
"timezone": "America/New_York",
"status": "approved",
"parentId": null,
"level": 0
}Errors
| Status | Code | When it happens |
|---|---|---|
| 400 | validation | The id is not a valid id. |
| 404 | notFound | The item does not exist or is outside what you can see. |
Examples
curl -b cookies.txt "https://app-api.homelyrx.com/v1/clinics/ORG_ID"Create an organization or clinic
POST/v1/clinics
Creates an organization or a clinic. A super admin can create one anywhere, or at the top when parentId is left out. Everyone else creates beneath the organization they are working in, or beneath parentId if you give one they can see. You can hand it to a person in the same call: with owner a new owner account is made, or, when that email already has an account, the new item is added to theirs.
Who can call it
super_admin, owner, admin. Creating an organization also needs the canCreateOrganizations permission (a super admin always has it).
Request body
| Name | Type | Required | Description |
|---|---|---|---|
name | string | Required | At least 2 characters. |
kind | string | Optional | organization or clinic. Defaults to clinic. |
parentId | string | Optional | The organization to create it under. It must be an organization you can see. |
city, state, address, timezone, organization | string | Optional | Optional details. state is exactly 2 letters. |
owner | object | Optional | Hands the new item to a person. Fields: name (at least 2 characters, required), email (required), password (at least 12 characters, required unless the email already has an account) and canCreateOrganizations (boolean, super admin only). |
Response
201 The new item.
{
"id": "6b0430e6cc8f4730ebbf8a8c",
"name": "Docs Example Org",
"kind": "organization",
"city": "Tampa",
"state": "FL",
"timezone": "America/New_York",
"status": "approved",
"parentId": null,
"level": 0
}Errors
| Status | Code | When it happens |
|---|---|---|
| 400 | validation | A field is invalid. |
| 400 | passwordRequired | owner is a new person but has no password. |
| 400 | parentMustBeOrganization | parentId is a clinic. |
| 403 | forbidden | Your role cannot create, or you may not create organizations. |
| 404 | notFound | parentId is not something you can see. |
| 409 | emailTaken | The owner's email belongs to a super admin. |
Examples
curl -b cookies.txt -X POST "https://app-api.homelyrx.com/v1/clinics" \
-H "content-type: application/json" \
-d '{"name":"Docs Example Org","kind":"organization","city":"Tampa","state":"FL","owner":{"name":"Docs Owner","email":"[email protected]","password":"a-long-password-123"}}'Update an organization or clinic
PATCH/v1/clinics/:id
Changes the profile of an item you can see. Send only the fields you want to change. Sending an empty string clears a field (except name). Unknown fields are rejected.
Who can call it
super_admin, owner, admin.
Request body
| Name | Type | Required | Description |
|---|---|---|---|
name | string | Optional | 2 to 120 characters. |
legalName, organization, tagline | string | Optional | Text up to 200 characters (tagline 160). |
taxId | string | Optional | Up to 40 characters. |
description | string | Optional | Up to 1000 characters. |
timezone | string | Optional | A time zone name. |
logoUrl, iconUrl, website | string | Optional | A full link starting with https://. |
brandColor, accentColor | string | Optional | A colour like #4a1470. |
email, supportEmail | string | Optional | A valid email address. |
phone, address, addressLine2, city, zip | string | Optional | Text. |
state | string | Optional | Exactly 2 letters; stored in capitals. |
Response
200 The updated item.
{
"id": "6b0430e6cc8f4730ebbf8a8c",
"name": "Docs Example Org",
"kind": "organization",
"city": "Tampa",
"state": "FL",
"timezone": "America/New_York",
"status": "approved",
"parentId": null,
"level": 0
}Errors
| Status | Code | When it happens |
|---|---|---|
| 400 | validation | A field is invalid, or the body contains a field that cannot be changed. |
| 403 | forbidden | Your role cannot edit. |
| 404 | notFound | The item is not something you can see. |
Examples
curl -b cookies.txt -X PATCH "https://app-api.homelyrx.com/v1/clinics/ORG_ID" \
-H "content-type: application/json" \
-d '{"tagline":"Care at home","brandColor":"#4a1470","website":"https://example.com"}'Allow someone to create organizations
PATCH/v1/clinics/:id/members/:userId
Switches the canCreateOrganizations permission on or off for an owner or admin who works in the organization.
Who can call it
super_admin only.
Request body
| Name | Type | Required | Description |
|---|---|---|---|
canCreateOrganizations | boolean | Required | true to allow, false to withdraw. |
Response
200 The person and their permission.
{ "data": { "id": "6b0430e6cc8f4730ebbf8a8e", "canCreateOrganizations": true } }Errors
| Status | Code | When it happens |
|---|---|---|
| 400 | validation | The body is not exactly canCreateOrganizations as a boolean. |
| 403 | forbidden | You are not a super admin. |
| 404 | notFound | No owner or admin with this id works in this organization. |
Examples
curl -b cookies.txt -X PATCH "https://app-api.homelyrx.com/v1/clinics/ORG_ID/members/USER_ID" \
-H "content-type: application/json" \
-d '{"canCreateOrganizations":true}'