# Build towers

> Build drawable tower geometry for the Risks in a Program.

```
POST https://towers-api.vinsa.dev/api/v1/towers
```

Send a program; get back its towers. Nothing is stored: the same request always gives the same answer, so you can cache it for as long as your own data is unchanged.

## Request

| Header | Value |
| --- | --- |
| `Authorization` | `Bearer <your key>` |
| `Content-Type` | `application/json` |

The body is a program with at least one risk. Contracts hold Layers, and Risks list their protecting `contractRefs`. The smallest useful body:

```json
{
  "program": {
    "contracts": [
      {
        "contractRef": "C-1",
        "currency": "USD",
        "layers": [
          {
            "layerName": "First excess",
            "layerType": "XOL",
            "lowerLimit": 2500000,
            "upperLimit": 5000000,
            "isUnlimited": false,
            "order": 100
          }
        ]
      }
    ],
    "risks": [
      {
        "riskId": "R-1001",
        "contractRefs": [
          "C-1"
        ]
      }
    ]
  }
}
```

Every field is listed in the [Request reference](https://towers.vinsa.dev/docs/api/request.md).

## Response

`200 OK` with one entry per risk, in the order you sent them. Each has the towers to draw. The response also carries `warnings`, `limitations` and `unlimitedDisplayHeight`. See the [Response reference](https://towers.vinsa.dev/docs/api/response.md).

You do not need to read the response to draw it: pass it to [`<Towers />`](https://towers.vinsa.dev/docs/react/towers.md) as it is.

## Drawn shares

The whole viewpoint uses the shared signing Engine’s Signed shares. See the [drawing rules](https://towers.vinsa.dev/docs/api/layering.md#width-is-share-height-is-amount) for eligibility, retention and overflow.

Use the [reinsurer viewpoint](https://towers.vinsa.dev/docs/api/viewpoints.md) to draw Our Lines, the rest of the Order and the cedant’s share within each Layer slot.

## Errors

| Status | When |
| --- | --- |
| `400` | The body cannot be drawn. The response lists every problem found. |
| `401` | The key is missing or not valid. See [Authentication](https://towers.vinsa.dev/docs/api/authentication.md). |

A `400` names each field at fault, so you can show or log exactly what to fix:

```json
{
  "message": "Invalid request body",
  "errors": [
    {
      "path": "program.contracts[0].layers[1].upperLimit",
      "message": "upperLimit must be a number greater than lowerLimit when isUnlimited is false"
    },
    {
      "path": "program.contracts[0].layers[2].layerType",
      "message": "layerType must be one of: FAC, QSR, XOL, SPL"
    }
  ]
}
```

All problems are reported at once, not just the first.
