API v1 reference: read and write
Routes that read from and write to a clinic on Moonshot EHR. Public routes need no key and only read the clinic's services, providers, membership plans and open times: the same information the clinic's booking and membership pages already show. Plus a secret API key for the clinic's own integration, the route that checks one, lead routes that create a lead and read its progress with it, and chart routes that read patient records and add to them, for a system covered by the clinic's business associate agreement.
What a key can write
With a secret API key the clinic's owner created, a server covered by the clinic's business associate agreement can write to the clinic's charts:
- Create a patient chart (
POST /api/v1/patients). - Add a file to a chart for staff review (
POST /api/v1/patients/{id}/documents). - Create a staff task on a chart (
POST /api/v1/patients/{id}/tasks). - Create an unsigned draft note that a clinician reviews and signs (
POST /api/v1/patients/{id}/notes).
Nothing written through the API is signed, sent to the patient, prescribed, booked or charged. Permissions, limits and rules: Writing.
Basics
- Host:
https://api.moonshotehr.com(https://api.moonshotclinic.comanswers the same routes). - Clinic, on the public reads:
X-Tenant-Slug: <clinic>. Missing or unknown answers404 tenant_not_found. On keyed routes the key decides the clinic (see Secret API keys). - Success:
{ "data": ..., "next_cursor": null }.next_cursoris a string or null; it is null except on the paged chart routes, where it fetches the next page. - Error:
{ "error": { "code", "message", "request_id" } }. Branch oncode;messageis for people. - Every response carries
X-Request-IdandCache-Control: no-store. Reads answerGETandHEAD; the lead routes also takePOSTandPATCHwith a JSON body of at most 64 KB. A trailing slash is ignored. - An explicit
X-Tenant-Slugthat does not match a clinic is a404; there is no fallback to another clinic. - Dates are
YYYY-MM-DDreal calendar days; anything else is400 invalid_request. Availability is reported from today on, in the clinic's time zone: a past date has no slots and a summary starts no earlier than today. - Full description: openapi-v1.json (OpenAPI 3.1).
GET /api/v1/catalog
The clinic (name, slug, phone, booking_mode), its appointment_types (id, name, duration_minutes, visit_mode, bookable_online), providers (id, display_name, title, appointment_type_ids), memberships.available and membership_plans (product_code, name, price_cents, interval).
bookable_online: falsemarks a video-only service: it is booked through the patient portal and/availabilityrefuses it.booking_mode: requestmeans the clinic takes requests, not online bookings; types and providers are then empty, except for any types the clinic still keeps open online.intervalis usuallymonth,quarteroryear; display any other value as given.
GET /api/v1/availability
Query: appointment_type_id (required), date (required, YYYY-MM-DD in the clinic's time zone), provider_id (optional).
{
"data": {
"date": "2026-11-16",
"duration": 30,
"slots": [
{ "time": "09:00", "end_time": "09:30", "provider_id": "8a2b4c6d-1e3f-4a5b-8c7d-9e0f1a2b3c4d", "provider_name": "Dana Reyes", "provider_title": "NP" }
]
},
"next_cursor": null
}
GET /api/v1/availability/summary
Query: appointment_type_id (required), from and to (required, up to 62 days apart; clamped to start today), provider_id (optional). Open-time counts per day.
{ "data": { "summary": { "2026-11-16": 6, "2026-11-17": 0 } }, "next_cursor": null }
Secret API keys
For the clinic's own integration, called from a server. The clinic's owner creates a key in the EHR (Settings, Developers, API keys), chooses its permissions and how long it lasts (12 months by default, never longer), and copies it once: it is never shown again. A live clinic's key starts mck_live_, a test clinic's mck_test_.
- Send it as
Authorization: Bearer <key>. Keep it on your server; never put it in a web page or an app. - The key decides the clinic.
X-Tenant-Slugis not needed; one that names a different clinic answers403 tenant_mismatch. - A missing, malformed, unknown, expired or revoked key answers
401 unauthorized, the same way every time, withWWW-Authenticate: Bearer. A key without a route's permission answers403 insufficient_scope. - Keyed routes send no CORS headers, so a browser cannot read them.
- To rotate: create a second key, move your integration to it, then have the owner revoke the first. A revoke takes effect on the next request.
- Permissions a key can carry:
leads:writeandleads:read(the lead routes),reports:read(the lead report),charts:read,appointments:readandmessages:read(the chart reads),patients:write,documents:write,tasks:writeandnotes:write(the chart writes; only the clinic's owner can add any chart permission, after confirming the receiving system is covered by the clinic's business associate agreement),handoffs:writeandevents:read(for the routes listed under Coming in v1).
GET /api/v1/key
Checks the key you sent: the clinic it belongs to, its prefix (as the clinic's Settings list shows it), its permissions and when it expires. Any valid key may call it; nothing else is returned.
curl -s https://api.moonshotehr.com/api/v1/key -H 'Authorization: Bearer <key>'
{
"data": {
"clinic": "northside",
"key_prefix": "mck_live_3f9a2c1e",
"scopes": ["leads:write"],
"expires_at": "2027-10-05T14:00:00.000Z"
},
"next_cursor": null
}
POST /api/v1/leads
Creates a lead on the clinic's Leads board, the same way the clinic's website form does. Needs leads:write. Body (JSON): email (required), first_name, last_name or name, phone, source, service_interest, notes, attribution (an object of UTM and click-id keys). Full field rules: Send leads.
curl -s https://api.moonshotehr.com/api/v1/leads -H 'Authorization: Bearer <key>' \
-H 'Content-Type: application/json' -H 'Idempotency-Key: form-submission-81723' \
-d '{ "email": "dana@example.com", "first_name": "Dana", "attribution": { "utm_source": "google" } }'
{ "data": { "id": "8d1c2b3a-4e5f-4a6b-9c7d-0e1f2a3b4c5d", "status": "new", "created_at": "2026-11-16T15:04:05.000Z", "duplicate": false, "note_saved": true }, "next_cursor": null }
201for a new lead. A lead with that email address (capitals ignored) from the last 24 hours answers200with"duplicate": trueand its id; no second lead is created.note_saved:truewhen thenotesyou sent are on the lead,falsewhen none were sent or they could not be saved.Idempotency-Key(optional, honored here and ignored onPATCH): the same key and body within 24 hours return the first answer; a different body, or a request while the first is still running, is409 idempotency_conflict.- An unknown or malformed field is
400 invalid_requestand the message names it.
PATCH /api/v1/leads/{id}
Corrects first_name, last_name, email, phone or attribution keys (the keys sent replace those keys; others are kept). Needs leads:write. Status, owner, notes and everything else the clinic's staff own are refused with 400 naming the field. Only leads this API created can be corrected; any other id is 404. Idempotency-Key is ignored here.
{ "data": { "id": "8d1c2b3a-4e5f-4a6b-9c7d-0e1f2a3b4c5d", "updated_at": "2026-11-17T09:30:00.000Z" }, "next_cursor": null }
GET /api/v1/leads/{id}/status
Three yes-or-no answers about the person behind the lead, defined as in the clinic's own conversion report: booked (an appointment booked after the lead came in), onboarding_completed (forms completed, none outstanding), member (a membership started after the lead came in). Needs leads:read. Only for leads this API created (a duplicate of a lead that came in another way answers without status); any other id is 404. Also attribution, the attribution keys stored on the lead. When the clinic owner has turned on payment sharing (off by default; only for an agency under a business associate agreement with the clinic), a payments summary: paid_total_cents kept after refunds since the lead came in, without card surcharges or sales tax (so it can be lower than the Collected figure in the clinic's own reports), payment_count, first_paid_at, last_paid_at (the clinic's local dates, YYYY-MM-DD), currency; card chargebacks are not taken off. When it is off, payments is absent, not zero. No names, contact details, line items or clinical data, but amounts and dates can still reveal which plan or service a patient bought.
{ "data": { "id": "8d1c2b3a-4e5f-4a6b-9c7d-0e1f2a3b4c5d", "booked": true, "onboarding_completed": false, "member": false, "updated_at": "2026-11-20T16:30:00.000Z", "attribution": { "utm_source": "google", "utm_campaign": "fall" }, "payments": { "paid_total_cents": 39000, "payment_count": 2, "first_paid_at": "2026-11-19", "last_paid_at": "2026-11-20", "currency": "USD" } }, "next_cursor": null }
The lead routes answer 403 phi_access_disabled until the clinic's business associate agreement with Moonshot EHR is in place, and never return an email address or phone number.
GET /api/v1/reports/leads
The clinic's lead and conversion totals for a period: the same numbers and definitions as the Funnel report the clinic's owner sees in the EHR. Needs reports:read. Counts only: no names, contact details, ids, campaign text, staff names or per-lead rows.
fromandto(optional, YYYY-MM-DD, the clinic's own calendar days, at most 366 days apart), orpreset(optional:this_month,last_monthorlast_90; it wins overfromandto). One of the two is needed.group_by(optional):none(the default) orsource, one row per lead source.source(optional): only leads from one source key, such asgoogle,meta,referralorother.- Campaign and lead owner are not available here, as a grouping or as a filter: either answers
400 invalid_request, as does any other parameter. leadscounts every lead in the period;new_prospect_leadsare the ones the funnel follows andexisting_patient_leadscame from people who were already patients.new_patient_leadsare new prospects that have been put on a patient record, paid or not. Each step has itscount,rate_from_previousandrate_from_cohort(percent of new-prospect leads).definitionsexplains every number in a sentence.- Counts are exact, including small ones, so a count of 1 can point at one person. Treat the report as the clinic's confidential information.
- Always sent: the lead counts above and the Consultation booked, Attended and Became a member steps.
- Sent only when the clinic owner has turned on payment sharing (off by default; only for an agency under a business associate agreement with the clinic): the First payment step (
paid),converted_patients(people who paid),collected_cents,collected_per_lead_cents,collected_per_converted_patient_centsandcurrency. Even then they are left out of the totals when it has fewer than 5 new-prospect leads, and out of every source row when any source row has fewer than 5, so one narrow query cannot show what one person paid. Comparing several queries (overlapping periods, one source against all) can still narrow it down, which is why the switch is only for an agency under a business associate agreement. Left out means absent, not zero. - A long period can take a few seconds; if it takes too long the answer is
503 report_timeoutwithRetry-After. One report per clinic runs at a time: a call while another is running answers429 rate_limitedwithRetry-After. The numbers move only as leads come in and progress, so a few calls an hour is plenty.
{"data": {"as_of": "2026-11-30T15:04:05.000Z", "range": {"from": "2026-10-01", "to": "2026-10-31", "days": 31, "preset": "last_month", "timezone": "America/Chicago"}, "group_by": "source", "definitions": ["leads: every lead created in the period ...", "..."], "totals": {"leads": 46, "new_prospect_leads": 40, "existing_patient_leads": 6, "new_patient_leads": 14, "steps": [{"key": "booked", "label": "Consultation booked", "count": 18, "rate_from_previous": 45, "rate_from_cohort": 45}, {"key": "attended", "label": "Attended", "count": 12, "rate_from_previous": 66.7, "rate_from_cohort": 30}, {"key": "member", "label": "Became a member", "count": 7, "rate_from_previous": 58.3, "rate_from_cohort": 17.5}, {"key": "paid", "label": "First payment", "count": 11, "rate_from_previous": 27.5, "rate_from_cohort": 27.5}], "converted_patients": 10, "collected_cents": 412500, "collected_per_lead_cents": 10313, "collected_per_converted_patient_cents": 41250}, "rows": [{"key": "google", "label": "Google", "leads": 38, "new_prospect_leads": 36, "existing_patient_leads": 2, "new_patient_leads": 13, "steps": [{"key": "booked", "label": "Consultation booked", "count": 17, "rate_from_previous": 47.2, "rate_from_cohort": 47.2}, {"key": "attended", "label": "Attended", "count": 11, "rate_from_previous": 64.7, "rate_from_cohort": 30.6}, {"key": "member", "label": "Became a member", "count": 7, "rate_from_previous": 63.6, "rate_from_cohort": 19.4}, {"key": "paid", "label": "First payment", "count": 10, "rate_from_previous": 27.8, "rate_from_cohort": 27.8}], "converted_patients": 9, "collected_cents": 383000, "collected_per_lead_cents": 10639, "collected_per_converted_patient_cents": 42556}], "currency": "USD"}, "next_cursor": null}
Like the lead routes, the report answers 403 phi_access_disabled until the clinic's business associate agreement with Moonshot EHR is in place.
GET /api/v1/patients
These routes read; none of them changes anything. The routes that add to a chart are under Writing. Server to server, with a key that has the permission named on each route. Only the clinic's owner can create such a key, and only after confirming that the receiving system is covered by the clinic's business associate agreement and that the data will not be forwarded to advertising platforms; a key made before these routes existed does not gain them. Until the clinic's business associate agreement with Moonshot EHR is in place they answer 403 phi_access_disabled.
- The key acts as the clinic, never as a staff member. A chart the clinic restricted to named staff, a deleted patient and another clinic's patient are never listed and answer
404 not_foundby id, the same as an id that never existed. - Not returned: draft notes (notes still being written), deleted lab orders, lab results the lab later replaced (the correction is returned) or withdrew, lab orders still in draft (never sent), body-composition scans, document files (names, types and dates only), uploads that never finished, bookings waiting for payment, deleted appointments, and text messages (SMS). Messages are the portal's secure messages only.
- Paged routes return rows oldest change first.
updated_sinceis not available on messages (a sent message has no change time) or problems (not paged). - Nothing marks a row that was deleted after you read it: there are no deletion records. To match deletions, re-read the full list from time to time and drop the rows it no longer returns.
- Every call is recorded at the clinic with the key, the route, the patient id and the row count. Example data below is fictional.
The clinic's patients, oldest change first, one page at a time. A deleted patient and a chart the clinic has restricted are never listed. Needs charts:read. Read-only.
Parameters: limit (optional, 1 to 100, default 50; above 100 is 400 invalid_request), cursor (optional, the previous page's next_cursor), updated_since (optional, YYYY-MM-DD or an ISO 8601 date and time with a time zone: only rows created or changed since then). Any other parameter is 400 invalid_request.
{"data": [{"id": "3f6b2a9e-1c4d-4e8a-9b7f-2d5c8e1a4b60", "first_name": "Avery", "last_name": "Sample", "date_of_birth": "1984-03-12", "sex": "female", "email": "avery.sample@example.com", "phone": "+15555550123", "status": "active", "created_at": "2026-02-04T15:20:00.000Z", "updated_at": "2026-11-20T15:04:05.123Z"}], "next_cursor": "eyJ0IjoiMjAyNi0xMS0yMFQxNTowNDowNS4xMjM0NTZaIiwiaSI6IjNmNmIyYTllLTFjNGQtNGU4YS05YjdmLTJkNWM4ZTFhNGI2MCJ9"}
GET /api/v1/patients/{id}
One patient's demographics. Needs charts:read. Read-only.
No query parameters; any is 400 invalid_request.
{"data": {"id": "3f6b2a9e-1c4d-4e8a-9b7f-2d5c8e1a4b60", "first_name": "Avery", "last_name": "Sample", "date_of_birth": "1984-03-12", "sex": "female", "email": "avery.sample@example.com", "phone": "+15555550123", "status": "active", "created_at": "2026-02-04T15:20:00.000Z", "updated_at": "2026-11-20T15:04:05.123Z"}, "next_cursor": null}
GET /api/v1/patients/{id}/notes
Signed and amended chart notes, and notes the clinic brought over from its previous EHR, without their text; drafts and notes still being written are never returned. status tells them apart: signed, amended or imported_from_prior_ehr. An imported note has no Moonshot signature (signed_at is null); source_ehr_name, original_signed_at and original_signed_by give the signature the previous EHR recorded, when it had one. Fetch one note for its text. Needs charts:read. Read-only.
Parameters: limit (optional, 1 to 100, default 50; above 100 is 400 invalid_request), cursor (optional, the previous page's next_cursor), updated_since (optional, YYYY-MM-DD or an ISO 8601 date and time with a time zone: only rows created or changed since then). Any other parameter is 400 invalid_request.
{"data": [{"id": "0c1d2e3f-4a5b-4c6d-8e7f-9a0b1c2d3e4f", "visit_date": "2026-11-18", "visit_type": "follow_up", "status": "signed", "is_administrative": false, "provider_name": "Dr. Riley Example", "signed_by_name": "Dr. Riley Example", "signed_at": "2026-11-18T17:42:10.000Z", "source_ehr_name": null, "original_signed_at": null, "original_signed_by": null, "cpt_codes": ["99214"], "icd_codes": ["E55.9"], "created_at": "2026-11-18T16:05:00.000Z", "updated_at": "2026-11-18T17:42:10.000Z"}], "next_cursor": "eyJ0IjoiMjAyNi0xMS0yMFQxNTowNDowNS4xMjM0NTZaIiwiaSI6IjNmNmIyYTllLTFjNGQtNGU4YS05YjdmLTJkNWM4ZTFhNGI2MCJ9"}
GET /api/v1/patients/{id}/notes/{note_id}
One signed, amended or imported note with its text by section and its addenda, as the chart shows it; an imported note's text is under sections.imported_note.content. A draft, or a note of a different patient, answers 404. Needs charts:read. Read-only.
No query parameters; any is 400 invalid_request.
{"data": {"id": "0c1d2e3f-4a5b-4c6d-8e7f-9a0b1c2d3e4f", "visit_date": "2026-11-18", "visit_type": "follow_up", "status": "signed", "is_administrative": false, "provider_name": "Dr. Riley Example", "signed_by_name": "Dr. Riley Example", "signed_at": "2026-11-18T17:42:10.000Z", "source_ehr_name": null, "original_signed_at": null, "original_signed_by": null, "cpt_codes": ["99214"], "icd_codes": ["E55.9"], "created_at": "2026-11-18T16:05:00.000Z", "updated_at": "2026-11-18T17:42:10.000Z", "appointment_id": null, "sections": {"assessment": "Vitamin D low at 18 ng/mL.", "plan": "Start D3 2000 IU daily; recheck in 12 weeks."}, "addenda": []}, "next_cursor": null}
GET /api/v1/patients/{id}/medications
Current and past medications and supplements. patient_reported: true marks an entry the patient typed on an intake form that the clinic has not confirmed yet. Needs charts:read. Read-only.
Parameters: limit (optional, 1 to 100, default 50; above 100 is 400 invalid_request), cursor (optional, the previous page's next_cursor), updated_since (optional, YYYY-MM-DD or an ISO 8601 date and time with a time zone: only rows created or changed since then). Any other parameter is 400 invalid_request.
{"data": [{"id": "5a6b7c8d-9e0f-4a1b-8c2d-3e4f5a6b7c8d", "name": "Cholecalciferol", "dosage": "2000 IU", "frequency": "once daily", "route": "oral", "status": "active", "kind": "medication", "start_date": "2026-11-18", "end_date": null, "rxnorm_cui": "316965", "prescriber_name": "Dr. Riley Example", "patient_reported": false, "created_at": "2026-11-18T17:40:00.000Z", "updated_at": "2026-11-18T17:40:00.000Z"}], "next_cursor": "eyJ0IjoiMjAyNi0xMS0yMFQxNTowNDowNS4xMjM0NTZaIiwiaSI6IjNmNmIyYTllLTFjNGQtNGU4YS05YjdmLTJkNWM4ZTFhNGI2MCJ9"}
GET /api/v1/patients/{id}/allergies
Allergies, active and inactive. patient_reported as on medications. Needs charts:read. Read-only.
Parameters: limit (optional, 1 to 100, default 50; above 100 is 400 invalid_request), cursor (optional, the previous page's next_cursor), updated_since (optional, YYYY-MM-DD or an ISO 8601 date and time with a time zone: only rows created or changed since then). Any other parameter is 400 invalid_request.
{"data": [{"id": "6b7c8d9e-0f1a-4b2c-9d3e-4f5a6b7c8d9e", "allergen": "Penicillin", "allergy_type": "drug", "severity": "moderate", "reaction": "Hives", "onset_date": null, "status": "active", "patient_reported": true, "notes": null, "created_at": "2026-02-04T15:30:00.000Z", "updated_at": "2026-02-04T15:30:00.000Z"}], "next_cursor": "eyJ0IjoiMjAyNi0xMS0yMFQxNTowNDowNS4xMjM0NTZaIiwiaSI6IjNmNmIyYTllLTFjNGQtNGU4YS05YjdmLTJkNWM4ZTFhNGI2MCJ9"}
GET /api/v1/patients/{id}/problems
The problem list, active and resolved, as the chart shows it. Not paginated and no updated_since: the list carries no per-entry change time. Needs charts:read. Read-only.
No query parameters; any is 400 invalid_request.
{"data": [{"id": "7c8d9e0f-1a2b-4c3d-8e4f-5a6b7c8d9e0f", "name": "Vitamin D deficiency", "icd10_code": "E55.9", "snomed_code": null, "status": "active", "severity": null, "onset_date": "2026-11-18", "resolved_date": null, "source": "chart", "review_status": null}], "next_cursor": null}
GET /api/v1/patients/{id}/labs
Lab orders, pending ones included, each with its results: value, unit, reference range, flag and dates. A deleted order, an order still in draft and a result the lab withdrew are never returned; result_status says whether a result is final or preliminary. updated_since matches an order whose own row changed. Needs charts:read. Read-only.
Parameters: limit (optional, 1 to 100, default 50; above 100 is 400 invalid_request), cursor (optional, the previous page's next_cursor), updated_since (optional, YYYY-MM-DD or an ISO 8601 date and time with a time zone: only rows created or changed since then). Any other parameter is 400 invalid_request.
{"data": [{"id": "8d9e0f1a-2b3c-4d4e-9f5a-6b7c8d9e0f1a", "order_date": "2026-11-10", "collection_date": "2026-11-11", "status": "released", "released_at": "2026-11-13T14:00:00.000Z", "lab_reference_id": "EX123456", "created_at": "2026-11-10T16:00:00.000Z", "updated_at": "2026-11-13T14:00:00.000Z", "results": [{"id": "9e0f1a2b-3c4d-4e5f-8a6b-7c8d9e0f1a2b", "test_name": "Vitamin D, 25-Hydroxy", "panel": "Vitamin D, 25-Hydroxy", "specimen": null, "value": "18", "value_numeric": 18, "unit": "ng/mL", "reference_range": "30-100", "flag": "low", "result_status": "final", "category": "vitamins", "updated_at": "2026-11-13T14:00:00.000Z"}]}], "next_cursor": "eyJ0IjoiMjAyNi0xMS0yMFQxNTowNDowNS4xMjM0NTZaIiwiaSI6IjNmNmIyYTllLTFjNGQtNGU4YS05YjdmLTJkNWM4ZTFhNGI2MCJ9"}
GET /api/v1/patients/{id}/vitals
Vitals as recorded. Body-composition scans are not included. Needs charts:read. Read-only.
Parameters: limit (optional, 1 to 100, default 50; above 100 is 400 invalid_request), cursor (optional, the previous page's next_cursor), updated_since (optional, YYYY-MM-DD or an ISO 8601 date and time with a time zone: only rows created or changed since then). Any other parameter is 400 invalid_request.
{"data": [{"id": "a0f1a2b3-4c5d-4e6f-9a7b-8c9d0e1f2a3b", "recorded_at": "2026-11-18T16:10:00.000Z", "height_inches": 66, "weight_lbs": 152.4, "blood_pressure_systolic": 118, "blood_pressure_diastolic": 76, "heart_rate": 64, "temperature_f": 98.2, "oxygen_saturation": 99, "lean_mass_lbs": null, "fat_mass_lbs": null, "waist_inches": null, "hip_inches": null, "chest_inches": null, "body_fat_percent": null, "lmp_date": null, "notes": null, "created_at": "2026-11-18T16:10:00.000Z", "updated_at": "2026-11-18T16:10:00.000Z"}], "next_cursor": "eyJ0IjoiMjAyNi0xMS0yMFQxNTowNDowNS4xMjM0NTZaIiwiaSI6IjNmNmIyYTllLTFjNGQtNGU4YS05YjdmLTJkNWM4ZTFhNGI2MCJ9"}
GET /api/v1/patients/{id}/appointments
Past and upcoming appointments, including cancelled and no-show ones; a booking still waiting for its payment is not returned. Needs appointments:read. Read-only.
Parameters: limit (optional, 1 to 100, default 50; above 100 is 400 invalid_request), cursor (optional, the previous page's next_cursor), updated_since (optional, YYYY-MM-DD or an ISO 8601 date and time with a time zone: only rows created or changed since then). Any other parameter is 400 invalid_request.
{"data": [{"id": "b1a2b3c4-5d6e-4f7a-8b8c-9d0e1f2a3b4c", "start_at": "2026-12-09T15:00:00.000Z", "end_at": "2026-12-09T15:30:00.000Z", "status": "scheduled", "appointment_type_id": "c2b3c4d5-6e7f-4a8b-9c9d-0e1f2a3b4c5d", "appointment_type": "Follow-up visit", "provider_id": "d3c4d5e6-7f8a-4b9c-8d0e-1f2a3b4c5d6e", "provider_name": "Dr. Riley Example", "created_at": "2026-11-18T17:45:00.000Z", "updated_at": "2026-11-18T17:45:00.000Z"}], "next_cursor": "eyJ0IjoiMjAyNi0xMS0yMFQxNTowNDowNS4xMjM0NTZaIiwiaSI6IjNmNmIyYTllLTFjNGQtNGU4YS05YjdmLTJkNWM4ZTFhNGI2MCJ9"}
GET /api/v1/patients/{id}/messages
Secure messages between the patient and the clinic in the patient portal, oldest first. Text messages (SMS) are not returned. No updated_since: a message has no change time once sent. Needs messages:read. Read-only.
Parameters: limit (optional, 1 to 100, default 50; above 100 is 400 invalid_request), cursor (optional, the previous page's next_cursor). Any other parameter is 400 invalid_request.
{"data": [{"id": "e4d5e6f7-8a9b-4c0d-9e1f-2a3b4c5d6e7f", "thread_id": "e4d5e6f7-8a9b-4c0d-9e1f-2a3b4c5d6e7f", "direction": "inbound", "sender_type": "patient", "automatic_reply": false, "subject": "Question about my vitamin D", "body": "Should I take it with food?", "read_at": "2026-11-19T14:02:00.000Z", "created_at": "2026-11-19T13:55:00.000Z"}], "next_cursor": "eyJ0IjoiMjAyNi0xMS0yMFQxNTowNDowNS4xMjM0NTZaIiwiaSI6IjNmNmIyYTllLTFjNGQtNGU4YS05YjdmLTJkNWM4ZTFhNGI2MCJ9"}
GET /api/v1/patients/{id}/documents
The patient's documents: id, name, type and dates only. The files cannot be downloaded through this API; an upload that never finished is not listed. Needs charts:read. Read-only.
Parameters: limit (optional, 1 to 100, default 50; above 100 is 400 invalid_request), cursor (optional, the previous page's next_cursor), updated_since (optional, YYYY-MM-DD or an ISO 8601 date and time with a time zone: only rows created or changed since then). Any other parameter is 400 invalid_request.
{"data": [{"id": "f5e6f7a8-9b0c-4d1e-8f2a-3b4c5d6e7f8a", "name": "outside-lab-results.pdf", "type": "lab_results", "uploaded_at": "2026-11-05T18:20:00.000Z", "updated_at": "2026-11-05T18:20:00.000Z"}], "next_cursor": "eyJ0IjoiMjAyNi0xMS0yMFQxNTowNDowNS4xMjM0NTZaIiwiaSI6IjNmNmIyYTllLTFjNGQtNGU4YS05YjdmLTJkNWM4ZTFhNGI2MCJ9"}
Writing
A new patient chart is made at once, and its header says it was created through the API, with the key's name. The other writes arrive for the clinic's staff to accept: a draft note waits for a clinician to review and sign it, a file waits in the chart for someone to review it, and a task waits in the clinic's unassigned pool. Nothing written here is signed, sent to the patient, prescribed, booked or charged. A person does each of those in the EHR.
- Server to server, with a key that has the permission named on each route:
patients:write,documents:write,tasks:writeornotes:write. Only the clinic's owner can create such a key, with the same confirmation as the chart reads; a key that only reads charts gets403 insufficient_scopeon every write. - Body: JSON with
Content-Type: application/json. Every route takes only the fields listed; any other field is400 invalid_requestnaming it. Text is stored as plain text, never as HTML. Text containing invisible characters (text-direction marks, zero-width characters, soft hyphens, variation selectors, tag characters, Hangul fillers, line or paragraph separators, private-use or unassigned code points), or a delimiter token such as<<<NAME>>>or<|im_start|>, is400 invalid_requestnaming the field. Idempotency-Key(optional, 1 to 255 visible characters, per key): the same key and body within 24 hours answer201with the same response the first call got, and nothing new is made. A replay never shows changes the clinic's staff made since. The same key with a different body, or while the first call is still running, is409 idempotency_conflict. Send one on every write you might retry.- A patient id is the lowercase id this API returns. Another clinic's patient, a deleted patient, a chart the clinic restricted to named staff and any other spelling of an id answer
404 not_found, as on the reads. - Where the key's name shows: a patient chart shows "Created via API" and the key's name in its header; a file, a task and a draft note show "API key: <name>" as who added them, and a draft note's sections keep that mark until a person edits them. Every call made with a valid key is recorded at the clinic with the key, the route and the patient id, including the first call refused for the key's rate limit in each limit window (later refusals in that window are not recorded one by one), a different clinic in
X-Tenant-Slug, a missing permission or a body that is not JSON. A call with no key or an invalid key is refused before any clinic is known, so it is not recorded at a clinic. Until the clinic's business associate agreement with Moonshot EHR is in place the writes answer403 phi_access_disabled. - There is no route to change or delete what you wrote. To correct it, ask the clinic.
POST /api/v1/patients
Creates a patient chart at once, with the same checks as a chart the clinic's staff add, including the fields the clinic requires. The chart's header says "Created via API" with the key's name. Needs patients:write. Fields: first_name, last_name and date_of_birth (YYYY-MM-DD) (required), middle_name, preferred_name, sex (male, female or other), email, phone, address_street, address_line2, address_city, address_state, address_zip, referral_source (up to 50 characters; some clinics require it), referral_detail.
curl -s https://api.moonshotehr.com/api/v1/patients -H 'Authorization: Bearer <key>' \
-H 'Content-Type: application/json' -H 'Idempotency-Key: intake-20261204-0417' \
-d '{ "first_name": "Jordan", "last_name": "Sample", "date_of_birth": "1979-08-21", "sex": "male", "email": "jordan.sample@example.com", "phone": "+15555550188" }'
{"data": {"id": "7b2e4c1a-9d3f-4e6b-8a5c-1f0e2d3c4b5a", "first_name": "Jordan", "last_name": "Sample", "date_of_birth": "1979-08-21", "sex": "male", "email": "jordan.sample@example.com", "phone": "+15555550188", "status": "prospect", "created_at": "2026-12-04T15:04:05.000Z", "updated_at": "2026-12-04T15:04:05.000Z"}, "next_cursor": null}
- A person who already has a chart at the clinic is
409 duplicate_patient, and no chart is created: the same first name, last name and date of birth, or the same name and email or phone on a chart that has no date of birth. An email address alone is not a match: family members may share one. The answer is the same whichever rule matched (the clinic's record of the call notes which one). A409 duplicate_patienttherefore confirms that a person matching those details already has a chart at this clinic. If the key also hascharts:read, the error carriesexisting_patient_idwhen that chart is one the key may read; otherwise it says nothing more about the other chart. - Daily ceilings, per key, over the last 24 hours: at most 500 patients created, and at most 200
409 duplicate_patientanswers. Past either, creates answer429 rate_limitedwithRetry-Afteruntil the oldest falls out of the window. A retry of a create that already succeeded is still answered. A roster re-sync that sends people who already have charts gets a duplicate answer for each, and each counts toward the 200: send every create with anIdempotency-Key(for example your own record id) so a retry replays the first answer instead of asking again, and send only people new since the last sync. - A field the clinic requires that is missing, or a value the chart refuses, is
400 invalid_requestnaming it.
POST /api/v1/patients/{id}/documents
Adds a file to the patient's chart, waiting for review: it is not shared with the patient, and an open review task for it lands in the clinic's unassigned task pool. Needs documents:write. Fields: file_name (required), content_type (required: PDF, an image, Word, Excel, text or CSV), content_base64 (required, the file as standard base64, at most 5 MB once decoded), document_type (optional: other, the default, lab_result, imaging, referral, consent, outside_records, intake_form, insurance_card, body_composition or letter), label (optional, up to 200 characters).
curl -s https://api.moonshotehr.com/api/v1/patients/3f6b2a9e-1c4d-4e8a-9b7f-2d5c8e1a4b60/documents \
-H 'Authorization: Bearer <key>' -H 'Content-Type: application/json' -H 'Idempotency-Key: fax-88213' \
-d '{ "file_name": "cardiology-consult.pdf", "content_type": "application/pdf", "document_type": "outside_records", "content_base64": "JVBERi0xLjcK..." }'
{"data": {"id": "c4d5e6f7-0a1b-4c2d-8e3f-4a5b6c7d8e9f", "patient_id": "3f6b2a9e-1c4d-4e8a-9b7f-2d5c8e1a4b60", "file_name": "cardiology-consult.pdf", "label": null, "content_type": "application/pdf", "document_type": "outside_records", "size_bytes": 182344, "review_status": "pending_review", "shared_with_patient": false, "created_at": "2026-12-04T15:06:11.000Z"}, "next_cursor": null}
POST /api/v1/patients/{id}/tasks
Creates a staff task on the patient's chart, unassigned: it lands in the clinic's task pool for someone to pick up, and nobody is notified. Needs tasks:write. Fields: title (required, up to 200 characters), description (optional, up to 4,000), due_date (optional, YYYY-MM-DD).
curl -s https://api.moonshotehr.com/api/v1/patients/3f6b2a9e-1c4d-4e8a-9b7f-2d5c8e1a4b60/tasks \
-H 'Authorization: Bearer <key>' -H 'Content-Type: application/json' -H 'Idempotency-Key: followup-55102' \
-d '{ "title": "Call to schedule the 12-week vitamin D recheck", "due_date": "2026-12-11" }'
{"data": {"id": "d9e0f1a2-3b4c-4d5e-9f6a-7b8c9d0e1f2a", "patient_id": "3f6b2a9e-1c4d-4e8a-9b7f-2d5c8e1a4b60", "title": "Call to schedule the 12-week vitamin D recheck", "description": null, "due_date": "2026-12-11", "status": "new", "assigned_to": null, "created_at": "2026-12-04T15:08:40.000Z"}, "next_cursor": null}
POST /api/v1/patients/{id}/notes
Creates an unsigned draft note on the patient's chart, with no provider. A clinician opens it in the EHR, edits it and signs it as themselves; no route here signs a note, and the draft is never shared with the patient. Needs notes:write. Fields: text (required, up to 20,000 characters), visit_date (optional, YYYY-MM-DD, the clinic's today by default), visit_type (optional, a label of at most 4 words and 40 characters using letters, digits, spaces and - / & ( ) ', such as Remote monitoring; anything else is 400 invalid_request).
curl -s https://api.moonshotehr.com/api/v1/patients/3f6b2a9e-1c4d-4e8a-9b7f-2d5c8e1a4b60/notes \
-H 'Authorization: Bearer <key>' -H 'Content-Type: application/json' -H 'Idempotency-Key: remote-monitoring-2026-12-04' \
-d '{ "text": "Home blood pressure, 7-day average 128/82 (14 readings). No readings above 150/95.", "visit_type": "Remote monitoring" }'
{"data": {"id": "e1f2a3b4-5c6d-4e7f-8a9b-0c1d2e3f4a5b", "patient_id": "3f6b2a9e-1c4d-4e8a-9b7f-2d5c8e1a4b60", "status": "draft", "visit_date": "2026-12-04", "visit_type": "Remote monitoring", "text": "Home blood pressure, 7-day average 128/82 (14 readings). No readings above 150/95.", "created_at": "2026-12-04T15:10:02.000Z"}, "next_cursor": null}
The draft is not returned by the chart reads (they return signed notes only) until a clinician signs it.
Limits
Per visitor IP address, per minute, counted separately for each route and separately from the clinic's own booking page: catalog 30, availability 60, summary 20. Keyed routes count per API key instead, per minute: key check 60, create lead 60, update lead 60, lead status 120, lead report 10, patient list 60, patient 120, notes 120, one note 120, medications 120, allergies 120, problems 120, labs 120, vitals 120, appointments 120, messages 120, documents 120, create patient 30, add file 10, create task 30, create draft note 30. A key's own lower limit, when the clinic set one, applies to the writes; a higher one does not raise them. Exactly that many calls succeed; the next gets 429 rate_limited with Retry-After (seconds).
Error codes
| Code | Status | Meaning |
|---|---|---|
invalid_request | 400 | A missing, unknown or malformed parameter (for example a chart limit above 100), or a service that cannot be booked online. |
unauthorized | 401 | Keyed route: the API key is missing, malformed, unknown, expired or revoked. |
online_booking_off | 403 | The clinic takes appointment requests, not online booking. |
insufficient_scope | 403 | Keyed route: the API key does not have the permission this route needs. |
tenant_mismatch | 403 | Keyed route: X-Tenant-Slug names a different clinic than the API key. |
phi_access_disabled | 403 | Lead routes, the lead report and the chart reads and writes: the clinic's business associate agreement with Moonshot EHR is not in place yet. |
tenant_not_found | 404 | No clinic matches X-Tenant-Slug. |
not_found | 404 | No v1 route at this path, no lead with this id at the key's clinic, or (chart routes) no patient or signed note with this id that the key may read: another clinic's patient, a deleted patient and a restricted chart answer the same way. |
method_not_allowed | 405 | Wrong method; see the Allow header. |
idempotency_conflict | 409 | Create lead and the chart writes: the Idempotency-Key was used with a different body, or its first request is still running. |
duplicate_patient | 409 | Create patient: this person already has a chart at the clinic. No chart was created. |
payload_too_large | 413 | The request body is larger than 64 KB (the file upload: larger than a 5 MB file as base64). |
rate_limited | 429 | Over the limit; wait Retry-After seconds. |
not_implemented | 501 | A planned route that is not available yet. |
report_timeout | 503 | Lead report: the period took too long to count; ask for a shorter one after Retry-After seconds. |
internal_error | 500 | Our side; retry shortly and quote X-Request-Id. |
From the browser
Only from site addresses the clinic listed with us (see Embed and availability). Errors, including 429, are readable by those sites, and X-Request-Id and Retry-After are exposed to their JavaScript.
const res = await fetch(
'https://api.moonshotehr.com/api/v1/availability?appointment_type_id=<id>&date=2026-11-16',
{ headers: { 'X-Tenant-Slug': '<clinic>' } },
);
const body = await res.json();
if (!res.ok) throw new Error(body.error.code + ': ' + body.error.message);
for (const slot of body.data.slots) console.log(slot.time, slot.provider_name);
From a server:
curl -s https://api.moonshotehr.com/api/v1/catalog -H 'X-Tenant-Slug: <clinic>'
Coming in v1
Available now: the public routes (catalog, availability and availability summary), the secret key, the route that checks it, the lead routes (create, correct, read progress), the lead report, the chart reads (patients, notes, medications, allergies, problems, labs, vitals, appointments, portal messages and the document list), and the chart writes (a patient, a file for review, an unassigned task, an unsigned draft note). Planned next, on that same key (server to server only): handing a visitor off to the hosted booking, join or intake page, and reading event delivery history. Those routes are not available yet.