# Ingest FHIR R4

URL: https://docs.clinia.com/sdks/reference/ingest/ingest-fhir-r4

Submits a FHIR R4 Bundle or a single resource. The response is a receipt: extraction continues after it is returned, so poll the ingestion to follow it. The version is part of the path because a Bundle does not state which FHIR release it is written against.

## Usage [#usage]

```javascript tab="JavaScript" tab-group="sdk-language"
import { ContextEngineClient } from "@clinia/context-engine-js";

// Initialize the client
const client = new ContextEngineClient({
  baseUrl: process.env.CLINIA_WORKSPACE,
  auth: {
    clientId: process.env.CLINIA_CLIENT_ID,
    clientSecret: process.env.CLINIA_CLIENT_SECRET,
  },
});

// Call the API, with the request body the API reference documents
const { data, error } = await client.ingest.ingestFhirR4("<patient-id>", body);

// Print the response
console.log(data ?? error);
```

```python tab="Python" tab-group="sdk-language"
import os
from clinia_context_engine import ClientCredentials, ContextEngineClient

# Initialize the client
client = ContextEngineClient(
    base_url=os.environ["CLINIA_WORKSPACE"],
    auth=ClientCredentials(
        client_id=os.environ["CLINIA_CLIENT_ID"],
        client_secret=os.environ["CLINIA_CLIENT_SECRET"],
    ),
)

# Call the API, with the request body the API reference documents
result = client.ingest.ingest_fhir_r4("<patient-id>", body)

# Print the response
print(result)
```

The environment variables are set in Install and authenticate, for [JavaScript](https://docs.clinia.com/sdks/javascript#install-and-authenticate) or [Python](https://docs.clinia.com/sdks/python#install-and-authenticate).

## API reference [#api-reference]

[`POST /v1/patients/{patientId}/ingestions/fhir/r4`](https://docs.clinia.com/api/rest/post-patients-patientId-ingestions-fhir-r4) documents the parameters, the request body and the responses.
