FHIR R4 API Reference

Build powerful healthcare integrations with our standards-compliant FHIR R4 REST API. Full OpenAPI specification available.

FHIR R4 REST JSON OAuth 2.0

Base URL

https://api.xehr.io/fhir/r4

Authentication

Authorization: Bearer <token>

Content-Type

application/fhir+json

Making Your First Request

Get Patient by ID
curl -X GET "https://api.xehr.io/fhir/r4/Patient/123" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Accept: application/fhir+json"
Response
{
  "resourceType": "Patient",
  "id": "123",
  "identifier": [
    {
      "system": "xehr-mrn",
      "value": "MRN-001234"
    }
  ],
  "name": [
    {
      "family": "Smith",
      "given": ["John", "William"]
    }
  ],
  "birthDate": "1980-05-15",
  "gender": "male"
}

OAuth 2.0 Authentication

1

Request Access Token

POST /oauth/token
Content-Type: application/x-www-form-urlencoded

grant_type=client_credentials
&client_id=YOUR_CLIENT_ID
&client_secret=YOUR_CLIENT_SECRET
&scope=patient/*.read
2

Use Token in Requests

Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI...
3

Refresh When Expired

Tokens expire after 1 hour. Use refresh token to obtain new access token.

API Reference

Patient

GET /Patient Search patients
GET /Patient/{id} Get patient by ID
POST /Patient Create new patient
PUT /Patient/{id} Update patient

Encounter

GET /Encounter Search encounters
GET /Encounter/{id} Get encounter by ID
POST /Encounter Create new encounter
PUT /Encounter/{id} Update encounter

Condition

GET /Condition Search conditions/diagnoses
POST /Condition Add diagnosis

Observation

GET /Observation Search observations (vitals, labs)
POST /Observation Create observation

Claim

GET /Claim Search claims
GET /Claim/{id} Get claim by ID
POST /Claim Submit new claim
PUT /Claim/{id} Update claim

Coverage

GET /Coverage Search insurance coverage
POST /Coverage Add patient coverage

SMART App Launch Framework

Build secure, context-aware applications that integrate seamlessly with xEHR. Full support for SMART on FHIR 2.0 specification.

EHR Launch

Launch apps from within the EHR with full patient and encounter context automatically passed.

launch=xyz&iss=https://api.xehr.io/fhir/r4

Standalone Launch

Patient portals and external apps can authenticate independently and select patient context.

iss=https://api.xehr.io/fhir/r4

Backend Services

System-to-system integration using JWT-based client authentication for automated workflows.

grant_type=client_credentials

PKCE Support

Proof Key for Code Exchange for enhanced security with public clients and SPAs.

code_challenge_method=S256

SMART Configuration Endpoints

GET Well-Known Configuration
/.well-known/smart-configuration

Discovery endpoint for SMART capabilities

AUTH Authorization
/oauth/authorize

OAuth 2.0 authorization endpoint

POST Token Exchange
/oauth/token

Token endpoint for access tokens

GET JWKS
/.well-known/jwks.json

JSON Web Key Set for token validation

GET Capability Statement
/fhir/r4/metadata

FHIR server capabilities and conformance

POST Token Revocation
/oauth/revoke

Revoke access or refresh tokens

Supported Scopes

patient/*.read Read all patient data
patient/*.write Write patient data
user/*.read User-context read access
system/*.read Backend service read
launch/patient Patient context
launch/encounter Encounter context
openid fhirUser User identity
offline_access Refresh tokens

Real-Time Event Notifications

Subscribe to events and receive real-time notifications when data changes.

patient.created New patient registered
encounter.completed Encounter signed and finalized
claim.submitted Claim sent to clearinghouse
claim.adjudicated ERA/remittance received
appointment.scheduled New appointment booked
lab.resulted Lab results received

Integration Support

Use any FHIR R4 compliant client library

JavaScript/TypeScript

npm install fhirclient

SMART Health IT client

Python

pip install fhirclient

SMART on FHIR Python client

Java

HAPI FHIR Client

hl7.fhir.r4 library

.NET

Hl7.Fhir.R4

Firely .NET SDK

xEHR is compatible with all FHIR R4 compliant client libraries. Use your preferred SDK.

Rate Limits

API rate limits are applied per organization to ensure fair usage.

Standard 1,000 requests/minute
Bulk Operations 100 requests/minute
Export Operations 10 concurrent jobs

Need higher limits? Contact us for enterprise plans.

Ready to Build?

Get your API credentials and start integrating with xEHR today.

xEHR AI Assistant

Online

Hi! I'm the xEHR AI Assistant. I can help you with:

  • Platform features
  • Pricing plans
  • HIPAA compliance
  • Schedule a demo

Powered by xEHR AI