What the API does
The HomelyRx API is the same API the HomelyRx portal uses. With it your software can create and update patients, list prescribers, search the catalog of pharmacy offers, place and cancel orders, and read order status, notifications and dashboard numbers.
Base address and versions
Every call goes to the API address of your environment, followed by a path. All signed-in routes start with /v1. Production is https://app-api.homelyrx.com. The test environment is https://stage-api.homelyrx.com; use it to build and try your integration before going live. On a local machine the address is http://localhost:8112.
To check that the API is running, call the health route. It needs no sign-in.
curl "https://app-api.homelyrx.com/healthz"{ "status": "ok", "env": "dev" }Quick start
These five steps sign in, find patients, add a patient, place a sandbox order for them and cancel it. Every example keeps the session cookie from step 1. In curl that is the cookie file cookies.txt; in JavaScript it is credentials: 'include'; in Python it is a requests.Session.
1. Sign in
Send your email and password. The reply describes you, and the API sets the hrx_session cookie.
curl -c cookies.txt -X POST "https://app-api.homelyrx.com/v1/auth/login" \
-H "content-type: application/json" \
-d '{"email":"[email protected]","password":"your-password"}'const API = 'https://app-api.homelyrx.com';
const res = await fetch(`${API}/v1/auth/login`, {
method: 'POST',
credentials: 'include',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ email: '[email protected]', password: 'your-password' }),
});
const { data: me } = await res.json();
console.log(me.role);import requests
api = "https://app-api.homelyrx.com"
s = requests.Session() # keeps the session cookie for the next calls
r = s.post(f"{api}/v1/auth/login", json={"email": "[email protected]", "password": "your-password"})
me = r.json()["data"]
print(me["role"]){
"data": {
"id": "6afe9b3c3a44248dcd845972",
"email": "[email protected]",
"name": "Rohit Suthar",
"role": "owner",
"clinicId": "6aeb0da3503a52507f605e76",
"canCreateOrganizations": false
}
}2. List patients
Lists are paged and can be filtered. This asks for five female patients whose profile is complete.
curl -b cookies.txt "https://app-api.homelyrx.com/v1/patients?limit=5&profile=complete&sex=F"const res = await fetch(`${API}/v1/patients?limit=5&profile=complete&sex=F`, { credentials: 'include' });
const { data: patients, meta } = await res.json();
console.log(meta.total, patients.map((p) => p.name));r = s.get(f"{api}/v1/patients", params={"limit": 5, "profile": "complete", "sex": "F"})
body = r.json()
print(body["meta"]["total"], [p["name"] for p in body["data"]])3. Create a patient
Only a first and last name are required. The patient is added to your clinic.
curl -b cookies.txt -X POST "https://app-api.homelyrx.com/v1/patients" \
-H "content-type: application/json" \
-d '{"firstName":"Maya","lastName":"Patel","dob":"03/14/1988","sex":"F","email":"[email protected]","phone":"(813) 555-0123","address":"401 E Jackson St, Tampa, FL 33602","externalId":"pt-2001"}'const res = await fetch(`${API}/v1/patients`, {
method: 'POST',
credentials: 'include',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({
firstName: 'Maya',
lastName: 'Patel',
dob: '03/14/1988',
sex: 'F',
email: '[email protected]',
phone: '(813) 555-0123',
address: '401 E Jackson St, Tampa, FL 33602',
externalId: 'pt-2001',
}),
});
const { data: patient } = await res.json(); // 201
console.log(patient.id);r = s.post(f"{api}/v1/patients", json={
"firstName": "Maya",
"lastName": "Patel",
"dob": "03/14/1988",
"sex": "F",
"email": "[email protected]",
"phone": "(813) 555-0123",
"address": "401 E Jackson St, Tampa, FL 33602",
"externalId": "pt-2001",
})
patient = r.json()["data"] # status 201
print(patient["id"])4. Place a sandbox order
The x-hrx-env: staging header makes this a sandbox order, so nothing is sent to a pharmacy. Each line names a catalog SKU. The reply is a summary of the order, with its number and total.
curl -b cookies.txt -X POST "https://app-api.homelyrx.com/v1/orders" \
-H "x-hrx-env: staging" \
-H "content-type: application/json" \
-d '{"patientId":"PATIENT_ID","shipTo":"patient","lines":[{"sku":"FIZY-278DYJ"},{"sku":"FIZY-SEM025"}]}'const res = await fetch(`${API}/v1/orders`, {
method: 'POST',
credentials: 'include',
headers: { 'content-type': 'application/json', 'x-hrx-env': 'staging' },
body: JSON.stringify({
patientId: patient.id,
shipTo: 'patient',
lines: [{ sku: 'FIZY-278DYJ' }, { sku: 'FIZY-SEM025' }],
}),
});
const { data: order } = await res.json(); // 201
console.log(order.number, order.total);r = s.post(
f"{api}/v1/orders",
headers={"x-hrx-env": "staging"},
json={"patientId": patient["id"], "shipTo": "patient", "lines": [{"sku": "FIZY-278DYJ"}, {"sku": "FIZY-SEM025"}]},
)
order = r.json()["data"] # status 201
print(order["number"], order["total"])5. Cancel the order
Orders can be cancelled by an owner or admin until a pharmacy ships them. Cancelling twice returns a 409 with the code alreadyCancelled.
curl -b cookies.txt -X POST "https://app-api.homelyrx.com/v1/orders/ORDER_NUMBER/cancel" \
-H "x-hrx-env: staging"const res = await fetch(`${API}/v1/orders/${order.number}/cancel`, {
method: 'POST',
credentials: 'include',
headers: { 'x-hrx-env': 'staging' },
});
const { data: cancelled } = await res.json();
console.log(cancelled.status); // "cancelled"r = s.post(f"{api}/v1/orders/{order['number']}/cancel", headers={"x-hrx-env": "staging"})
print(r.json()["data"]["status"]) # "cancelled"Where to go next
The pages of this reference are listed below. Each endpoint shows who can call it, its parameters, an example response and its errors.
- AuthenticationSign in to the HomelyRx API with an email and password, keep the session cookie, read who you are, sign out, and understand roles and cookie settings.
- Requests and responsesHow HomelyRx API calls look: base address, JSON bodies, the data and meta envelope, paging, sandbox and production, and choosing a clinic with headers.
- ErrorsEvery error the HomelyRx API returns: the response shape, each error code with its HTTP status and meaning, and how to read field-level validation errors.
- Organizations and clinicsHow organizations and clinics work in the HomelyRx API: the tree, who can create what, scoping with x-clinic-id, and the endpoints to list, create and edit them.
- PatientsUse the HomelyRx patients API to list and filter patients, read one patient with order history, create, update and delete patients, with curl, JavaScript and Python.
- ProvidersUse the HomelyRx providers API to list prescribers with their NPI and licensed states, search and filter them, read one provider and add a new one.
- Catalog and pharmaciesSearch the HomelyRx catalog of pharmacy offers by name, SKU, pharmacy, stock and type, read the catalog summary, and list the partner pharmacies.
- OrdersUse the HomelyRx orders API to place orders from catalog SKUs, list and filter them, read lines and tracking, cancel an order and add a message, with curl, JavaScript and Python.
- Notifications and dashboardRead the latest HomelyRx notifications, mark them all as read, and get the dashboard summary of orders, spend, delivery rate and patients for the last 30 days.
- WebhooksReceive order events from HomelyRx at your own address: create a webhook in the portal, verify the signature, and handle order.created, order.cancelled and order.message.
