FHIR REST API Implementation

VerifiedSafe

Expert guidance for implementing FHIR RESTful API servers and clients following HL7 FHIR specification (R4/R5). Covers CRUD operations, bundles, transactions, and content negotiation.

Sby Skills Guide Bot
DevelopmentAdvanced
2/28/2026
Claude CodeCursorCodex
#fhir#rest-api#hl7#healthcare-interoperability#api-design

Recommended for

Automated summary

Provides implementation guidance for HL7 FHIR RESTful API servers and clients, covering URL patterns, core operations, content negotiation, headers, versioning, and conditional operations.

Strengths

  • Concrete table of FHIR operations with HTTP methods, URL patterns, and success codes.
  • Explains application/fhir+json/xml MIME types and the fhirVersion parameter for R2 through R5.
  • Covers required request/response headers, weak ETags, and optimistic locking with If-Match.
  • Points to a dedicated reference for detailed operation specifications.

Limitations

  • The provided content is truncated at the versioning and CapabilityStatement section.
  • Focuses on the REST layer rather than clinical resource modeling or validation.
  • Assumes prior familiarity with the FHIR specification and its resources.
When to use it

Use this skill when designing or implementing FHIR RESTful endpoints, a FHIR server, or a FHIR client that follows the HL7 specification.

When not to use it

Do not use it to define clinical data models, perform semantic validation of FHIR resources, or design non-FHIR APIs.

Security analysis

Safe
Quality score90/100

The skill is purely instructional documentation for implementing FHIR REST APIs. It contains no executable commands, network calls, credential handling, destructive operations, or attempts to disable safety controls. It only describes standard HTTP/FHIR patterns and therefore presents no meaningful execution risk.

No concerns found

How this analysis is made

Examples

Add FHIR read and search endpoints
Implement FHIR R4 read and search endpoints for Patient in my Express server, including application/fhir+json content negotiation and ETag version headers.
Support conditional create and transactions
Add conditional create and batch transaction support to our FHIR API using the If-None-Exist header and a Bundle request body.
Implement optimistic locking in a FHIR client
Write a FHIR client method that updates an Observation using If-Match with the current weak ETag and handles a 412 Precondition Failed response.

name: fhir-api description: Expert guidance for implementing FHIR RESTful API servers and clients following the HL7 FHIR specification. Use this skill when implementing a FHIR server with REST endpoints, building a FHIR client, designing FHIR API routes and handlers, implementing FHIR operations (read, create, update, delete, search, history), working with FHIR bundles, batch requests, or transactions, handling FHIR content negotiation, headers, and versioning, or implementing conditional operations. Trigger keywords include "FHIR REST", "FHIR API", "FHIR server", "FHIR client", "FHIR endpoint", "FHIR operations", "RESTful FHIR", "implement FHIR".

FHIR REST API implementation

This skill provides guidance for implementing FHIR RESTful APIs according to the HL7 FHIR specification (R4/R5).

URL structure

All FHIR REST URLs follow the pattern:

[base]/[type]/[id]
  • [base]: Service base URL (e.g., https://fhir.example.org/r4)
  • [type]: Resource type (e.g., Patient, Observation)
  • [id]: Logical resource ID

URLs are case-sensitive and use UTF-8 encoding.

Core operations

| Operation | HTTP | URL Pattern | Success | | ----------------- | -------- | ----------------------------------- | ------- | | Read | GET | [base]/[type]/[id] | 200 | | VRead | GET | [base]/[type]/[id]/_history/[vid] | 200 | | Create | POST | [base]/[type] | 201 | | Update | PUT | [base]/[type]/[id] | 200/201 | | Patch | PATCH | [base]/[type]/[id] | 200 | | Delete | DELETE | [base]/[type]/[id] | 200/204 | | Search | GET/POST | [base]/[type]?params | 200 | | History | GET | [base]/[type]/[id]/_history | 200 | | Capabilities | GET | [base]/metadata | 200 | | Batch/Transaction | POST | [base] | 200 |

For detailed specifications of each operation, see references/operations.md.

Content negotiation

MIME types

| Format | MIME Type | | ------ | ------------------------- | | JSON | application/fhir+json | | XML | application/fhir+xml | | RDF | application/fhir+turtle |

Use the Accept header for response format and Content-Type for request body format.

The _format query parameter overrides Accept when clients cannot set headers.

FHIR version

Specify version via MIME type parameter:

Accept: application/fhir+json; fhirVersion=4.0

Version mappings: 1.0 (R2), 3.0 (R3), 4.0 (R4), 4.3 (R4B), 5.0 (R5).

Required headers

Request headers

| Header | Purpose | Example | | ------------- | ------------------- | ----------------------- | | Accept | Response format | application/fhir+json | | Content-Type | Request body format | application/fhir+json | | If-Match | Optimistic locking | W/"123" | | If-None-Exist | Conditional create | identifier=123 | | Prefer | Return preference | return=representation |

Response headers

| Header | Purpose | Example | | ------------- | ------------------ | ------------------------------- | | ETag | Version identifier | W/"123" | | Location | New resource URL | [base]/Patient/123/_history/1 | | Last-Modified | Modification time | RFC 7231 date |

Versioning and optimistic locking

FHIR uses weak ETags for version tracking:

  1. Server returns ETag: W/"[versionId]" with responses
  2. Client sends If-Match: W/"[versionId]" with updates
  3. Server returns 412 Precondition Failed if version mismatch

Implement version-aware updates when CapabilityStatement.rest.resource.versioning is versioned-update.

Error handling

Return OperationOutcome resources for all errors:

{
    "resourceType": "OperationOutcome",
    "issue": [
        {
            "severity": "error",
            "code": "invalid",
            "diagnostics": "Patient.birthDate: Invalid date format"
        }
    ]
}

Status codes

| Code | Meaning | | ---- | -------------------------------------- | | 400 | Invalid syntax or validation failure | | 404 | Resource not found | | 409 | Version conflict | | 410 | Resource deleted | | 412 | Precondition failed (version mismatch) | | 422 | Business rule violation |

Prefer header

Control response content with Prefer:

| Value | Response body | | ------------------------- | -------------------- | | return=minimal | Empty (headers only) | | return=representation | Full resource | | return=OperationOutcome | Validation outcome |

For async operations, use Prefer: respond-async to get 202 Accepted with status polling URL.

Implementation checklist

Server implementations should:

  1. Implement CapabilityStatement at /metadata
  2. Support content negotiation (JSON at minimum)
  3. Return proper ETags for versioned resources
  4. Include Location header on create/update
  5. Return OperationOutcome for all errors
  6. Support _format parameter fallback
  7. Honour Prefer header for response content

References

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/fhir-rest-api-implementation-mm5t89ov/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/fhir-rest-api-implementation-mm5t89ov' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/fhir-rest-api-implementation-mm5t89ov/download' --output '.skill-downloads/fhir-rest-api-implementation-mm5t89ov/SKILL.md.part' && mv '.skill-downloads/fhir-rest-api-implementation-mm5t89ov/SKILL.md.part' '.skill-downloads/fhir-rest-api-implementation-mm5t89ov/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/fhir-rest-api-implementation-mm5t89ov/SKILL.md' && test -s '.skill-downloads/fhir-rest-api-implementation-mm5t89ov/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/fhir-api' && cp -R '.skill-downloads/fhir-rest-api-implementation-mm5t89ov' '.claude/skills/fhir-api'

Cursor
test -f '.skill-downloads/fhir-rest-api-implementation-mm5t89ov/SKILL.md' && test -s '.skill-downloads/fhir-rest-api-implementation-mm5t89ov/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/fhir-api' && cp -R '.skill-downloads/fhir-rest-api-implementation-mm5t89ov' '.cursor/skills/fhir-api'

Codex
test -f '.skill-downloads/fhir-rest-api-implementation-mm5t89ov/SKILL.md' && test -s '.skill-downloads/fhir-rest-api-implementation-mm5t89ov/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/fhir-api' && cp -R '.skill-downloads/fhir-rest-api-implementation-mm5t89ov' '.agents/skills/fhir-api'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/fhir-rest-api-implementation-mm5t89ov'

openskills read 'fhir-rest-api-implementation-mm5t89ov'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/fhir-rest-api-implementation-mm5t89ov/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills