Skip to main content
Use this endpoint to create a raw FHIR R4 resource when the simplified SDK methods don’t cover your use case. The request body must be a valid FHIR R4 resource object. Your tenant tag is automatically injected into meta.tag — you do not need to include it. The response is the created FHIR resource in its native structure.

Request

POST https://api.clinikapi.com/v1/fhir/:resourceType

Headers

x-api-key
string
required
Your ClinikAPI secret key (clk_live_* or clk_test_*).
Content-Type
string
required
Must be application/fhir+json or application/json.

Path parameters

resourceType
string
required
The FHIR resource type to create (e.g. Patient, Observation, Condition, MedicationRequest). Must match the resourceType field in the request body.

Body

A valid FHIR R4 resource object. The resourceType field must be present and match the path parameter. Refer to the FHIR R4 specification for the full resource schema for each type.

Response

Returns 201 Created with the raw FHIR R4 resource as stored, including the generated id and meta.tag with your tenant identifier.
resourceType
string
FHIR resource type as submitted.
id
string
Server-generated resource ID.
meta.tag
array
Contains your automatically injected tenant tag.

Examples

curl

curl -X POST https://api.clinikapi.com/v1/fhir/Patient \
  -H "x-api-key: clk_live_abc123" \
  -H "Content-Type: application/fhir+json" \
  -d '{
    "resourceType": "Patient",
    "name": [{ "family": "Smith", "given": ["John"] }],
    "gender": "male",
    "birthDate": "1990-01-15"
  }'

TypeScript SDK

import { Clinik } from '@clinikapi/sdk';

const clinik = new Clinik(process.env.CLINIKAPI_SECRET_KEY!);

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

// Create a raw FHIR Observation
const { data: obs } = await clinik.fhir.request('POST', '/Observation', {
  resourceType: 'Observation',
  status: 'final',
  code: { coding: [{ system: 'http://loinc.org', code: '8867-4', display: 'Heart rate' }] },
  subject: { reference: 'Patient/pt_abc123' },
  valueQuantity: { value: 72, unit: 'beats/min' },
});

console.log(patient.id); // server-generated ID