> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ferrum.thalamiq.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Content Negotiation

> Request and response format handling

## Content Negotiation

The FHIR API supports multiple content formats through HTTP content negotiation.

## Supported Formats

Ferrum supports **JSON** and **XML**. The FHIR spec also defines RDF (turtle); Ferrum does not support RDF.

* `application/fhir+json` - FHIR JSON (recommended)
* `application/fhir+xml` - FHIR XML
* `application/json` - Plain JSON
* `application/xml` - Plain XML

Examples in this documentation use JSON.

## Request Format

Specify the content type when sending data using the `Content-Type` header:

```bash theme={null}
# JSON request
curl -X POST \
     -H "Content-Type: application/fhir+json" \
     -d '{"resourceType":"Patient","name":[{"family":"Doe"}]}' \
     https://your-server.com/fhir/Patient

# XML request
curl -X POST \
     -H "Content-Type: application/fhir+xml" \
     -d '<Patient xmlns="http://hl7.org/fhir"><name><family value="Doe"/></name></Patient>' \
     https://your-server.com/fhir/Patient
```

## Response Format

Request your preferred response format using the `Accept` header:

```bash theme={null}
# Request JSON response
curl -H "Accept: application/fhir+json" \
     https://your-server.com/fhir/Patient/123

# Request XML response
curl -H "Accept: application/fhir+xml" \
     https://your-server.com/fhir/Patient/123
```

## Default Behavior

If no `Accept` header is provided, the server defaults to `application/fhir+json`.

## Format Priority

You can specify multiple formats with quality values:

```bash theme={null}
curl -H "Accept: application/fhir+xml;q=0.9, application/fhir+json;q=1.0" \
     https://your-server.com/fhir/Patient/123
```

The server will return the highest quality format it supports.
