Skip to main content
The clinik.fhir namespace gives you direct access to the underlying FHIR R4 API when the simplified resource namespaces don’t cover your use case. You get the full power of FHIR — custom search parameters, chained queries, and FHIR operations like $everything and $validate — while still benefiting from the SDK’s authentication, retry logic, and tenant isolation.
All passthrough requests enforce the same tenant isolation and rate limits as the simplified SDK methods. The ClinikAPI server always injects and filters by your tenant tag, so you cannot accidentally read or write another tenant’s data.

request

const { data, meta } = await clinik.fhir.request<T>(
  method: string,
  path: string,
  body?: unknown
): Promise<ApiResponse<T>>
method
string
required
HTTP method. Accepted values: GET, POST, PUT, PATCH, DELETE.
path
string
required
FHIR resource path relative to the API root, for example /Patient or /Observation/obs_abc123. Do not include /v1/ — the SDK prepends it automatically.
body
unknown
Request body for POST, PUT, and PATCH requests. Pass a raw FHIR R4 resource object.
data
T
The raw FHIR R4 resource or Bundle returned by the server. The generic type parameter T lets you provide your own type annotation.
Passthrough responses return raw FHIR R4 resources, not the simplified format used by the resource namespaces. Fields like resourceType, meta, and FHIR-native identifiers will be present in the response.

Examples

const { data } = await clinik.fhir.request('POST', '/Patient', {
  resourceType: 'Patient',
  name: [{ family: 'Smith', given: ['John'] }],
  gender: 'male',
  birthDate: '1990-01-15',
});

When to use the passthrough

Use clinik.fhir.request() when you need:
  • Custom FHIR search parameters not exposed in the simplified SDK, such as chained parameters or composite searches.
  • FHIR operations$everything, $validate, $apply, and other operation framework endpoints.
  • Resource types not yet simplified by ClinikAPI, such as HealthcareService, Location, or CareTeam.
  • Complex FHIR queries with multiple _include, _revinclude, or _filter parameters.
If you find yourself using the passthrough frequently for a particular resource type, consider requesting first-class SDK support for that resource through the ClinikAPI GitHub repository.

TypeScript typing

Provide a generic type argument to get typed responses:
import type { Bundle, Patient } from 'fhir/r4';

const { data: bundle } = await clinik.fhir.request<Bundle>(
  'GET',
  '/Patient?name=Smith&_count=10'
);

const { data: patient } = await clinik.fhir.request<Patient>(
  'GET',
  '/Patient/pt_abc123'
);