Guide

# Build a flashing line

A flashing is a folded sheet-metal profile, drawn by hand and cut to a list of lengths. The API stores a flashing line exactly as you send it and never prices or checks it, so this guide works one through from the sketch: the numbers you compute, the drawing geometry, the write, and the SVG upload.

## 1 · Start from the sketch

The example is a Colorbond flashing in Basalt at 0.55 mm: a 10 mm crush fold on the top edge, a 110 mm upright, a 90° bend, a 320 mm flat, a 140° bend and a 10 mm kick. The cut list is three pieces at 1200 mm and two at 925 mm, at $20.00 a metre. Resolve the template first — page `ListFlashings` and match on `flashingName`, `thickness` and `colours` — and keep its `flashtpl_` id. Every flashing template reports the same `productType`, so that filter does not narrow the list.

Lengths and girths are always millimetres and `totalLength` is always metres, whatever measurement system the account uses.

## 2 · Work out the numbers

Four values on the line are yours to compute. The server stores them as sent and never cross-checks them against the drawing or the cut list.

| Field | Rule | This flashing |
| --- | --- | --- |
| totalGirth | Every edge size in the drawing plus every finish size, in millimetres. With other sides, the side with the largest girth. | 110 + 320 + 10 + 10 = 450 |
| bends | One for each point that joins two edges, plus what each finish adds: crush fold 2, open hook 2, feather 1, drip edge 1. | 2 joins + a crush fold = 4 |
| totalLength | The sum over the cut list of amount × length, divided by 1000, in metres. | 3 × 1200 + 2 × 925 = 5450 mm = 5.45 |
| totalPrice | unitPrice × the priced metres, rounded to the cent. | $20.00 × 5.45 = $109.00 |

> **Mind the minimum length.** If the account charges a minimum flashing length, every piece shorter than it is priced as that length. With a 1000 mm minimum the two 925 mm pieces price as 1000 each, so the priced length is 5.6 m and `totalPrice` is $112.00 — while `totalLength` stays 5.45. The API does not apply the minimum for you.

## 3 · Draw it

A drawing is a set of points joined by edges. The points carry the sketch's canvas coordinates, which only lay it out; the sizes in `lines.values` are the real dimensions, so send `isFreeDrawing` as true. Record every edge at both ends — `p1.vectors` lists `p2` and `p2.connect` lists `p1` — key each size `"from-to"`, and give every edge a size. Angles are keyed by the point they sit on.

A finish sits on the point at the finished end. `flip` chooses the side: looking from that end along its edge, false folds to the right and true to the left — here true turns the crush fold into the inside of the L. The arrow marks the front face; 0 points left and the angle turns clockwise on screen, so 135 points up and to the right.

Give the drawing a `tempId` that no other drawing in the request uses, and number it 0 — the server does not assign `drawingNumber`, and documents sort drawings by it. Its side defaults to the far side; any `otherSides` default to the near side.

## 4 · Write the order

Send the line with the document. A flashing line cannot be added to an existing order, replaced or removed, so it goes in the create call — or onto a quote before conversion. `priceLevel` is a name, not an id. `thickness` is stored as sent and never compared with the template, so make it match. Amounts are micros of the account currency.

```bash
POST /v1/orders
{
  "requestId": "6f1c2d3e-4a5b-4c6d-8e7f-9a0b1c2d3e4f",
  "customerId": "cust_01k2m…",
  "isSubmitted": false,
  "lines": [{ "flashing": {
    "templateId": "flashtpl_01k2m…",
    "productName": "Colorbond",
    "priceLevel": "A",
    "colour": "Basalt",
    "thickness": "0.55",
    "bends": "4",
    "totalGirth": "450",
    "totalLength": "5.45",
    "subitems": [{ "amount": 3, "length": 1200 }, { "amount": 2, "length": 925 }],
    "unitPrice":  { "amountMicros": "20000000",  "currency": "AUD" },
    "totalPrice": { "amountMicros": "109000000", "currency": "AUD" },
    "drawing": {
      "tempId": "flashing-1",
      "drawingNumber": 0,
      "isFreeDrawing": true,
      "points": {
        "p1": { "id": "p1", "x": 150, "y": 175, "vectors": ["p2"], "connect": [],
                "finish": { "type": "FINISH_TYPE_CRUSH_FOLD", "size": 10, "label": "cf10", "flip": true } },
        "p2": { "id": "p2", "x": 150, "y": 230, "vectors": ["p3"], "connect": ["p1"] },
        "p3": { "id": "p3", "x": 310, "y": 230, "vectors": ["p4"], "connect": ["p2"] },
        "p4": { "id": "p4", "x": 328.4, "y": 245.4, "vectors": [], "connect": ["p3"] }
      },
      "lines":  { "values": { "p1-p2": { "size": 110 }, "p2-p3": { "size": 320 }, "p3-p4": { "size": 10 } } },
      "angles": { "values": { "p2": { "angle": 90 }, "p3": { "angle": 140 } } },
      "frontArrow": { "x": 136, "y": 244, "angle": 135 }
    }
  }}]
}
```

## 5 · Map the drawing id and upload the SVG

The create response pairs the `tempId` you sent with the assigned `drawingId` in its `drawings` list, one entry per flashing line in the order you sent them.

```json
{
  "order": { "orderId": "order_01k2m…", "subtotal": { "amountMicros": "109000000", "currency": "AUD" } },
  "drawings": [
    { "tempId": "flashing-1", "drawingId": "drawing_01k2m…", "otherSides": [] }
  ]
}
```

Render the drawing yourself and upload the image base64-encoded. The decoded SVG must be at most 2,000,000 bytes, and each drawing in the batch reports its own outcome.

```bash
POST /v1/orders/{orderId}/drawings:uploadSvg
{
  "svgs": [
    { "drawingId": "drawing_01k2m…", "svg": "PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPuKApjwvc3ZnPg==" }
  ]
}
```

## 6 · What the server checks

- A flashing line without a drawing is rejected with 400 (`validation_failure`).

- Once the document is submitted, `templateId`, `priceLevel`, `colour`, `thickness`, `bends`, `totalGirth`, `unitPrice` and a drawing with points are required, and `bends` and `totalGirth` must be greater than zero.

- `colour` is checked against the template's colours. Everything else — thickness, bends, girth, length, the cut list and every price — is stored exactly as sent.

- A drawing whose points, lines or angles exceed about 15,000 characters of JSON is rejected with 400.

> **After the write.** Read the order back with `GetOrder` to confirm the line, then open it in the Factory app. The drawing renders from the geometry you sent, and the app recomputes girth, bends and price from the same rules described here — if its figures differ from yours, the difference is in your numbers, and the stored values are what invoices will use.

---

Source: https://developer.factory.app/guides/build-a-flashing-line · Factory Sales API v1
