Skip to content

API Reference

  • Base URL: http://localhost:8888/fhir (host and port are configurable)
  • FHIR Version: R4 by default; R4B, R5 and R6 through [fhir] version
Header Values
Accept application/fhir+json, application/json
Content-Type application/fhir+json, application/json

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
Terminal window
GET /fhir/metadata

Returns the server’s CapabilityStatement describing supported operations.

Terminal window
POST /fhir/{resourceType}
Content-Type: application/fhir+json
{resource body}

Response: 201 Created with Location header

Terminal window
GET /fhir/{resourceType}/{id}

Response: 200 OK with resource body

Terminal window
PUT /fhir/{resourceType}/{id}
Content-Type: application/fhir+json
If-Match: W/"{versionId}" # Optional, for conditional update
{resource body with id}

Response: 200 OK with updated resource

Terminal window
DELETE /fhir/{resourceType}/{id}

Response: 204 No Content

Terminal window
GET /fhir/{resourceType}?{parameters}
POST /fhir/{resourceType}/_search
Content-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.

Terminal window
# Instance history
GET /fhir/{resourceType}/{id}/_history
# Type history
GET /fhir/{resourceType}/_history
# System history
GET /fhir/_history
# Remove the history of a resource, or one version; never the current version
DELETE /fhir/{resourceType}/{id}/_history
DELETE /fhir/{resourceType}/{id}/_history/{versionId}

Removing history needs an administrator. See FHIR R6.

Terminal window
GET /fhir/{resourceType}/{id}/_history/{versionId}
Terminal window
POST /fhir
Content-Type: application/fhir+json
{
"resourceType": "Bundle",
"type": "transaction",
"entry": [...]
}

All-or-nothing execution. See Transactions for details.

Terminal window
POST /fhir
Content-Type: application/fhir+json
{
"resourceType": "Bundle",
"type": "batch",
"entry": [...]
}

Independent execution of each entry.

Terminal window
POST /fhir/{resourceType}/$validate
POST /fhir/{resourceType}/{id}/$validate

Validate a resource against profiles.

Terminal window
GET /fhir/ValueSet/$expand?url={valuesetUrl}
POST /fhir/ValueSet/$expand

Expand a ValueSet. See Terminology for details.

Terminal window
GET /fhir/ValueSet/$validate-code?url={valuesetUrl}&code={code}&system={system}
POST /fhir/ValueSet/$validate-code
Terminal window
GET /fhir/Patient/{id}/$everything

Returns a Bundle with all resources related to the patient.

Terminal window
GET /fhir/Patient/{id}/$summary
GET /fhir/Patient/$summary?identifier={identifier}

An International Patient Summary document. See Patient Summary.

Evaluates a FHIRPath expression, against a resource given inline or at {Type}/{id}/$fhirpath against a stored one.

POST /fhir/$fhirpath
Content-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.

POST /fhir/{type}/{id}/$expunge
Authorization: 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.

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
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.

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

All errors return an OperationOutcome:

{
"resourceType": "OperationOutcome",
"issue": [
{
"severity": "error",
"code": "not-found",
"diagnostics": "Resource Patient/xyz not found"
}
]
}
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
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)
Header Description
Location URL of created/updated resource
ETag Resource version (W/"1")
Last-Modified Resource modification timestamp
Content-Location Canonical URL
Terminal window
GET /healthz # the process is up
GET /readyz # the database and packages are ready
Terminal window
GET /admin/config
POST /admin/config/$reload
GET /admin/config/{category}
GET /admin/config/{category}/{key}
PUT /admin/config/{category}/{key}
DELETE /admin/config/{category}/{key}
Terminal window
GET /admin/features
GET /admin/features/{name}
PUT /admin/features/{name}
POST /admin/features/{name}/$evaluate

The DB console API needs [db_console] enabled, and its required_role if one is set.

Terminal window
GET /api/db-console/active-queries
GET /api/db-console/index-advisor?resourceType=Patient
POST /api/db-console/index-advisor/analyze

See the index advisor.

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.

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 Origin is reflected back, with Access-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