Batch Upsert

Description of how to insert or update a collection of resources using our FHIR API.

PUT {base}/

The batch upsert operation allows you to update or create multiple resources in a single request. This is useful for efficiently managing large sets of data with minimal API calls. The upsert logic works as following:

  • Create: If a resource with the specified id does not exist, it will be created based on the resourceType described in the body.

  • Update: If a resource with the specified id already exists, it will be updated with the new data provided in the request.

Below is an example of how to use a PUT request to insert or update a resource. A complete list of resources can be found by visiting the resource specifications here.

Request PUT {base}/

Headers

Name
Value

Content-Type

application/json

Authorization

Bearer <token>

Body

[
  {
    "name": [{ "given": ["Bob"] }],
    "active": true,
    "resourceType": "Patient",
    "id": "30405060"
  },
  {
    "name": [{ "given": ["Charles"] }],
    "active": false,
    "resourceType": "Patient",
    "id": "40506070"
  },
  {
    "name": [{ "given": ["Christy"] }],
    "active": false,
    "resourceType": "Patient",
    "id": "50607080"
  }
]

Response

[
  {
    "name": [
      {
        "given": ["Bob"]
      }
    ],
    "active": true,
    "id": "30405060",
    "resourceType": "Patient",
    "meta": {
      "lastUpdated": "2024-07-17T06:56:48.506516Z",
      "createdAt": "2024-07-17T06:56:48.506516Z",
      "versionId": "540603"
    }
  },
  {
    "name": [
      {
        "given": ["Charles"]
      }
    ],
    "active": false,
    "id": "40506070",
    "resourceType": "Patient",
    "meta": {
      "lastUpdated": "2024-07-17T06:56:48.519054Z",
      "createdAt": "2024-07-17T06:56:48.519054Z",
      "versionId": "540605"
    }
  },
  {
    "name": [
      {
        "given": ["Christy"]
      }
    ],
    "active": false,
    "id": "50607080",
    "resourceType": "Patient",
    "meta": {
      "lastUpdated": "2024-07-17T06:56:48.519054Z",
      "createdAt": "2024-07-17T06:56:48.519054Z",
      "versionId": "540613"
    }
  }
]

Last updated