Send a file to your connection(s) to provide clinical or administrative context for patients you share. Typically, you send a file to save to a patient’s chart. This article contains instructions for how to send a generic file with the Redox FHIR® API. If you want to send results-related documents, learn how to send results or vitals.
With Redox, you can send files to your connection(s) with either of these two methods:
- Upload a file to a Redox blob endpoint, then include the URL reference (recommended).
- Embed a file directly in the selected data model.
| Upload and reference file | Embed file | |
|---|---|---|
| Best for | Regularly sending large files.This is our recommended method since it improves our ability to process the request without errors. | Occasionally sending small files. |
| File size limit | Up to 30 MB. The file limit is separate from the overall request limit. For example, if the request limit is 10 MB, the uploaded file doesn’t need to fit within that threshold. | Must fit within the request’s size limit. Check limits by traffic type. Best practice: We recommend not embedding files over 200 KB. |
| Encoding | base64. Redox handles encoding the file. | base64. You must encode the file yourself. |
| Environment type | For paid accounts, available in any environment. For free accounts, only available in staging or production. If you try to upload files in a development environment with a free account, we return a 403 Forbidden error. | Available in any environment. |
| Available file download in the Redox dashboard | Yes. | No. |
If you haven’t already, review general file sending info.
To upload a file to the Redox endpoint, use the Binary resource, then include the URL reference in the DocumentReference$documentreference-create operation.
To embed a file, use the DocumentReference$documentreference-create operation.
- Decide which sending method to use (i.e., upload or embed a file).
- For free accounts choosing to upload and reference a file, log in to either a staging or production environment. Uploading isn’t available in free development environments. Talk to your Technical Account Manager about upgrading if you want to upload files in development.
Our recommended method is to upload a file to the Redox endpoint using the FHIR® Binary resource. Then, refer to the file in DocumentReference$documentreference-create.
- Locate the file you want to upload.
- Authenticate an OAuth API key like you would for any FHIR® API request. Learn how to authenticate and initiate a request.
- Upload your file to the Redox upload endpoint using the FHIR® Binary resource.Support for the FHIR Binary resource
- Replace {{ENVIRONMENT-FLAG}} with Development, Staging, or Production respectively.
- Replace $API_TOKEN with your access token.API token
- Add the Redox-source-Id header if you have more than one source in your environment. Learn about managing source details.
- Keep redox in the slug. That portion routes the request to the appropriate Redox upload endpoint.Example: Upload a file to Redox with the Binary resourcebash
- If the file upload is successful, you receive a 201 Created status. The reference URL is in the location header of the Binary response.Example: Binary response with the reference URLjson
- Reference the uploaded file in a DocumentReference$documentreference-create request to your connection. Refer to the DocumentReference schema for all the requirements.
- Include the required entry.resource.content.attachment fields with the URL reference to the uploaded file:
- In the url field, enter the URL reference from the Binary response.
- In the contentType field, enter a valid MIME type. Learn more about MIME types for files.
- (Optional) In the title field, enter the name of the file.Example: Reference the uploaded file in DocumentReference$documentreference-createbashAbbreviated code example
- To check if the file uploaded successfully, log in to the Redox dashboard and check the log for the request. The uploaded file displays under the Process tab of the log.
You can embed a file within the DocumentReference resource, so long as the file fits within the size limit for the type of traffic. Check limits by traffic type.
- Encode the file as a base64 encoded string.
- Authenticate an OAuth API key like you would for any FHIR® API request. Learn how to authenticate and initiate a request.
- Embed the uploaded file in a DocumentReference$documentreference-create request to your connection. Refer to the DocumentReference schema for all the requirements.
- Replace {{ENVIRONMENT-FLAG}} with Development, Staging, or Production respectively.
- Replace $API_TOKEN with your access token.
- Replace {{DESTINATION-SLUG}} with the human-readable safe name for the intended destination.
- Add the Redox-source-Id header if you have more than one source in your environment. Learn about managing source details.
- Populate the entry.resource.content.attachment fields to include the encoded file:
- In the contentType field, enter a valid MIME type. Learn more about MIME types for files.
- In the data field, insert the base64 encoded string for the file.
- (Optional) In the title field, enter the name of the file.Example: Embed a file in DocumentReference$documentreference-createbashAbbreviated code example
- To check if the embedded file sent successfully, log in to the Redox dashboard and check the log for the request. The embedded file displays in the log payload.