---
title: "Simulator Upload"
method: POST
path: "/api/v1/simulator/upload"
tags: ["simulator"]
---

# Simulator Upload

`POST /api/v1/simulator/upload`

## Request

- The document declares no server URL.
- Auth: none declared

Handles the simulator upload workflow for eICR refinement.

Steps:
1. Obtain the simulator eICR ZIP file (either uploaded by user or from local sample in
    refiner/assets/demo/mon-mothma-covid-influenza.zip).
2. Read and validate the XML files (eICR and RR) from the ZIP (XMLFiles object).
3. Call the service layer (`simulator`) to orchestrate the refinement workflow.
4. For each unique reportable condition code found in the RR (and having a configuration),
    build a refined XML document and collect metadata. The code used is the actual code
    from the RR that triggered the match, not a canonical or database code.
5. Package all refined and original files into a ZIP.
6. Upload the ZIP to S3 and get a download URL.
7. Construct and return the response model for the frontend, including per-condition
    refinement results and a link to the ZIP of outputs.

Any exceptions during file processing or workflow execution are caught and mapped to HTTP errors.

## Request body `multipart/form-data`

- BodyUploadEcr
  - `body` string, required
  - `uploaded_file` string, binary, nullable

## Response `200`

Successful Response

- SimulatorUploadResponse: Model for the response when uploading a document in the simulate testing suite.
  - `message` string, required
  - `refined_conditions_found` integer, required
  - `refined_conditions` Condition[], required
    - `code` string, required
    - `display_name` string, required
    - `refined_eicr` string, required
    - `stats` string[], required
    - `render_diff` boolean, required
  - `unrefined_eicr` string, required
  - `refined_download_key` string, required
  - `file_info_response` FileInfoResponse, required: Utility class to help Orval ship these values to the frontend.
    - `max_for_diff_rendering_mb` 2
    - `max_for_uncompressed_mb` 15

## Other responses

- `422`: Validation Error

## Changes

- **2026-05-28** `f03e4ed9ca5e`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/cdcgov/apis/dibbs-ecr-refiner/changes/api/v1/simulator/upload/post.md)

---

[API](https://skmtc.dev/cdcgov/apis/dibbs-ecr-refiner.md) - [All operations](https://skmtc.dev/cdcgov/apis/dibbs-ecr-refiner/llms.txt) - [OpenAPI document](https://skmtc.dev/cdcgov/apis/dibbs-ecr-refiner/revisions/7312cd4b44ac?raw)
