# $import and /fhir/$import `$import` is an implementation of the upcoming FHIR Bulk Import API. This is an asynchronous Operation, which returns url to monitor progress. There are two versions of this operation - `/fhir/$import` accepts data in FHIR format, `/$import` works with [Aidbox format](../rest-api/other/aidbox-and-fhir-formats.md). #### Resource requirements for all import operations: | Operation | id | resourceType | | --------------- | -------- | ------------ | | `/$import` | Required | Not required | | `/fhir/$import` | Required | Not required | {% hint style="warning" %} Keep in mind that $import **does not validate** inserted resources for the sake of performance. Pay attention to the structure of data you insert and use the correct URL for your data format, i.e.: use /fhir prefix for FHIR data. {% endhint %} {% hint style="info" %} Please consider using [Asynchronous validation API](../../modules/profiling-and-validation/asynchronous-resource-validation.md) to validate data after $import {% endhint %} ## Example {% tabs %} {% tab title="Request" %} ```yaml POST /fhir/$import Accept: text/yaml Content-Type: text/yaml id: synthea contentEncoding: gzip inputs: - resourceType: Encounter url: https://storage.googleapis.com/aidbox-public/synthea/100/Encounter.ndjson.gz - resourceType: Organization url: https://storage.googleapis.com/aidbox-public/synthea/100/Organization.ndjson.gz - resourceType: Patient url: https://storage.googleapis.com/aidbox-public/synthea/100/Patient.ndjson.gz ``` {% endtab %} {% tab title="Response" %} ```yaml status: 200 ``` {% endtab %} {% endtabs %} ## Parameters
| Parameter | Description |
|---|---|
id | Identifier of the import |
contentEncoding | Supports gzip or plain (non-gzipped .ndjson files) |
inputs | Resources to import |
update | Update history for updated resources (false by default) |
| Parameter | Type | Description |
|---|---|---|
id | string | Identifier of the import |
resourceType | string | Type of resource where the progress of import operation is recorded. Possible value: BulkImportStatus |
meta | object | |
meta.createdAt | string | Timestamp string at which the resource was created |
meta.lastUpdated | string | Timestamp string at which the resource was updated last time |
meta.versionId | string | Version id of this resource |
contentEncoding | string | gzip or plain |
time | object | |
time.start | string | Timestamp string at which the operation started in ISO format |
time.end | string | Timestamp string at which the operation was completed in ISO format. Only present after the entire import operation has been completed |
type | string | Data format type to be loaded. Possible values: |
inputs | object[] | |
inputs[].url | string | URL from which load resources |
inputs[].resourceType | string | Resource type to be loaded |
inputs[].status | string | Load status for each input. Possible values: |
inputs[].total | integer | The number of loaded resources. Only present after the operation for this input has been completed successfully |
inputs[].ts | string | Timestamp string at which the loading was completed in ISO format. Only present after the operation for this input has been completed |
inputs[].duration | integer | Duration of loading in milliseconds. Only present after the operation for this input has been completed successfully |
status | string | Load status for all inputs. Only present after the entire import operation has been completed. Possible value: |
| Parameter | Description |
|---|---|
id | Identifier of the import. If you don't provide this, the id will be auto-generated. You can check it on Content-Location header in the response |
contentEncoding | Supports gzip or plain (non-gzipped .ndjson files) |
inputs (required) | Resources to import
|
update | Update history for updated resources (false by default) |
allowedRetryCount | Set the maximum number of import retries for each input (2 by default) |
python3 -m http.server
ngrok http 8000
# url: https://<...>.ngrok-free.app/Encounter.ndjson.gz