Poll for updates
The CollaborateMD API does not have a “webhook” feature where the API can notify you of updates made in the system.
Instead, you can poll the API periodically to retrieve the Patients or Appointments that were updated since your last check.
Read This First: Each Updated Record Is Returned Only Once
These endpoints are a queue, not a search. Each call will return up to 100 (configurable with the
response_count parameter) records that have been updated since your last call.
Once a record has been returned from the API, it is cleared from the database, so a given change is returned to you exactly once. Your next call to the API will return the next batch of records, which will not include any records that were returned in the previous batch (unless they were updated in the meantime).
Because of this design, you must design your polling strategy to be resilient to failures —
if a 200 OK response is received with data, at least try to log a record of the data you received
so that the records can be re-retrieved from the individual GET endpoints for the patient or appointment records.
The endpoints
Patient updates:
GET /v1/customer/{custno}/patient/updates/find/xmlGET /v1/customer/{custno}/patient/updates/find/hl7GET /v2/customer/{custno}/patient/updates/find/xml
Appointment updates:
GET /v1/customer/{custno}/appointment/updates/find/xmlGET /v1/customer/{custno}/appointment/updates/find/hl7
All require the Patient/Claim/Appointment permission. Prefer the v2 patient endpoint for new integrations.
The recommended polling pattern
- Call the endpoint with a
response_countyou can handle reliably in one call, maximum of 1,000. - Persist the whole response first, before doing anything else with it — to a queue, a table, or a file. This allows you to reprocess the records if an error occurs during your processing.
- Then process from your own store, at your own pace, retrying individual failures there.
- Repeat. If the number of results equals your
response_count, you can call again straight away as there are probably more records available. Otherwise, wait for your normal polling time.
Choosing response_count
Ask for what you can durably store in a single request, and no more. A larger response_count clears
more flags per call, so a failure part-way through processing loses more. When unsure, smaller and more
frequent is the safer trade.
The maximum response_count is 1,000. The default, when you omit the parameter, is 100. Asking for more than the
maximum returns Status: TOO MANY ITEMS REQUESTED and does not clear any records.
Interval
The interval affects latency and load. We recommend polling based on when activity occurs. During active hours,
you may want to poll as often as every five to fifteen minutes. During inactive hours, most requests may return
nothing, and a longer interval like every one to two hours or more may be most effective.
Poll again immediately whenever the number of responses is equal to your response_count, since that means
more is waiting.
Response shape
Patient updates return a PatientUpdatesResponseXML: the standard Status and StatusMessage, plus
Patient— the full patient record, repeated once per updated patientAccountNumber— the patient’s account number
You receive the current state of every record that was touched, so treat each one as an upsert (insert or update) against your own store.
For the exact structure of the nested Patient object, see the operation in the
API reference — it is the same model the
create/update endpoints accept.
Checking the outcome
HTTP 200 does not mean success. Check the body’s Status:
Status |
Meaning | What to do |
|---|---|---|
SUCCESS |
Records returned, and their flags are now cleared | Persist, then process |
NOT FOUND |
The customer number is not valid | Fix the custno; do not retry unchanged |
TOO MANY ITEMS REQUESTED |
response_count exceeds the permitted maximum of 1000 |
Lower it and retry |
ERROR |
Server-side failure | Retry with backoff |
Note that an over-large response_count yields TOO MANY ITEMS REQUESTED, not INVALID CRITERIA. When
this happens, no records are returned and nothing is cleared. It is safe to retry.
An empty list with Status: SUCCESS means nothing has changed since your last poll.
See Reading responses for the convention in full.
Worked example
#!/usr/bin/env bash# Poll for patient updates, persisting the raw response BEFORE interpreting it.set -euo pipefail
CUSTNO="12345678"BASE_URL="https://webapi.example.com"SPOOL_DIR="./spool"
mkdir -p "$SPOOL_DIR"
# Credentials come from the environment, never from the script.: "${CMD_API_USER:?set CMD_API_USER}": "${CMD_API_SECRET:?set CMD_API_SECRET}"
stamp="$(date -u +%Y%m%dT%H%M%SZ)"spool_file="${SPOOL_DIR}/patient-updates-${stamp}.xml"
# Steps 1 and 2: fetch, and write the body straight to durable storage.curl --fail --silent --show-error \ --user "${CMD_API_USER}:${CMD_API_SECRET}" \ "${BASE_URL}/v1/customer/${CUSTNO}/patient/updates/find/xml?response_count=100" \ --output "${spool_file}"
# The records are cleared server-side now, but they are safe on disk. Only now interpret them.if ! grep -q "<Status>SUCCESS</Status>" "${spool_file}"; then echo "Poll did not succeed; keeping ${spool_file} for inspection." >&2 grep -o "<StatusMessage>[^<]*</StatusMessage>" "${spool_file}" >&2 || true exit 1fi
# Step 3: process from the spool file, not from the network response../import-patient-updates "${spool_file}"This script is intentional about the process:
- It always stores the response immediately. It never discards a response.
- The stored file is the recovery mechanism. It doesn’t re-request after a processing failure.
Note what the script does not do: it never re-requests after a processing failure, and it never discards a response. The spool file is the recovery mechanism.
Related
- Reading responses — the
Statusconvention - Create and update patients — the same
Patientmodel, in the other direction - Error reference — what individual
StatusMessagevalues mean

