Filtering & Date Ranges
This page explains how date filtering and the mode parameter work across all Dental API endpoints. Understanding these concepts is essential for building efficient sync workflows and delta queries.
The mode parameter
The mode parameter controls how date filters are interpreted. It appears on most list endpoints.
0 | Business Date Mode | Filters by the business/transaction date (e.g., appointment date, treatment date). This is the default. |
1 | Modification Timestamp Mode | Filters by when records were created or last modified. Use this for sync/delta queries to capture all changes since your last sync. |
When to use each mode
Mode 0 (Business Date). Use when:
- Generating reports for a specific date range
- Displaying appointments for a calendar view
- Fetching treatments performed during a period
Mode 1 (Modification Timestamp). Use when:
- Syncing data to an external system
- Detecting changes since your last API call
- Building incremental backup workflows
Example: business date vs modification timestamp
# Mode 0: Get appointments scheduled for January 2026
curl "https://api-uat.dental4web.com.au/api/v1/appointments?from_date=2026-01-01&to_date=2026-01-31&mode=0"
# Mode 1: Get all appointments created or modified since January 1st
curl "https://api-uat.dental4web.com.au/api/v1/appointments?from_date=2026-01-01&to_date=2026-01-31&mode=1" The first request returns appointments scheduled in January. The second returns appointments that were created or updated in January, including future appointments booked during that period.
Automatic date range defaults
When querying list endpoints without a specific patient_id, the API applies automatic date range defaults to prevent unbounded queries. Each endpoint has its own default range optimised for typical use cases.
These list endpoints need at least one query parameter other than page, per_page, mode, include and include_deleted: GET Appointments, GET Cancelled Appointments, GET Treatments, GET Treatment Plans, GET Clinical Notes, GET Recalls and GET Patients. A request with none returns 400 with the message At least one query parameter is required. Where you want the default range and have no other filter to send, use practitioner_id=-1, which matches every practitioner. A from_date or to_date on its own also satisfies the rule.
Default ranges by endpoint
| When | 90 days | 30 | 60 |
| When | 60 days | 60 | 0 |
| When | 180 days | 180 | 0 |
| When | 90 days | 90 | 0 |
| When | 210 days | 30 | 180 |
| When | 12 months | 365 | 0 |
| When | 90 days | 90 | 0 |
| When NO | 90 days | 90 | 0 |
If you send only from_date, the range ends that many days later; if you send only to_date, it starts that many days earlier. The “Total Range” column gives the number of days.
GET Financials is not in this table because from_date is required. If you omit to_date and send no patient_id, the range ends 365 days after from_date. With a patient_id, an omitted to_date has no upper limit.
How defaults are applied
The API handles three scenarios when dates are omitted:
Scenario 1 (both NULL):
from_date = today − [Past Days]
to_date = today + [Future Days]
Scenario 2 (only from_date NULL):
from_date = to_date − [Total Range Days]
Scenario 3 (only to_date NULL):
to_date = from_date + [Total Range Days] Examples
# Appointments: No dates provided → defaults to 30 days past, 60 days future
# If today is 2026-02-13:
# from_date = 2026-01-14 (30 days ago)
# to_date = 2026-04-14 (60 days ahead)
curl "https://api-uat.dental4web.com.au/api/v1/appointments?practitioner_id=-1"
# Recalls: No dates provided → defaults to 30 days past, 180 days future
# If today is 2026-02-13:
# from_date = 2026-01-14 (30 days ago)
# to_date = 2026-08-12 (180 days ahead)
curl "https://api-uat.dental4web.com.au/api/v1/recalls?practitioner_id=-1" Patient endpoint
The /patients endpoint behaves differently to other list endpoints. If your request has no patient_id or patient_card AND no complete from_date/to_date window, the API auto-injects a 90-day recency window before executing the search. The injection is surfaced in metadata.patients_default_window_injected: true and a warnings[] entry: see ‘Patient endpoint row caps’ below. Note: at least one query parameter must still be supplied to reach this endpoint at all. A genuinely empty GET /patients (zero query parameters) returns 400 before this injection logic runs.
When date parameters are used without a patient_id, the following rules apply:
Scenario | Behaviour |
Both | A 90-day recency window is auto-injected. |
Only |
|
Only |
|
Both | No injection, no cap. The API respects your window verbatim. This is the only shape that bypasses the 10,000 cap on broad calls. |
Partial-bound calls (only one date supplied) and truly-no-filter calls take the SAME code path as recency-window injection: the missing end is auto-filled and the response is treated as bounded. The 10,000 broad-fanout cap fires in both cases. The ONLY shape that bypasses both the recency injection and the row cap is supplying both ends of a valid from_date + to_date window ≤ 370 days.
Patient endpoint row caps
In addition to the recency window injection, patient read endpoints have two layered row caps that protect against unbounded fan-out:
Broad-fanout cap | 10,000 rows | Any call NOT bounded by |
DOB-fanout cap | 1,000 rows |
|
Both caps are bypassed by a patient_id / patient_card lookup (point lookups). The broad cap is also bypassed by a valid both-bounds from_date + to_date window ≤ 370 days (the trusted sync-delta path). A single-ended date filter (only from_date OR only to_date) does NOT bypass the cap; the API auto-fills the missing end and treats it as an injected window. Garbage values (patient_id='abc', patient_card='ABCDEFGHIJKL', malformed dates) do NOT count as bounding; the cap still applies.
Unfiltered patient searches are also rate limited for cloud-hosted practices: more than 10 calls a minute for one organisation that have no patient_id, patient_card or complete from_date and to_date window of 370 days or less return 429 RP-4291 with a Retry-After header. Searches with one of those filters are not limited by this rule.
When a cap fires, the response includes metadata.patient_fanout_cap_applied: true and metadata.patient_fanout_cap_value: 10000 (broad) or 1000 (DOB), plus a warnings[] entry describing the action. The broad cap warning reads, for example: “Results limited to 10,000 rows because the search had no patient_id or patient_card and no date window of 370 days or less. Add one of those to remove the limit, or narrow the date window if the default window (last 90 days) still returns too many rows.” The date_of_birth cap warning reads: “Results limited to 1,000 rows because the search used date_of_birth without a patient_id or patient_card, which can match many patients. Add a patient_id or patient_card to remove the limit.” GET Patients Lite uses a shorter text for its 10,000 row cap: “Results limited to 10,000 rows because the search had no patient_id or patient_card. Add one of those to remove the limit.”
Detecting injection or capping in the response
When the window injector or either cap fires, the response carries these informational fields so callers can programmatically detect the bounded outcome:
| boolean | Always present; |
| int |
|
| boolean | Always present; |
| int |
|
| string | Present when window or cap fires, with a human-readable description and the resolved date values. |
Treat these as informational. The response data is correct but bounded; supply a wider explicit window or a unique identifier to bypass.
# Partial-bound on /patients (only from_date supplied)
# If today is 2026-06-05:
# from_date stays as supplied
# to_date auto-filled to today (2026-06-05)
# Response metadata:
# patients_default_window_injected: true
# patients_default_window_days: 90
# patient_fanout_cap_applied: true
# patient_fanout_cap_value: 10000
curl "https://api-uat.dental4web.com.au/api/v1/patients?from_date=2026-04-01"
# Partial-bound on /patients (only to_date supplied)
# from_date auto-filled to to_date - 90 days; counts as an injected window
curl "https://api-uat.dental4web.com.au/api/v1/patients?to_date=2026-06-05"
# Cap-bypass: both ends supplied, span ≤ 370 days
# No window injection, no row cap. Full result set paginated.
curl "https://api-uat.dental4web.com.au/api/v1/patients?from_date=2026-01-01&to_date=2026-06-05" Why defaults exist
Without defaults, a query like GET /appointments would attempt to return the entire appointment history, potentially millions of records. Defaults protect both API performance and your application from timeout errors.
Overriding defaults
Simply provide explicit date parameters to override:
# Uses defaults (30 days past, 60 days future)
curl "https://api-uat.dental4web.com.au/api/v1/appointments?practitioner_id=-1"
# Explicit range (full year)
curl "https://api-uat.dental4web.com.au/api/v1/appointments?from_date=2025-01-01&to_date=2025-12-31"
# Patient-specific (no date limits)
curl "https://api-uat.dental4web.com.au/api/v1/appointments?patient_id=12345" MWP imaging: date ranges
The MediaWeb PACS image search endpoint (GET /mwp/images) does not apply a default date range: both start_date and end_date are required. Omitting either one returns 400 with support_code: MWP_DATE_RANGE_REQUIRED.
The bulk endpoint (GET /mwp/images/patient/{patient_id}) works differently. start_date and end_date are optional and filter on the study date. If both are omitted, the last 12 months up to today are searched. If only start_date is supplied, the range ends 12 months later; if only end_date is supplied, it starts 12 months earlier. To retrieve a patient’s full history, supply an explicit range.
Cancelled appointments: special behaviour
The /appointments/cancelled endpoint has unique mode behaviour:
0 | Original appointment date (when it was scheduled for) |
1 | Cancellation date (when it was cancelled, not modification date) |
This is intentional: when syncing cancellations, you typically want to know which appointments were cancelled during a period, not when they were originally scheduled.
The endpoint’s mode parameter itself accepts any integer from 0 to 10, not just 0 and 1. Confirmed live: every value from 2 to 10 returns the same result set as mode=0, so 0 and 1 are the only two worth using.
# Get appointments originally scheduled for January that were cancelled
curl "https://api-uat.dental4web.com.au/api/v1/appointments/cancelled?from_date=2026-01-01&to_date=2026-01-31&mode=0"
# Get appointments cancelled during January (regardless of original date)
curl "https://api-uat.dental4web.com.au/api/v1/appointments/cancelled?from_date=2026-01-01&to_date=2026-01-31&mode=1" Endpoints supporting the mode parameter
| Appointment date | Modification timestamp |
| Original appointment date | Cancellation date |
| Treatment date | Modification timestamp |
| Plan date | Modification timestamp |
| Note date | Modification timestamp |
Note: GET /patients does not require (or accept) the mode parameter. If date values are provided in the request, the endpoint operates on the record’s last-modified timestamp without needing explicit declaration of mode=1.
Sync workflow best practices
The sync pattern differs between patient endpoints and other list endpoints. Patient reads have row caps (10,000 broad / 1,000 DOB) and filter on the record’s last-modified timestamp implicitly. Other list endpoints have no row caps for cloud-hosted practices (on-premise reads stop at 100,000 rows, with a warnings[] entry) and use the mode parameter to switch between business-date and modification-timestamp filtering.
When a cap fires or a recency window is auto-injected, the response carries a warnings[] entry and informational metadata.* fields: check these on every sync call.
Initial sync: non-patient endpoints
No row cap applies for cloud-hosted practices. For on-premise practices a single request returns at most 100,000 rows, so walk long histories in date windows (for example one year at a time). Use a wide explicit window with mode=0 (or omit mode) to walk full history by business date:
# Sync all appointments for the past 2 years
curl "https://api-uat.dental4web.com.au/api/v1/appointments?from_date=2024-06-05&to_date=2026-06-05"
# Sync all financial transactions for the past 5 years
curl "https://api-uat.dental4web.com.au/api/v1/financials?from_date=2021-06-05&to_date=2026-06-05"
# Sync all treatments performed in the past 3 years
curl "https://api-uat.dental4web.com.au/api/v1/treatments?from_date=2023-06-05&to_date=2026-06-05" Initial sync: patient endpoints
The 10,000 broad-fanout cap requires sync windows of ≤ 370 days. Walk back in 1-year increments until you reach your practice start date. Each call respects the cap-bypass condition (both bounds supplied AND span ≤ 370 days), so each window returns the complete patient set modified inside it.
# Walk patients back in 1-year windows. Each call returns the complete bounded set.
curl "https://api-uat.dental4web.com.au/api/v1/patients?from_date=2025-06-05&to_date=2026-06-05"
curl "https://api-uat.dental4web.com.au/api/v1/patients?from_date=2024-06-05&to_date=2025-06-05"
curl "https://api-uat.dental4web.com.au/api/v1/patients?from_date=2023-06-05&to_date=2024-06-05"
# ...continue back in 1-year increments until you reach your practice start date. Note: /patients automatically filters on the record’s last-modified timestamp whenever date parameters are supplied: no mode parameter is needed (or accepted). If metadata.patient_fanout_cap_applied: true appears and pagination.total_rows equals metadata.patient_fanout_cap_value, the result was cut short: narrow the window or supply patient_id / patient_card.
Delta sync: non-patient endpoints
Use mode=1 with the date of your last successful sync to capture every record created or modified since. Filters work on whole days: with mode=1, from_date and to_date match the date a record was created or last changed, so start each sync from the date of your last sync and skip records you have already processed (match on the record id and updated_date):
# Get all changes since yesterday
curl "https://api-uat.dental4web.com.au/api/v1/appointments?from_date=2026-06-04&to_date=2026-06-05&mode=1"
curl "https://api-uat.dental4web.com.au/api/v1/treatments?from_date=2026-06-04&to_date=2026-06-05&mode=1"
curl "https://api-uat.dental4web.com.au/api/v1/clinical-notes?from_date=2026-06-04&to_date=2026-06-05&mode=1" GET Financials has no mode parameter. For incremental sync, re-read a recent from_date to to_date window.
Delta sync: patient endpoints
No mode parameter: date values implicitly filter on the record’s last-modified timestamp. As long as the window is ≤ 370 days, the cap-bypass condition is satisfied:
# Get patients modified since last sync (modification timestamp is implicit)
curl "https://api-uat.dental4web.com.au/api/v1/patients?from_date=2026-06-04&to_date=2026-06-05" Handling pagination in syncs
Large result sets are paginated. Always loop until complete, and add a small delay between calls to avoid hitting the per-org rate limit (currently 60 requests per minute during peak hours, 120 off-peak):
import requests
import time
def sync_all_pages(endpoint, params, headers, delay=1.0):
params['page'] = 1
params['per_page'] = 100
all_records = []
while True:
response = requests.get(endpoint, params=params, headers=headers)
data = response.json()
if data.get('metadata', {}).get('patient_fanout_cap_applied'):
print("Warning: cap fired; consider narrowing the window.")
page_records = data.get('data', [])
all_records.extend(page_records)
pagination = data.get('pagination', {})
if len(page_records) < params['per_page'] or params['page'] >= pagination.get('total_pages', params['page']):
break
params['page'] += 1
time.sleep(delay)
return all_records On this page
- Filtering & Date Ranges