> ## Documentation Index
> Fetch the complete documentation index at: https://docs.osaconnection.com/llms.txt
> Use this file to discover all available pages before exploring further.

# ESX exports

> Send a roof you have measured and get back an Xactimate ESX file built from it: check, send, poll, download, correct.

Send OSA a roof you have measured, in OSA's [roof format](https://docs.osaconnection.com/roof-format.md), and get back an Xactimate ESX file. OSA checks the roof, has the export provider build the ESX, and gives you a link to the file.

The ESX holds the roof as a sketch (faces, edges, dimensions), with no line items or prices.

Sending and checking a roof is not charged. The first time you ask for a live export's ESX is charged as one **use**: see [What counts as a use](https://docs.osaconnection.com/esx-export-uses.md).

## How it works

The usual path, from a roof to its file:

```mermaid theme={"system"}
sequenceDiagram
    participant You as Your system
    participant OSA
    participant Provider as Export provider
    opt Check first (not charged)
        You->>OSA: POST /v1/esx-exports/checks
        OSA-->>You: 200, every problem found
    end
    You->>OSA: POST /v1/esx-exports
    OSA->>Provider: The roof, to be built
    OSA-->>You: 202, status processing
    loop No more than once every 5 seconds
        You->>OSA: GET /v1/esx-exports/{id}
        OSA->>Provider: Is it built?
        OSA-->>You: processing, ready or failed
    end
    You->>OSA: POST /v1/esx-exports/{id}/download
    OSA-->>You: download_url, valid for one hour
    You->>Provider: GET download_url, without your OSA key
    Provider-->>You: The ESX file
```

**1. Check the roof (optional)**

`POST /v1/esx-exports/checks` answers with every problem it finds. No export is recorded and nothing is charged, so check as often as you like.

**2. Send the roof**

`POST /v1/esx-exports` checks the roof and sends it to the export provider. The answer is `202` with the export and any warnings, usually `status: processing`.

**3. Poll the export**

`GET /v1/esx-exports/{id}`, no more than once every 5 seconds, until the export is `ready` or `failed`.

**4. Ask for the file**

`POST /v1/esx-exports/{id}/download` answers with a link to the ESX, valid for one hour. Fetch the file from the link without your OSA key.

**5. Correct it if you need to**

`POST /v1/esx-exports/{id}/versions` sends a corrected roof to the same export, which is built again.

Your key needs `esx-exports:create` to check, send and correct a roof, and `esx-exports:read` to read exports and ask for the file. See [Authentication](https://docs.osaconnection.com/authentication.md#permissions).

## Send a roof

A request has your id for the order (`reference`), the roof (`input`) and the `property` it is on. This one sends a gable roof, 40 by 30 ft, pitch 6/12, eaves 9 ft above the ground:

```bash theme={"system"}
curl https://api.osaconnection.com/v1/esx-exports \
  -H "Authorization: Bearer $OSA_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: 7c4e2b9a-1f3d-4e8a-b6c5-0d9e8f7a6b5c" \
  -d '{
    "reference": "ORDER-1042",
    "input": {
      "type": "roof",
      "format": "osa-roof/1",
      "plan": { "units": "ft", "y_axis": "up", "north_deg": 0 },
      "structures": [
        {
          "id": "house",
          "points": [
            { "id": "a", "x": -20, "y": -15 },
            { "id": "b", "x": 20, "y": -15 },
            { "id": "c", "x": 20, "y": 15 },
            { "id": "d", "x": -20, "y": 15 },
            { "id": "e", "x": -20, "y": 0 },
            { "id": "f", "x": 20, "y": 0 }
          ],
          "edges": [
            { "id": "eave-s", "from": "a", "to": "b", "type": "eave" },
            { "id": "eave-n", "from": "c", "to": "d", "type": "eave" },
            { "id": "ridge", "from": "e", "to": "f", "type": "ridge" },
            { "id": "rake-sw", "from": "a", "to": "e", "type": "rake" },
            { "id": "rake-se", "from": "b", "to": "f", "type": "rake" },
            { "id": "rake-ne", "from": "c", "to": "f", "type": "rake" },
            { "id": "rake-nw", "from": "d", "to": "e", "type": "rake" }
          ],
          "faces": [
            { "id": "south", "edges": ["eave-s", "rake-se", "ridge", "rake-sw"], "pitch": 6, "eave_height_ft": 9 },
            { "id": "north", "edges": ["eave-n", "rake-nw", "ridge", "rake-ne"], "pitch": 6, "eave_height_ft": 9 }
          ]
        }
      ]
    },
    "property": {
      "street": "740 Canyon View Drive",
      "city": "Lehi",
      "state": "UT",
      "zip": "84043",
      "lat": 40.4358,
      "lon": -111.8683
    }
  }'
```

`POST /v1/esx-exports/checks` takes the same body, without the `Idempotency-Key` header. You can also send `claim_number`, `end_user` (who in your system asked) and your own `metadata`; each is returned as sent. The [API reference](https://docs.osaconnection.com/api-reference/esx-exports/send-a-roof-to-be-built-into-an-esx.md) lists every field.

The answer comes before the build finishes:

```json theme={"system"}
{
  "id": "3f0c8a6e-5b1d-4c0e-9a77-2f6d1e4b8c90",
  "reference": "ORDER-1042",
  "test": false,
  "status": "processing",
  "failure": null,
  "clean": true,
  "major_warnings": 0,
  "minor_warnings": 0,
  "warnings": [],
  "provider_messages": [],
  "version": 1,
  "created_at": "2026-12-01T15:42:10Z",
  "updated_at": "2026-12-01T15:42:13Z",
  "ready_at": null,
  "first_downloaded_at": null,
  "claim_number": null,
  "end_user": null,
  "metadata": {}
}
```

* **`Idempotency-Key` is required.** A retry with the same key within 24 hours returns the export as it is now and creates nothing new. Only a `202` is replayed: see [Limits and idempotency](https://docs.osaconnection.com/limits-and-idempotency.md#esx-exports).
* **One export per reference.** A `reference` you have already used, in the key's environment, is refused with `409 duplicate_export`, which names the existing export. Send a correction as a new version of it.
* **The roof is checked every time**, whether or not you checked it first.

What you get back when you send a roof:

```mermaid theme={"system"}
flowchart TD
    A["POST /v1/esx-exports"] --> C{"Critical problem<br/>in the roof?"}
    C -- yes --> R2["422<br/>validation_failed"]
    C -- no --> D{"reference<br/>already used?"}
    D -- yes --> R3["409<br/>duplicate_export"]
    D -- no --> E{"Export provider<br/>reached?"}
    E -- no --> R4["503<br/>export_provider_unavailable"]
    E -- yes --> R5["202<br/>processing, or failed<br/>with build_refused"]
```

Only a `202` creates an export. A `422`, `409` or `503` records nothing and charges nothing.

## Warnings

A roof is refused only for a **critical** problem, one that means it cannot be built. The answer is `422 validation_failed` with every problem found in `errors`, and nothing is recorded.

Every other problem is a **warning**, `major` or `minor`. The ESX is built anyway, and each warning says where it is and what OSA did about it. You can correct it in the ESX, or send a corrected version.

On the export, `clean` is `true` when there are no warnings, `major_warnings` and `minor_warnings` count them, and `warnings` lists at most 100, `major` ones first. [Roof checks and problems](https://docs.osaconnection.com/roof-checks.md) lists every check and warning.

`provider_messages` holds anything the export provider said when it took the file: free text, usually empty, with no effect on `clean`. Don't parse it.

## Poll the export

```bash theme={"system"}
curl https://api.osaconnection.com/v1/esx-exports/3f0c8a6e-5b1d-4c0e-9a77-2f6d1e4b8c90 \
  -H "Authorization: Bearer $OSA_API_KEY"
```

Poll no more than once every 5 seconds per export, until it is `ready` or `failed`. With many exports in flight, spread your polls to stay inside your key's [rate limit](https://docs.osaconnection.com/limits-and-idempotency.md), which is lower for a test key. Reading a `processing` export asks the export provider for the build's status; it never sends or resends anything.

```json theme={"system"}
{
  "id": "3f0c8a6e-5b1d-4c0e-9a77-2f6d1e4b8c90",
  "reference": "ORDER-1042",
  "test": false,
  "status": "ready",
  "failure": null,
  "clean": true,
  "major_warnings": 0,
  "minor_warnings": 0,
  "warnings": [],
  "provider_messages": [],
  "version": 1,
  "created_at": "2026-12-01T15:42:10Z",
  "updated_at": "2026-12-01T15:42:26Z",
  "ready_at": "2026-12-01T15:42:26Z",
  "first_downloaded_at": null,
  "claim_number": null,
  "end_user": null,
  "metadata": {}
}
```

Poll this endpoint, not the list: `GET /v1/esx-exports` shows each export as last recorded and refreshes nothing. Use the list to catch up or reconcile: see [Polling](https://docs.osaconnection.com/polling.md#esx-exports).

An export moves between three statuses. A corrected roof takes it round again as a new version:

```mermaid theme={"system"}
flowchart TD
    S(["Send a roof,<br/>or a new version"]) --> P["processing"]
    S -. "build_refused, or a version<br/>not sent (build_failed)" .-> X["failed"]
    P -- "built" --> R["ready"]
    P -- "build_failed<br/>build_timeout" --> X
    R -- "ask for the file" --> L(["Link to the ESX"])
    R -- "new version" --> S
    X -- "new version" --> S
```

| `status` | Meaning |
| - | - |
| `processing` | Received and on its way through the build |
| `ready` | The ESX can be asked for |
| `failed` | Not built; `failure` says why |

An export not `ready` 10 minutes after its latest version was sent becomes `failed` with reason `build_timeout`. This is applied when the export is read by id, or when a version or its file is asked for; never by the list.

| `failure.reason` | What happened | What to do |
| - | - | - |
| `build_refused` | The export provider refused the file. `failure.detail` gives its words | Correct the roof and send a new version. If the fault is not clear, [contact OSA](https://docs.osaconnection.com/introduction.md#support) with the export's `id` |
| `build_failed` | The export provider took the file and could not build it, or a version could not be sent to it | Send the same roof again as a new version. If it fails again, [contact OSA](https://docs.osaconnection.com/introduction.md#support) with the export's `id` |
| `build_timeout` | Not ready 10 minutes after it was sent | Send the same roof as a new version |

`failure.detail` is for people; match on `reason`. Statuses and reasons are open enums: treat an unknown `status` as `processing` and an unknown `reason` as `build_failed`.

## Ask for the file

Before you ask, look at `clean` and `major_warnings`: the first time you ask for a live export's ESX is charged, whether or not it has warnings.

```bash theme={"system"}
curl -X POST https://api.osaconnection.com/v1/esx-exports/3f0c8a6e-5b1d-4c0e-9a77-2f6d1e4b8c90/download \
  -H "Authorization: Bearer $OSA_API_KEY"
```

Send no body. The answer is a link to the file and when it expires:

```json theme={"system"}
{
  "download_url": "https://files.example.com/esx/3f0c8a6e-5b1d-4c0e-9a77-2f6d1e4b8c90.esx?expires=1796143382&signature=9f2c7a1e",
  "expires_at": "2026-12-01T16:43:02Z"
}
```

Fetch the file from `download_url` within one hour. After that, ask again for a fresh link; that is not another use. OSA does not keep the file: the link is to the export provider's storage.

```bash theme={"system"}
curl -o ORDER-1042.esx "$DOWNLOAD_URL"
```

> [!WARNING]
>
> Fetch the link with a plain `GET` and no `Authorization` header: never send your OSA key to it. Anyone holding the link can download the file until it expires, so don't log or share it.

The export must be `ready`. One that is `processing` or `failed` answers `409 export_not_ready`, and nothing is charged.

## Correct a roof

Send the corrected roof to the same export, not as a new export: the `reference` is already used, and a new export is a new use when you ask for its file.

This sends the gable again, as you would after `build_timeout`. A corrected roof goes in the same place.

```bash theme={"system"}
curl https://api.osaconnection.com/v1/esx-exports/3f0c8a6e-5b1d-4c0e-9a77-2f6d1e4b8c90/versions \
  -H "Authorization: Bearer $OSA_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: 0e6f3c2a-8d4b-4f1e-9a7c-5b2d1e3f4a6c" \
  -d '{
    "input": {
      "type": "roof",
      "format": "osa-roof/1",
      "plan": { "units": "ft", "y_axis": "up", "north_deg": 0 },
      "structures": [
        {
          "id": "house",
          "points": [
            { "id": "a", "x": -20, "y": -15 },
            { "id": "b", "x": 20, "y": -15 },
            { "id": "c", "x": 20, "y": 15 },
            { "id": "d", "x": -20, "y": 15 },
            { "id": "e", "x": -20, "y": 0 },
            { "id": "f", "x": 20, "y": 0 }
          ],
          "edges": [
            { "id": "eave-s", "from": "a", "to": "b", "type": "eave" },
            { "id": "eave-n", "from": "c", "to": "d", "type": "eave" },
            { "id": "ridge", "from": "e", "to": "f", "type": "ridge" },
            { "id": "rake-sw", "from": "a", "to": "e", "type": "rake" },
            { "id": "rake-se", "from": "b", "to": "f", "type": "rake" },
            { "id": "rake-ne", "from": "c", "to": "f", "type": "rake" },
            { "id": "rake-nw", "from": "d", "to": "e", "type": "rake" }
          ],
          "faces": [
            { "id": "south", "edges": ["eave-s", "rake-se", "ridge", "rake-sw"], "pitch": 6, "eave_height_ft": 9 },
            { "id": "north", "edges": ["eave-n", "rake-nw", "ridge", "rake-ne"], "pitch": 6, "eave_height_ft": 9 }
          ]
        }
      ]
    }
  }'
```

* **Send `input`, and `property` only if the address or location changed.** `Idempotency-Key` is required, as for sending a roof.
* **An export that is `ready` or `failed` takes a new version.** One still `processing` answers `409 export_not_ready`; check it again shortly.
* **The corrected roof is checked again.** A critical problem answers `422 validation_failed` and leaves the export as it was.
* **The export keeps its `id` and `reference`**, and its `version` goes up by one. The answer is `202`, usually `status: processing`: poll it as before. If the provider refused the corrected file, the export is already `failed` with reason `build_refused`. `warnings`, the two counts, `clean`, `provider_messages` and `failure` describe the latest version only.
* **The earlier ESX is gone.** Once a new version is accepted, the earlier version's ESX can no longer be asked for, even if the new build fails.
* **It is not another use.** If you already asked for the export's ESX, asking for it again after the new version is not charged again.

## If the export provider is unavailable

If the export provider can't be reached, or fails part-way, the answer is `503 export_provider_unavailable` and nothing is charged. Wait for the number of seconds in `Retry-After`, then:

* **Sending a roof.** Nothing was created. Send the same request again with the same `Idempotency-Key`.
* **Sending a version.** If the provider failed before the version started to be sent, the export is left as it was. If it failed after sending started, the export is `failed` with reason `build_failed`: its `version` has gone up and the earlier file is no longer available. Either way, send the same request again (the same `Idempotency-Key` is fine); after a failed version it makes the next version.
* **Asking for the file.** Ask again.

## Test and live exports

An export sent with an `osa_test_` key is a **test export** (`"test": true`). It is built on a test system and never charged.

Test and live exports never overlap, which is stricter than for claims: a test key sees only test exports and a live key only live ones. An export of the other environment answers `404 not_found` and is never listed, and a `reference` is checked for duplicates only within the key's environment. See [Testing](https://docs.osaconnection.com/testing.md#test-exports).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.