API Reference
Base Configuration
Section titled “Base Configuration”- Base URL:
http://localhost:8888/fhir(host and port are configurable) - FHIR Version: R4 by default; R4B, R5 and R6 through
[fhir] version
Content Types
Section titled “Content Types”| Header | Values |
|---|---|
| Accept | application/fhir+json, application/json |
| Content-Type | application/fhir+json, application/json |
Supported Resources
Section titled “Supported Resources”OctoFHIR supports all standard FHIR R4 resource types. Common resources include:
- Clinical: Patient, Observation, Condition, Procedure, DiagnosticReport
- Administrative: Organization, Practitioner, Location, Encounter
- Financial: Claim, Coverage, ExplanationOfBenefit
- Workflow: Task, ServiceRequest, Appointment
RESTful API
Section titled “RESTful API”Metadata (CapabilityStatement)
Section titled “Metadata (CapabilityStatement)”GET /fhir/metadataReturns the server’s CapabilityStatement describing supported operations.
Create
Section titled “Create”POST /fhir/{resourceType}Content-Type: application/fhir+json
{resource body}Response: 201 Created with Location header
GET /fhir/{resourceType}/{id}Response: 200 OK with resource body
Update
Section titled “Update”PUT /fhir/{resourceType}/{id}Content-Type: application/fhir+jsonIf-Match: W/"{versionId}" # Optional, for conditional update
{resource body with id}Response: 200 OK with updated resource
Delete
Section titled “Delete”DELETE /fhir/{resourceType}/{id}Response: 204 No Content
Search
Section titled “Search”GET /fhir/{resourceType}?{parameters}POST /fhir/{resourceType}/_searchContent-Type: application/x-www-form-urlencoded
{parameters}Response: 200 OK with Bundle of type searchset
See Search Parameters for detailed search documentation. For index behavior and query planning guidance, see Search Indexing.
History
Section titled “History”# Instance historyGET /fhir/{resourceType}/{id}/_history
# Type historyGET /fhir/{resourceType}/_history
# System historyGET /fhir/_history
# Remove the history of a resource, or one version; never the current versionDELETE /fhir/{resourceType}/{id}/_historyDELETE /fhir/{resourceType}/{id}/_history/{versionId}Removing history needs an administrator. See FHIR R6.
Version Read
Section titled “Version Read”GET /fhir/{resourceType}/{id}/_history/{versionId}Bundle Operations
Section titled “Bundle Operations”Transaction
Section titled “Transaction”POST /fhirContent-Type: application/fhir+json
{ "resourceType": "Bundle", "type": "transaction", "entry": [...]}All-or-nothing execution. See Transactions for details.
POST /fhirContent-Type: application/fhir+json
{ "resourceType": "Bundle", "type": "batch", "entry": [...]}Independent execution of each entry.
Operations
Section titled “Operations”$validate
Section titled “$validate”POST /fhir/{resourceType}/$validatePOST /fhir/{resourceType}/{id}/$validateValidate a resource against profiles.
$expand (ValueSet)
Section titled “$expand (ValueSet)”GET /fhir/ValueSet/$expand?url={valuesetUrl}POST /fhir/ValueSet/$expandExpand a ValueSet. See Terminology for details.
$validate-code (ValueSet)
Section titled “$validate-code (ValueSet)”GET /fhir/ValueSet/$validate-code?url={valuesetUrl}&code={code}&system={system}POST /fhir/ValueSet/$validate-code$everything (Patient)
Section titled “$everything (Patient)”GET /fhir/Patient/{id}/$everythingReturns a Bundle with all resources related to the patient.
$summary (Patient)
Section titled “$summary (Patient)”GET /fhir/Patient/{id}/$summaryGET /fhir/Patient/$summary?identifier={identifier}An International Patient Summary document. See Patient Summary.
$fhirpath
Section titled “$fhirpath”Evaluates a FHIRPath expression, against a resource given inline or at {Type}/{id}/$fhirpath against
a stored one.
POST /fhir/$fhirpathContent-Type: application/fhir+json
{ "resourceType": "Parameters", "parameter": [ { "name": "expression", "valueString": "name.where(use = 'official').family" }, { "name": "resource", "resource": { "resourceType": "Patient" } }, { "name": "debug", "valueBoolean": true } ]}With debug the response also holds a debug trace in the format the FHIR Mapping Language IG proposes
for all evaluation languages: traceStatus, and a trace per event with its phase (enter, step,
exit), depth, position in the expression, the focus and the result. trace() adds a step with its
message, and the inside of where() and other functions is traced for each item. A failing expression
then answers with its trace, status stopped, and an outcome. A trace stops at 10,000 events or about
4 MiB of values, and evaluation goes on with status truncated.
$expunge
Section titled “$expunge”POST /fhir/{type}/{id}/$expungeAuthorization: Bearer {token}Content-Type: application/fhir+json
{ "resourceType": "Parameters", "parameter": [{"name": "dryRun", "valueBoolean": true}]}Permanently removes one resource: its live row and every stored version. A normal DELETE keeps
history; $expunge is for data that must not stay, such as a record created for the wrong person.
It works on one instance and does not follow references.
Who may call it. Only administrators: a user with the role admin or superuser, or a token
holding a system/* scope with delete permission and no filter, such as system/*.cruds. Anyone else
gets 403. On a server with auth.policy.anonymous_access enabled, a call without credentials is
allowed too.
dryRun. With dryRun set to true, in the body or the query, nothing is removed and the
response says what would go. A GET is always a dry run. A POST without dryRun removes the
resource.
The response is a Parameters resource:
{ "resourceType": "Parameters", "parameter": [ {"name": "dryRun", "valueBoolean": false}, {"name": "live", "valueBoolean": true}, {"name": "versions", "valueInteger": 3} ]}| Parameter | Meaning |
|---|---|
dryRun |
Whether this call only looked |
live |
Whether the resource had a live row; false for one that was already deleted |
versions |
Stored versions, removed or about to be, counting the live one |
A resource with nothing stored is 404, so a second $expunge of the same id is 404.
To remove a whole patient record on R6, see $purge.
Search Parameters
Section titled “Search Parameters”Common Parameters
Section titled “Common Parameters”| Parameter | Type | Description |
|---|---|---|
_id |
token | Resource logical ID |
_lastUpdated |
date | Last modification timestamp |
_profile |
uri | Profiles the resource conforms to |
_tag |
token | Tags on the resource |
_security |
token | Security labels |
_source |
uri | Source URI |
Search Modifiers
Section titled “Search Modifiers”| Modifier | Types | Description |
|---|---|---|
:exact |
string | Case-sensitive exact match |
:contains |
string | Substring match |
:missing |
all | Element present/absent |
:not |
token | Exclude matching codes |
:in |
token | Code in ValueSet |
:not-in |
token | Code not in ValueSet |
:below |
token | Code or descendants |
:above |
token | Code or ancestors |
:text on string and token parameters is refused with an error.
Result Parameters
Section titled “Result Parameters”| Parameter | Description |
|---|---|
_count |
Number of results per page |
_offset |
Pagination offset |
_cursor |
Position of a keyset page, taken from a next link |
_sort |
Sort by parameter(s) |
_elements |
Return only specified elements |
_summary |
Return summary (true, false, text, data, count) |
_include |
Include referenced resources |
_revinclude |
Include resources that reference results |
Error Responses
Section titled “Error Responses”All errors return an OperationOutcome:
{ "resourceType": "OperationOutcome", "issue": [ { "severity": "error", "code": "not-found", "diagnostics": "Resource Patient/xyz not found" } ]}HTTP Status Codes
Section titled “HTTP Status Codes”| Code | Meaning |
|---|---|
| 200 | Success (search, read) |
| 201 | Created |
| 204 | No Content (delete) |
| 400 | Bad Request |
| 401 | Unauthorized |
| 403 | Forbidden |
| 404 | Not Found |
| 409 | Conflict (the resource already exists, or a concurrent write) |
| 412 | Precondition Failed (version mismatch on If-Match) |
| 422 | Unprocessable Entity |
| 500 | Internal Server Error |
Headers
Section titled “Headers”Request Headers
Section titled “Request Headers”| Header | Description |
|---|---|
Accept |
Response format |
Content-Type |
Request body format |
If-Match |
Conditional update (ETag) |
If-None-Match |
Conditional read |
If-None-Exist |
Conditional create (search params) |
Prefer |
Return preference (return=minimal, return=representation) |
X-Request-Id |
Correlation ID for tracing |
X-Skip-Validation |
Skip validation (if enabled) |
Response Headers
Section titled “Response Headers”| Header | Description |
|---|---|
Location |
URL of created/updated resource |
ETag |
Resource version (W/"1") |
Last-Modified |
Resource modification timestamp |
Content-Location |
Canonical URL |
Admin API
Section titled “Admin API”Health Check
Section titled “Health Check”GET /healthz # the process is upGET /readyz # the database and packages are readyConfiguration
Section titled “Configuration”GET /admin/configPOST /admin/config/$reloadGET /admin/config/{category}GET /admin/config/{category}/{key}PUT /admin/config/{category}/{key}DELETE /admin/config/{category}/{key}Feature Flags
Section titled “Feature Flags”GET /admin/featuresGET /admin/features/{name}PUT /admin/features/{name}POST /admin/features/{name}/$evaluateDatabase
Section titled “Database”The DB console API needs [db_console] enabled, and its required_role if one is set.
GET /api/db-console/active-queriesGET /api/db-console/index-advisor?resourceType=PatientPOST /api/db-console/index-advisor/analyzeSee the index advisor.
Pagination
Section titled “Pagination”Search results include pagination links:
{ "resourceType": "Bundle", "type": "searchset", "total": 150, "link": [ {"relation": "self", "url": "...?_count=10"}, {"relation": "first", "url": "...?_count=10&_offset=0"}, {"relation": "next", "url": "...?_count=10&_offset=10"}, {"relation": "previous", "url": "...?_count=10&_offset=0"}, {"relation": "last", "url": "...?_count=10&_offset=140"} ], "entry": [...]}Follow these links instead of building paging URLs. Sorting by _id or _lastUpdated, and a listing
with no criteria, page by _cursor and have no last link. See
Keyset pagination.
Rate Limiting
Section titled “Rate Limiting”There is no general rate limit and no X-RateLimit-* headers.
A username or client id that fails to authenticate too often gets 429 with Retry-After at
/auth/token; see Lockout. Bulk status polling also sends
Retry-After: on 202 while a job runs, and on 429 when a client polls the same job faster than
bulk_export.min_poll_interval_ms allows.
CORS is on and has no configuration:
- Allowed origin: the request’s
Originis reflected back, withAccess-Control-Allow-Credentials: true - Allowed methods: GET, POST, PUT, PATCH, DELETE, OPTIONS
- Allowed headers: Content-Type, Authorization, Accept, X-Request-Id, X-Skip-Validation
- Exposed headers: Content-Type, X-Request-Id, Location
- Preflight responses are cached for one hour