> ## 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.

# Roof checks and problems

> What OSA checks on every roof, which problems refuse it, which are warnings, and how a problem is shaped.

OSA checks every roof you send. A **critical** problem means the roof cannot be built, and it is refused. Any other problem is a **warning**: the roof is built anyway, and the warning says what OSA did about it.

The checks look at whether the drawing holds together, not whether it matches the real house: OSA cannot see that part of a roof is missing, only a drawing that contradicts itself.

## The request's shape comes first

Before any roof check, the request is checked against the [API reference](https://docs.osaconnection.com/api-reference/esx-exports/send-a-roof-to-be-built-into-an-esx.md): an unknown or misspelt field, a wrong type, or a value out of range. A request that fails answers `422 validation_failed`, with `errors` pointing at each field and no `check` or `severity`, and the roof checks do not run:

```json theme={"system"}
{
  "type": "https://docs.osaconnection.com/errors#validation_failed",
  "title": "Validation failed",
  "status": 422,
  "detail": "The request has 1 invalid field.",
  "code": "validation_failed",
  "request_id": "9a5b6c7d8e9f0a1b2c3d4e5f6a7b8c9d",
  "errors": [
    { "pointer": "/input/structures/0/faces/0", "detail": "must NOT have additional properties (low_egde)" }
  ]
}
```

Everything below applies to a well-shaped request. Rules the shape cannot show, such as two points with the same id, are check 1 problems (see [Critical problems](#critical-problems)).

## A problem

Each problem the roof checks find has the same four fields:

| Field | Meaning |
| - | - |
| `pointer` | A JSON Pointer to its place in the request, for example `/input/structures/0/faces/1` |
| `check` | The number of the check that found it (below) |
| `severity` | `error`, `major` or `minor` |
| `detail` | What is wrong, naming your own ids, and for a warning what OSA did about it. For people: don't parse it |

| `severity` | Meaning |
| - | - |
| `error` | Critical: the roof cannot be built and is refused |
| `major` | A warning: the roof is built anyway. Look at these before you ask for the file |
| `minor` | A warning: the roof is built anyway |

`severity` is an open enum: treat an unknown value as `major`. `check` numbers may be added too.

## Where problems appear

* **Checking a roof.** `POST /v1/esx-exports/checks` answers `200` with `buildable` and every problem found in `problems`. A roof that would be refused still gets `200`, with `buildable: false`. The `reference` is not checked for duplicates here.
* **A roof refused.** `POST /v1/esx-exports` and `POST /v1/esx-exports/{id}/versions` answer `422 validation_failed` when there is at least one `error`. `errors` then lists every problem the checks found, warnings included.
* **A roof built.** The export's `warnings` lists the latest version's warnings: at most 100, `major` ones first when there are more. `major_warnings` and `minor_warnings` count them exactly, and `clean` is `true` when there are none. `warnings` never holds an `error`.

A critical problem can stop the later checks on its structure, so the list may not be every problem the roof has. Check the roof again after correcting it.

A check that found one critical problem and one warning. The face `north` names an edge `rake-nx` that does not exist, and the edge it meant, `rake-ne`, lies on no face:

```json theme={"system"}
{
  "buildable": false,
  "problems": [
    {
      "pointer": "/input/structures/0/faces/1",
      "check": 2,
      "severity": "error",
      "detail": "Face `north` uses `rake-nx`, which is not an edge of structure `house`."
    },
    {
      "pointer": "/input/structures/0/edges/5",
      "check": 3,
      "severity": "minor",
      "detail": "Edge `rake-ne` (rake) lies on no face. It is left out of the roof."
    }
  ]
}
```

Sent to be built, the same roof is refused:

```json theme={"system"}
{
  "type": "https://docs.osaconnection.com/errors#validation_failed",
  "title": "Validation failed",
  "status": 422,
  "detail": "The roof can't be built. It has 1 critical problem and 1 warning.",
  "code": "validation_failed",
  "request_id": "7d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a",
  "errors": [
    {
      "pointer": "/input/structures/0/faces/1",
      "check": 2,
      "severity": "error",
      "detail": "Face `north` uses `rake-nx`, which is not an edge of structure `house`."
    },
    {
      "pointer": "/input/structures/0/edges/5",
      "check": 3,
      "severity": "minor",
      "detail": "Edge `rake-ne` (rake) lies on no face. It is left out of the roof."
    }
  ]
}
```

## The checks

| Check | What it looks at |
| - | - |
| 1 | The roof format's rules that the request's shape cannot show: a scale when `plan` is in pixels, unique ids, one way of giving heights, an overhang only on an eave or a rake, coordinates in range |
| 2 | Edges and faces refer to things that exist, and faces close |
| 3 | How edges sit on faces |
| 4 | Eaves and which way faces slope |
| 5 | Heights where faces meet |
| 6 | Heights given for every section |
| 7 | The property's ZIP and location |

## Critical problems

A roof with any of these is refused (`severity: error`).

| Check | Critical when |
| - | - |
| 1 | `units` is `px` and there is no `feet_per_pixel`, or there is a `feet_per_pixel` and `units` is `ft` |
| 1 | Two structures, or two points, edges or faces in one structure, have the same id |
| 1 | Some points of a structure have `z_ft` and others do not, or one structure uses both `z_ft` and `eave_height_ft` |
| 1 | An edge that is not an `eave` or a `rake` has an `overhang_ft` |
| 1 | A point's `x` or `y` is more than 1,000,000 plan units either way |
| 2 | A face or an edge cannot be measured, because two of its points are at the same place |
| 2 | An edge joins a point that does not exist, or its two ends are the same point |
| 2 | A face uses an edge that does not exist, lists an edge twice, or its edges do not close a loop in order |
| 2 | A face's `low_edge` is not one of the face's edges |
| 3 | An edge lies on more than two faces |
| 5 | A point's height cannot be worked out: for example, it lies only on faces that could not be placed, or on an edge of no length |
| 7 | The property's latitude is 0 and its longitude is 0 |

A check 1 problem stops checks 2 to 6. A missing ZIP, latitude or longitude never reaches the roof checks: it is a shape error, a `422` with no `check`, as in [The request's shape comes first](#the-requests-shape-comes-first).

## Warnings

A roof with only these is built. Each warning says what OSA did.

| Check | Warning | Severity | What OSA does |
| - | - | - | - |
| 3 | An edge lies on no face | `minor` | Leaves it out |
| 3 | Two edges join the same two points | `minor` | Keeps both |
| 4 | An `eave` is not level | `minor` up to 1 ft across its ends, `major` beyond | Builds it as drawn |
| 4 | An `eave` shared by two faces is level on neither | `minor` up to 1 ft, `major` beyond | Builds it as drawn |
| 4 | A face has eaves on opposite sides | `major` | Slopes it toward its longest group of eaves |
| 4 | A sloped face has no eave and no `low_edge` | `major` | Takes its corners' heights from the faces around it |
| 5 | Without `z_ft`: faces disagree on a shared point's height by more than 1 inch | `minor` up to 1 ft, `major` beyond | Builds the point at the average of the heights its faces give it. A `major` one usually means a lower roof shares points with a higher one: give the lower roof its own points (see [Points](https://docs.osaconnection.com/roof-format.md#points)) |
| 5 | With `z_ft` on every point: a face is not flat, or does not match its pitch, at a point | `minor` up to 1 ft, `major` beyond | Builds the point at the height you gave it. Nothing is averaged |
| 6 | A structure gives heights but one section has none | `major` | Builds that section with its lowest eave at 0 ft |

## Before you ask for the file

The first time you ask for a live export's ESX is charged as one use, whether or not it has warnings. Look at `clean` and `major_warnings` first, and correct the roof with a new version if you need to. See [What counts as a use](https://docs.osaconnection.com/esx-export-uses.md).


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