# Test with Redox FHIR sandbox data

The <u>**Redox FHIR sandbox**</u> allows you to test your FHIR workflows with test patients. Use this full-featured sandbox during implementation to test an end-to-end integrated workflow against a FHIR server—and to mirror how an integration might look when connecting to legacy systems.

We seed our sandbox with a robust set of test patient data covering most of the FHIR resources in our API suite. [See our FHIR specs](https://docs.redoxengine.com/permalink/fhir-resources-landing-page). 

You can test reads, queries, and even writebacks. 

## When Redox refreshes the sandbox

We want our sandbox to be useful to everyone. To achieve that, we occasionally refresh the sandbox, which reverts the environment to its original state with only Redox-seeded test data. This keeps test data valuable to all customers and clears the sandbox of any potentially confidential test data. We only refresh as necessary to ensure the overall health of the sandbox.

## Destination slug

Send all sandbox API requests to `redox-fhir-sandbox`. 

## Discover test patient data

Our FHIR sandbox supports <u>reading</u> and <u>querying</u> for data. This allows you to test your search workflows. 

### Search tips

The Redox FHIR sandbox uses <u>**exact matching**</u> for patient searches.

For identifiers, we include one or more of the following for each test patient:

- Medical Record ID (MR)
- driver’s license number (DL)
- passport number (PPN)
- Social Security number (SSN)

The `system` for MR, DL, and PPN is the Redox FHIR API sandbox environment. The `system` for SSN is `http://hl7.org/fhir/side/us-ssn`. [Learn more about searching with patient identifiers](/fhir-api-actions/patients/search-for-a-patient-with-identifier).

For demographics, we include one or more of the following for each test patient:

- given name
- family name
- gender
- birthdate
- address-city
- address-state
- address-postalcode
- home phone
- mobile phone
- email address

> **Phone and address parameters**
>
> A couple of things to note for patient searches:
>
> First, the `phone` parameter matches either a home or mobile phone.
>
> Second, you may notice that the address is split into three parameters (`address-city`, `address-state`, `address-postalcode`) and doesn’t include the street address. The FHIR API sandbox doesn’t support searching for a street address. Instead, you can search by city, state, or postal code—or a combination of the three.

[Learn more about searching with patient demographics](/fhir-api-actions/patients/search-for-a-patient-by-demographics).

### Redox test patients

See the pre-seeded Redox test patients below. Most of these test patients can’t be modified.

| **Patient** | **Identifiers / Demographics** | **Resources** |
| --- | --- | --- |
| Synthia Davis | <u>**FHIR ID**</u>: fbee8d6b-5acf-370c-7edd-af0d84f5288c <u>**MR**</u>: 3Y67hJYUopQywm8frKLGBf <u>**DOB**</u>: 2000-10-10 <u>**gender**</u>: female <u>**address**</u>: Revere, MA 02151 | `Appointment` `CarePlan` `CareTeam` `Condition` `Coverage` `Device` `DiagnosticReport` `DocumentReference` `Encounter` `Goal` `Immunization` `MedicationRequest` `Observation` `Patient` `Procedure` `ServiceRequest` |
| Micheal Shields | <u>**FHIR ID**</u>: 307b6419-5147-4716-10b1-bb458ac191c3 <u>**MR**</u>: 5Z89kLZWqrSzvn9gtNMHCh <u>**DOB**</u>: 2003-07-19 <u>**gender**</u>: female <u>**address**</u>: Fairhaven, MA | `AllergyIntolerance` `Appointment` `CarePlan` `CareTeam` `Condition` `Coverage` `DiagnosticReport` `DocumentReference` `Encounter` `Medication` `MedicationAdministration` `MedicationRequest` `Observation` `Patient` `Procedure` |
| Narcisa Torphy | <u>**FHIR ID**</u>: 18022a84-1fd7-ba38-3567-efbc6a50e9d4 <u>**MR**</u>: 7A12mNXYstUvop2huOPJDi <u>**DOB**</u>: 1967-05-11 <u>**gender**</u>: female <u>**address**</u>: Dedham, MA 02026 | `Condition` `Coverage` `DiagnosticReport` `DocumentReference` `Encounter` `ImagingStudy` `Observation` `Patient` `Procedure` |
| Roosevelt Turner | <u>**FHIR ID**</u>: 7673112e-f252-3c46-a7e7-ac1e1fe3fa45 <u>**MR**</u>: 9B34oPZWuwQxyj4kvQRKEj <u>**DOB**</u>: 1994-08-29 <u>**gender**</u>: male <u>**address**</u>: Boston, MA 02467 | `AllergyIntolerance` `CarePlan` `CareTeam` `Condition` `Coverage` `DiagnosticReport` `DocumentReference` `Encounter` `Observation` `Patient` `Procedure` `ServiceRequest` |
| Keva Green | <u>**FHIR ID**</u>: 81c2f5eb-f99f-40c4-b504-59483e6148d7 <u>**MR**</u>: kyHGADnvX3xbkU4V9ayaqh <u>**DOB**</u>: 1995-08-26 <u>**gender**</u>: female <u>**address**</u>: Hillsboro, OR 97123 _Note_: This is an editable test patient, so demographic data may be different from what you see listed here. | `Account` `AllergyIntolerance` `Appointment` `Condition` `Coverage` `DiagnosticReport` `DocumentReference` `Encounter` `Immunization` `MedicationRequest` `MedicationAdministration` `RelatedPerson` `ServiceRequest` `Specimen` |

> **Test patients CSV file**
>
> Our sandbox environment has hundreds of available test patients seeded with associated clinical data. Find the <u>Test Patients</u> CSV file on the <u>Developer</u> \> <u>Test Tools</u> \> <u>Dev Tool Downloads</u> page of the Redox dashboard. The patients in the CSV file support read, query, _and_ writeback requests. [Learn how to use developer test tools](/how-to-use-redox/use-developer-test-tools).
>
> ![Download a CSV file with the test patients available in the Redox FHIR sandbox.](https://images.ctfassets.net/cl3wt5ehhnlv/5hRc6xf4xkcfnV5FpSC2bz/43290cb7ce1af36810a55fa95f7b7f58/dev-tool-downloads-fhir-test-patients.png)

> **FYI: Data from Synthea**
>
> We generated some of our test data from an open-source dataset called Synthea™. 
>
> > Jason Walonoski, Mark Kramer, Joseph Nichols, Andre Quina, Chris Moesel, Dylan Hall, Carlton Duffett, Kudakwashe Dube, Thomas Gallagher, Scott McLachlan, Synthea: An approach, method, and software mechanism for generating synthetic patients and the synthetic electronic health care record, _Journal of the American Medical Informatics Association_, Volume 25, Issue 3, March 2018, Pages 230–238, [https://doi.org/10.1093/jamia/ocx079](https://doi.org/10.1093/jamia/ocx079)

### Example search responses

Refer to the code examples below to see what kind of responses to expect. So you know, the `bundle.id` field in the response is different for each request.

**Example: Response for a patient search with MR identifier**

```json
{
  "id": "30e87b5f-f3ae-4118-99e2-6b06621c1d37",
  "resourceType": "Bundle",
  "type": "searchset",
  "entry": [
    {
      "resource": {
        "id": "5a8ca233-5aee-47a7-b5d1-9976a94a98f7",
        "environment_id": "d7c2d4d0-4349-49ac-bd58-9bc9d722d359",
        "identifier": [
          {
            "value": "1X45iGXUozTwnc5dsJKFAe",
            "system": "urn:redox:redox-fhir-sandbox:MR"
          },
          {
            "use": "secondary",
            "value": "S99910612",
            "system": "urn:redox:redox-fhir-sandbox:DL"
          },
          {
            "use": "secondary",
            "value": "X37324658X",
            "system": "urn:redox:redox-fhir-sandbox:PPN"
          },
          {
            "use": "secondary",
            "value": "999-68-4590",
            "system": "http://hl7.org/fhir/sid/us-ssn"
          }
        ],
        "active": true,
        "name": [
          {
            "use": "official",
            "given": ["Gus"],
            "family": "Smitham"
          }
        ],
        "telecom": [
          {
            "use": "home",
            "value": "555-100-8501",
            "system": "phone"
          },
          {
            "use": "mobile",
            "value": "555-817-9005",
            "system": "phone"
          },
          {
            "value": "Gus.Smitham-98@syntheamail.com",
            "system": "email"
          }
        ],
        "gender": "male",
        "birthDate": "1948-01-06",
        "deceasedDateTime": null,
        "address": [
          {
            "use": "home",
            "city": "Beaverton",
            "line": ["933 Fritsch Way"],
            "state": "MI",
            "country": "US",
            "postalCode": "48612"
          }
        ],
        "maritalStatus": {
          "text": "S",
          "coding": [
            {
              "code": "S",
              "system": "http://hl7.org/fhir/v3/MaritalStatus",
              "display": "Never Married"
            }
          ]
        },
        "generalPractitioner": [
          {
            "reference": "Practitioner/88c69bfc-96ce-4bc7-b9dc-9420ba14b6fc"
          }
        ],
        "link": null,
        "created_at": "2020-10-12T18:23:12.162Z",
        "updated_at": null,
        "contact": null,
        "extension": [
          {
            "url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-race",
            "extension": [
              {
                "url": "text",
                "valueString": "White"
              }
            ]
          },
          {
            "url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity",
            "extension": [
              {
                "url": "ombCategory",
                "valueCoding": {
                  "code": "2186-5",
                  "system": "urn:oid:2.16.840.1.113883.6.238",
                  "display": "Non Hispanic or Latino"
                }
              },
              {
                "url": "text",
                "valueString": "Not Hispanic"
              }
            ]
          }
        ],
        "communication": [
          {
            "language": {
              "text": "English"
            }
          }
        ],
        "meta": null,
        "contained": null,
        "resourceType": "Patient"
      },
      "search": {
        "mode": "match",
        "score": 1
      }
    }
  ],
  "total": 1
}

```

**Example: Response for a patient search with SSN identifier**

```json
{
  "id": "a9ff2e9f-3bb6-4ed4-a154-ebeb6c271f24",
  "resourceType": "Bundle",
  "type": "searchset",
  "entry": [
    {
      "resource": {
        "id": "34d5d139-4cd8-4edc-8736-f25bdcad2b9e",
        "environment_id": "d7c2d4d0-4349-49ac-bd58-9bc9d722d359",
        "identifier": [
          {
            "value": "hgJfcpJnHWDpoYFmNWjtpu",
            "system": "urn:redox:redox-fhir-sandbox:MR"
          },
          {
            "use": "secondary",
            "value": "999-44-3722",
            "system": "http://hl7.org/fhir/sid/us-ssn"
          }
        ],
        "active": true,
        "name": [
          {
            "use": "official",
            "given": ["Jude"],
            "family": "Welch"
          }
        ],
        "telecom": [
          {
            "use": "home",
            "value": "555-360-1507",
            "system": "phone"
          },
          {
            "use": "mobile",
            "value": "555-798-2412",
            "system": "phone"
          },
          {
            "value": "Jude.Welch-19@syntheamail.com",
            "system": "email"
          }
        ],
        "gender": "male",
        "birthDate": "2008-04-11",
        "deceasedDateTime": null,
        "address": [
          {
            "use": "home",
            "city": "Troy",
            "line": ["806 Durgan Alley Unit 4"],
            "state": "OH",
            "country": "US",
            "postalCode": "45373"
          }
        ],
        "maritalStatus": {
          "text": "Never Married",
          "coding": [
            {
              "code": "S",
              "system": "http://hl7.org/fhir/v3/MaritalStatus",
              "display": "Never Married"
            }
          ]
        },
        "generalPractitioner": [
          {
            "reference": "Practitioner/a09eca7c-f69e-42ac-bf65-d24b33dd9c37"
          }
        ],
        "link": null,
        "created_at": "2020-10-12T19:33:46.130Z",
        "updated_at": null,
        "contact": null,
        "extension": [
          {
            "url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-race",
            "extension": [
              {
                "url": "text",
                "valueString": "White"
              }
            ]
          },
          {
            "url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity",
            "extension": [
              {
                "url": "ombCategory",
                "valueCoding": {
                  "code": "2186-5",
                  "system": "urn:oid:2.16.840.1.113883.6.238",
                  "display": "Non Hispanic or Latino"
                }
              },
              {
                "url": "text",
                "valueString": "Not Hispanic"
              }
            ]
          }
        ],
        "communication": [
          {
            "language": {
              "text": "English"
            }
          }
        ],
        "meta": null,
        "contained": null,
        "resourceType": "Patient"
      },
      "search": {
        "mode": "match",
        "score": 1
      }
    }
  ],
  "total": 1
}
```

**Example: Response for a patient search with demographics and phone number**

```json
{
  "id": "d4440bbb-bb71-46b7-8d1a-316cd84a5ebf",
  "resourceType": "Bundle",
  "type": "searchset",
  "entry": [
    {
      "resource": {
        "id": "35cc950a-aa90-4130-b6a8-9dd83965fc42",
        "environment_id": "d7c2d4d0-4349-49ac-bd58-9bc9d722d359",
        "identifier": [
          {
            "value": "ctQgwYF6kNCgiuxdb7z7p9",
            "system": "urn:redox:redox-fhir-sandbox:MR"
          },
          {
            "use": "secondary",
            "value": "S99921352",
            "system": "urn:redox:redox-fhir-sandbox:DL"
          },
          {
            "use": "secondary",
            "value": "X10211256X",
            "system": "urn:redox:redox-fhir-sandbox:PPN"
          },
          {
            "use": "secondary",
            "value": "999-26-7604",
            "system": "http://hl7.org/fhir/sid/us-ssn"
          }
        ],
        "active": true,
        "name": [
          {
            "use": "official",
            "given": ["Earnest"],
            "family": "Mitchell"
          }
        ],
        "telecom": [
          {
            "use": "home",
            "value": "555-762-3229",
            "system": "phone"
          },
          {
            "value": "Earnest.Mitchell-15@syntheamail.com",
            "system": "email"
          }
        ],
        "gender": "male",
        "birthDate": "1998-06-10",
        "deceasedDateTime": null,
        "address": [
          {
            "use": "home",
            "city": "Summit",
            "line": ["746 Kohler Trail"],
            "state": "NJ",
            "country": "US"
          }
        ],
        "maritalStatus": {
          "text": "Never Married",
          "coding": [
            {
              "code": "S",
              "system": "http://hl7.org/fhir/v3/MaritalStatus",
              "display": "Never Married"
            }
          ]
        },
        "generalPractitioner": [
          {
            "reference": "Practitioner/03ed22e7-1b0a-4313-9c7d-0fb09d219483"
          }
        ],
        "link": null,
        "created_at": "2020-10-12T17:55:58.565Z",
        "updated_at": null,
        "contact": null,
        "extension": [
          {
            "url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-race",
            "extension": [
              {
                "url": "text",
                "valueString": "White"
              }
            ]
          },
          {
            "url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity",
            "extension": [
              {
                "url": "ombCategory",
                "valueCoding": {
                  "code": "2186-5",
                  "system": "urn:oid:2.16.840.1.113883.6.238",
                  "display": "Non Hispanic or Latino"
                }
              },
              {
                "url": "text",
                "valueString": "Not Hispanic"
              }
            ]
          }
        ],
        "communication": [
          {
            "language": {
              "text": "English"
            }
          }
        ],
        "meta": null,
        "contained": null,
        "resourceType": "Patient"
      },
      "search": {
        "mode": "match",
        "score": 1
      }
    }
  ],
  "total": 1
}

```

**Example: Response for a patient search with demographics and city/state**

```json
{
  "id": "b6aad1be-024e-4b7c-80dd-32a144a8c91e",
  "resourceType": "Bundle",
  "type": "searchset",
  "entry": [
    {
      "resource": {
        "id": "4c5d0ad8-cd0f-45fc-a670-5f9c7cabf844",
        "environment_id": "d7c2d4d0-4349-49ac-bd58-9bc9d722d359",
        "identifier": [
          {
            "value": "vnFCX1PcEi7FAm32jrbnjj",
            "system": "urn:redox:redox-fhir-sandbox:MR"
          },
          {
            "use": "secondary",
            "value": "S99987926",
            "system": "urn:redox:redox-fhir-sandbox:DL"
          },
          {
            "use": "secondary",
            "value": "999-37-3216",
            "system": "http://hl7.org/fhir/sid/us-ssn"
          }
        ],
        "active": true,
        "name": [
          {
            "use": "official",
            "given": ["Ana Luisa"],
            "family": "Salgado"
          }
        ],
        "telecom": [
          {
            "use": "home",
            "value": "555-252-2071",
            "system": "phone"
          },
          {
            "use": "mobile",
            "value": "555-310-4913",
            "system": "phone"
          },
          {
            "value": "Ana Luisa.Salgado-41@syntheamail.com",
            "system": "email"
          }
        ],
        "gender": "female",
        "birthDate": "2003-11-25",
        "deceasedDateTime": null,
        "address": [
          {
            "use": "home",
            "city": "Paterson",
            "line": ["471 Kuhlman Burg Apt 32"],
            "state": "NJ",
            "country": "US",
            "postalCode": "07502"
          }
        ],
        "maritalStatus": {
          "text": "Never Married",
          "coding": [
            {
              "code": "S",
              "system": "http://hl7.org/fhir/v3/MaritalStatus",
              "display": "Never Married"
            }
          ]
        },
        "generalPractitioner": [
          {
            "reference": "Practitioner/23d36780-ec5b-4491-8a74-046fcbd922bf"
          }
        ],
        "link": null,
        "created_at": "2020-10-12T12:42:05.459Z",
        "updated_at": "2020-10-12T16:45:01.513Z",
        "contact": null,
        "extension": [
          {
            "url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-race",
            "extension": [
              {
                "url": "text",
                "valueString": "White"
              }
            ]
          },
          {
            "url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-ethnicity",
            "extension": [
              {
                "url": "ombCategory",
                "valueCoding": {
                  "code": "2135-2",
                  "system": "urn:oid:2.16.840.1.113883.6.238",
                  "display": "Hispanic or Latino"
                }
              },
              {
                "url": "text",
                "valueString": "Hispanic"
              }
            ]
          }
        ],
        "communication": [
          {
            "language": {
              "text": "Spanish"
            }
          }
        ],
        "meta": null,
        "contained": null,
        "resourceType": "Patient"
      },
      "search": {
        "mode": "match",
        "score": 1
      }
    }
  ],
  "total": 1
}

```

## Write data to the Redox FHIR sandbox

Our FHIR sandbox supports saving information from external systems. This allows you to:

- Create unique patient populations specific to your system or product.
- Create and assign unique clinical data to patient records.
- Write test results or documents to one of your test patient records.

> **Writeback not supported for Redox patients**
>
> You can only perform writeback requests for test patient records you’ve created, not Redox test patients.



The sandbox supports all of our FHIR writeback requests. [Learn about writeback requests](https://docs.redoxengine.com/permalink/44VsShfybmUTSeXD7s7KtJ/#fhir-writeback).

> **Confidential data**
>
> You shouldn’t include confidential data, like personal health information (PHI), when writing data to the Redox FHIR sandbox. Since it’s a testing environment, users from multiple organizations may save data with yours. Or if they query, they may unintentionally retrieve your saved data. Like its name suggests, our sandbox is a community tool and should be treated as such.

> **Writeback only available to Redox customers**
>
> You must be a Redox customer to use writeback requests in the FHIR sandbox. Writeback is available to you as a customer, whether you’re testing your initial development or after you’ve already implemented hundreds of connections.
>
> If you’re not a customer yet, you can still perform reads and queries to the sandbox, but not writebacks. [Talk to a Redoxer](https://redoxengine.com/forms/contact-us/) if you’re interested in the writeback feature of our FHIR sandbox.

### Writeback tips

To send a successful writeback request, we recommend reviewing some best practices.

<details>
<summary>Don’t copy examples from Redox FHIR API schemas</summary>

We don’t recommend copying and pasting the examples in our FHIR API specs. Our examples show the full capacity of each API schema. The schemas don’t contain realistic required values to successfully send a writeback message to the FHIR sandbox.

</details>

<details>
<summary>Start with a Bundle object</summary>

All requests to the Redox FHIR sandbox should first include a `Bundle` resource type. It should contain an `entry` array and a `type: message`. [Learn more about the Bundle resource](https://www.hl7.org/fhir/bundle.html).

**Example: Bundle resource in a writeback request**

```json
{
  "resourceType": "Bundle",
  "type": "message",
  "timestamp": "2024-07-15T22:05:54.0335865+00:00",
  "entry": [] // include objects for additional resources
}
```

You may include an `id` parameter in the Bundle object to identify the bundle, but it’s not required.

For real-world logs, most FHIR servers won’t consume a full bundle but will instead consume single resources to specific endpoints. If your connection requires this, we’ll handle the configuration for you.

</details>

<details>
<summary>Include a MessageHeader resource</summary>

The `MessageHeader` resource specifies metadata for the writeback request for the downstream FHIR server. This includes data about your organization, including the `source.name`, `source.endpoint`, and a unique identifier for the source. You should consider this a requirement in your bundle.

This resource also includes a `focus` array, where you should reference the resource you’re using to exchange data. For example, `Appointment/$appointment-create` would include the `fullURL` of the `Appointment` resource in the bundle. Or, `Patient/$patient-create` would include the `fullURL` of the `Patient` resource in the bundle.

[Review the possible FHIR resources](https://docs.redoxengine.com/permalink/fhir-resources-landing-page) to include.

</details>

<details>
<summary>Use resource IDs and fullURLs correctly</summary>

First, [learn how to handle FHIR identifiers](/implementation-guide/handle-fhir-identifiers-and-match-patient-data). Next, review recommendations specific to the FHIR sandbox:

##### Writing data to existing resources

Use the FHIR resource ID within the `id` value of the specific FHIR resources. This should be a UUID for the FHIR sandbox, which you should've gotten this from a previous `_search` or `read` request. 

##### Creating new resources

Though it’s technically allowed, don’t assign a FHIR resource ID in the `entry.resource.id`. The destination FHIR server is typically the source of truth for assigning FHIR identifiers to a payload.

Instead, assign a `fullURL` value to the resource. This allows your system to attach an identifier to the resource so you can link it elsewhere within the payload without assigning an FHIR ID. The destination should assign the actual FHIR ID.

We recommend using a UUID as the `fullURL` value, prefaced by `urn:uuid`, although these can be assigned as URLs by your system as well. For example, you could include `urn:uuid:245a33e0-e187-4850-aebc-4e86dd2111b2`, where the value after the colon is your system’s unique identifier for the resource. This `fullURL` can be used as a reference anywhere else you need in the payload.

</details>

<details>
<summary>Reference resources within the bundle appropriately</summary>

A <u>**bundle**</u> is an assortment of related but independent FHIR resources. A <u>**reference**</u> indicates a one-way relationship from one resource to another. References are crucial for maintaining data integrity and context in a bundle. [Check out the FHIR glossary](/basics/redox-fhir-api/fhir-glossary) for more definitions and details.

You can use references to link to existing resources in the FHIR sandbox. That means you don’t necessarily have to include the full resource every time you reference it. See the example `Observation` resource below, which includes references to related `Patient` and `Encounter` resources.

**Example: Observation resource with Patient and Encounter references**

```json
{
    "fullUrl": "urn:uuid:c1672713-83ed-69b6-2242-75b0f0cc7d66",
    "resource": {
      "resourceType": "Observation",
      "id": "c1672713-83ed-69b6-2242-75b0f0cc7d66",
      "status": "final",
      "category": [ {
        "coding": [ {
          "system": "http://terminology.hl7.org/CodeSystem/observation-category",
          "code": "vital-signs",
          "display": "vital-signs"
        } ]
      } ],
      "code": {
        "coding": [ {
          "system": "http://loinc.org",
          "code": "8302-2",
          "display": "Body Height"
        } ],
        "text": "Body Height"
      },
      "subject": {
        "reference": "Patient/307b6419-5147-4716-10b1-bb458ac191c3"
      },
      "encounter": {
        "reference": "urn:uuid:1bea528e-d3e4-6f65-bc23-982eee4d618d"
      },
      "effectiveDateTime": "2021-09-11T20:15:57-04:00",
      "issued": "2021-09-11T20:15:57.319-04:00",
      "valueQuantity": {
        "value": 160.8,
        "unit": "cm",
        "system": "http://unitsofmeasure.org",
        "code": "cm"
      }
    }
}
```

When creating a writeback bundle, make sure the `reference` fields contain either the:

1. resource ID
2. `fullURL`

The example above shows both types. If the resource already exists in the FHIR sandbox, use the resource ID. If the resource doesn’t exist, use the `fullURL`. Including incorrect references in the bundle will cause your message to fail.

Also, the message may fail if you’re copying example payloads from our FHIR specs. The intent of our FHIR specs is to show the full schema shape, not necessarily provide a sample call for you to use.

</details>

<details>
<summary>Know when to create vs. reference resources</summary>

In a writeback message, there are extra FHIR resources in the bundle. For example, you might send `Appointment/$appointment-create`, but you’ll see `Patient`, `Practitioner`, `Location`, `Encounter`, and other resources included. If those extra resources don’t exist in the FHIR sandbox, your writeback message might create new resources.

- _To include existing resources in the FHIR sandbox_, include the full resource with the resource ID. If you don’t have the resource ID, you can query for it first. The FHIR sandbox looks at the resource ID, resource type, and identifiers to determine if there’s already a matching resource.
- _To include new resources_ (or if there wasn’t a matching resource in the scenario above), enter all the required elements for the given resource and assign it a `fullURL`. A new resource will be created and assigned a unique resource ID. This is likely how your connection’s FHIR server will behave in production as well.
  - If your connections use HL7v2, we recommend including all the resources and data points you have within the writeback bundle.
  - If your connections use FHIR, including extra resources within the bundle (besides the main resource you’re using) is less important.

When a new resource ID is assigned, you’ll see it in the response’s URL (e.g., `Appointment/bf4d58c5-aeaa-4c2f-8c69-c57c9f198637`: `https://fhir.redoxengine.com/fhir-sandbox/Appointment/bf4d58c5-aeaa-4c2f-8c69-c57c9f198637/_history/MTcyMTk0MDUyODQyNDg5NDAwMA`).

</details>

> **Troubleshoot FHIR writeback errors**
>
> We all need a little help sometimes. If you run into errors, [check out our troubleshooting guide](/troubleshooting/troubleshoot-fhir-writeback-errors).

### Static administration resource examples

You’ll typically need to include administrative references for writeback messages, like `Practitioner`, `Location`, and `Organization`. Below are some example references you can use as inputs to leverage existing resources in your test bundles:

| **Resource** | **Examples** |
| --- | --- |
| `Practitioner` | `Practitioner/7efc2275-b837-42d7-af6d-1386f8a618ae` `Practitioner/dbed0f85-e3cd-47ac-9305-3f629e138832` `Practitioner/264f7ec9-3bd4-3268-b88c-ec9618b4dd1a` `Practitioner/fff2db55-4039-42b6-a3c1-c61991b6752b` `Practitioner/ffff2b69-26d1-46a8-bd2d-1cdc38eb7ba0` |
| `Location` | `Location/0066e68c-8ea1-46f2-9716-40410b97894d` `Location/006eed1d-6691-496a-b36d-90a666f4f27d` `Location/ed4afd58-9796-4cc5-aed7-5c47345acec9` `Location/02321b8d-5096-4797-a7a7-dece90df4342` `Location/02bd7825-dd5f-4264-880b-7d9f846de281` |
| `Organization` | `Organization/1aedcb45-c507-3ad0-9010-6583d264ae72` `Organization/308b5efa-a9c2-3728-b1ff-d29c5f060731` `Organization/90cf148c-69ed-3d33-aa86-b509c6b0b25f` `Organization/700056a6-3aea-3efd-8423-a9acbd38a5ea` `Organization/0f7f97f6-693c-3de9-8190-85feaf4632e2` |

### Example writeback responses

You can typically expect either a `200` or `201` in response to your writeback message.

| **HTTP response** | **Description** |
| --- | --- |
| `200` | A resource that already exists in the FHIR sandbox was successfully updated with the content in your writeback payload. The resource ID was updated can be found in the `location` value. |
| `201` | A resource was created within the FHIR sandbox. This means the the sandbox didn’t locate a resource that matched the input criteria. |

Individual resource responses will be included in the `entry` array of the response. The number of objects depends on the number of resources included within your bundle.

Refer to the example below if you want to know what kind of response to expect.

**Example: Successful writeback response**

```json
  "body": {
    "entry": [
      {
        "response": {
          "etag": "W/\"MTcyMTA2NTY2MzE0OTAyMTAwMA\"",
          "lastModified": "2024-07-15T17:47:43.149021+00:00",
          "location": "https://fhir.redoxengine.com/fhir-sandbox/Appointment/bf4d58c5-aeaa-4c2f-8c69-c57c9f198637/_history/MTcyMTA2NTY2MzE0OTAyMTAwMA",
          "status": "201 Created"
        }
      },
      {
        "response": {
          "etag": "W/\"MTcyMTA2NTY2MzE0OTAyMTAwMA\"",
          "lastModified": "2024-07-15T17:47:43.149021+00:00",
          "location": "https://fhir.redoxengine.com/fhir-sandbox/Patient/b0a06ead-cc42-aa48-dad6-841d4aa679fa/_history/MTcyMTA2NTY2MzE0OTAyMTAwMA",
          "status": "200 OK"
        }
      }
    ],
    "resourceType": "Bundle",
    "type": "transaction-response"
  }
```
