Authentication tiers
Reads and stored-query execution are open. Writes need a write key;
definition management, inline resources and admin operations need the admin key.
Keys travel in headers (a Bearer authorization header also works):
| Header | Tier | Grants |
|---|---|---|
X-Write-Key | write | resource writes, POST /Bundle, /admin/flush |
X-Admin-Key | admin | everything, including key management and inline queryResource/viewResource |
401 OperationOutcome — the response never reveals which tier a guess nearly hit. Runners below that need a key show a key field (kept in this browser's localStorage only).Discovery
The interactive OpenAPI docs list every route mechanically. This page is the semantic guide.
Creating resources
POST /{resourceType} with a FHIR resource body. The server assigns a monotonic version id, returned as ETag (W/"<seq>") and mirrored in meta.versionId; Location names the new resource. Ids are optional — omit id and the server mints one.
const created = await fetch(`${location.origin}/Slot`, {
method: "POST",
headers: { "Content-Type": "application/fhir+json", "X-Write-Key": WRITE_KEY },
body: JSON.stringify({
resourceType: "Slot", id: "walkin-001", status: "free",
start: "2027-03-05T09:00:00Z", end: "2027-03-05T09:30:00Z",
schedule: { reference: "Schedule/10" },
}),
});
console.log(created.status, created.headers.get("ETag")); // 201 W/"42"import requests
created = requests.post(f"{BASE}/Slot", json=slot, headers={"X-Write-Key": WRITE_KEY})
print(created.status_code, created.headers["ETag"])curl -X POST "$BASE/Slot" -H "X-Write-Key: $WRITE_KEY" \ -H "Content-Type: application/fhir+json" -d @slot.json
Conditional create: add If-None-Exist: <search> to create only when no match exists (200 if one match, 412 if many). Re-posting an existing id is a 400 — use PUT to update.
Read, search, history
GET /{type}/{id} returns the current version. The runner reads a seeded slot; if you ran the upsert above, GET /Slot/docs-demo-slot returns your own write the same way.
| Search parameter | Meaning |
|---|---|
_id | one or more resource ids |
identifier | system|value or bare value |
_count, _offset | paging (page links ride Link headers) |
Anything else is a 400 listing the supported set — structured filtering belongs to the ViewDefinitions and SQL queries below. Every read has a twin versioned read: GET /{type}/{id}/_history/{versionId} returns that exact version.
Update & delete
PUT /{type}/{id} creates-or-updates. Send If-Match: W/"<seq>" for optimistic locking — a stale version is 412. DELETE /{type}/{id} tombstones: reads answer 410 Gone, _history keeps every version forever.
await fetch(`${BASE}/Slot/walkin-001`, {
method: "PUT",
headers: { "Content-Type": "application/fhir+json", "X-Write-Key": WRITE_KEY,
"If-Match": created.headers.get("ETag") },
body: JSON.stringify({ ...slot, status: "busy" }),
});
await fetch(`${BASE}/Slot/walkin-001`, { method: "DELETE", headers: { "X-Write-Key": WRITE_KEY } });requests.put(f"{BASE}/Slot/walkin-001", json={**slot, "status": "busy"},
headers={"X-Write-Key": WRITE_KEY, "If-Match": created.headers["ETag"]})
requests.delete(f"{BASE}/Slot/walkin-001", headers={"X-Write-Key": WRITE_KEY})curl -X PUT "$BASE/Slot/walkin-001" -H "X-Write-Key: $WRITE_KEY" \ -H 'If-Match: W/"42"' -H "Content-Type: application/fhir+json" -d @slot.json curl -X DELETE -H "X-Write-Key: $WRITE_KEY" "$BASE/Slot/walkin-001"
Transaction bundles
POST /Bundle with type: transaction|batch applies every entry in order — creates, updates, deletes — and returns one response Bundle with per-entry statuses, ETags and locations.
ViewDefinition $run
The synchronous view evaluator. Instance level runs a stored view (open access):
Operation parameters — _format (json|ndjson|csv|parquet, default ndjson), _limit, header (CSV on/off) — may travel in the query string or in a Parameters body, never both (that is a 400). A source parameter can name an alternate data source when the server was started with sources configured. Type-level POST /ViewDefinition/$run additionally accepts an inline viewResource — admin tier, because it is author-supplied evaluation.
SQL-on-FHIR $sqlquery-run
Runs a stored SQLQuery Library with bound parameters. Runtime values arrive as a nested Parameters resource; declared types are coerced (a date parameter gets a real DATE, not a string):
Three levels: /Library/{id}/$sqlquery-run (stored, open), /Library/$sqlquery-run and /$sqlquery-run with a queryReference or inline queryResource (admin tier). Dependencies referenced by relatedArtifact labels are materialized as views first; cycles are detected and refused.
Definition registry
GET /ViewDefinition and GET /Library list registered definitions; GET /{type}/{id} reads one. Registering or replacing a definition is POST /{type} — admin tier, because definitions drive evaluation. Served definitions are versioned into the dataset on every flush and restored on restart.
Bulk publish feed
Every write is published to an append-only parquet dataset; GET /$bulk-publish serves the Bulk-Data-shaped manifest pointing at the parts. On a public server with a private dataset the part URLs need credentials — the manifest is the map, access is the token.
Flushes are automatic (interval or row-count); POST /admin/flush (write tier) forces one synchronously. Rows keep their _seq across retries and restarts — a version id is never reused.
Admin & key management
POST /admin/key (admin tier) manages the labeled write-key set at runtime — no restart:
curl -X POST "$BASE/admin/key" -H "X-Admin-Key: $ADMIN_KEY" \
-H "Content-Type: application/json" \
-d '{"action":"add","label":"ci","key":"<new-key>"}'
# {"action":"add","label":"ci","write_keys":["__env__","ci"]}
# revoke (never the last one):
curl -X POST "$BASE/admin/key" -H "X-Admin-Key: $ADMIN_KEY" \
-d '{"action":"revoke","label":"ci"}'
Rotation is two-step and zero-downtime: add the new key, switch clients, revoke the old. Runtime-added keys persist with the dataset and survive restarts; the environment bootstrap key (__env__) is the break-glass fallback. The admin key itself is environment-only by design — rotating it is a secret change plus a restart.
Limits & errors
| Situation | Response |
|---|---|
| Write/admin call without a valid key | 401 OperationOutcome |
| Unknown or mistyped operation parameter | 400 naming the parameter |
| Parameter in both body and query string | 400 (ambiguous) |
| Unsupported search parameter | 400 listing the supported set |
POST an id that already exists | 400 — use PUT |
Stale If-Match on update | 412 |
| Read of a deleted resource | 410 Gone |
| Body over the server cap (default 10 MB) | 413 |
| Query over the time limit (default 30 s) | 408 — the query is interrupted |
| Too many requests queued | 503 busy — retry shortly |
Results are capped: an omitted _limit applies a server default (1,000 rows) and explicit limits are capped at the server maximum. Errors are always FHIR OperationOutcome resources.
This API is powered by fhir4ds — open source, one pip install fhir4ds-v2[serve] away.
Machine-readable route listing: /openapi.json · interactive: /docs