# Designs

Build a product part by part with modeling scripts and circuit boards, check every part, follow every change live, download meshes, boards and pictures, and order the parts.


A design is one product in the account, such as a mug or a lamp. A design has parts. Each part has one process, one material and a script that makes the part's shape with the [modeling API](/docs/agents/designs#the-modeling-api). Summonmade runs the script, checks the part and the assembled product, and tells every open view. All paths are under `https://summonmade.com/api/v1`. The examples read the key from `SUMMONMADE_API_KEY`.

AI apps use the same operations as MCP tools. See [Design in the cloud](/docs/agents/designs).

## The design object

| Field | Type | Values |
| --- | --- | --- |
| `id` | string | `DS-` and 8 characters from `23456789ABCDEFGHJKLMNPQRSTUVWXYZ`, for example `DS-7KQ2XW4P`. |
| `title` | string | 1 to 80 characters. |
| `description` | string | Up to 2000 characters. |
| `parts` | array | The parts. See [The part object](#the-part-object). |
| `checks` | array | Each check: `id`, `title`, `status` (`pass`, `warn` or `fail`), `summary` and `part` (null for a check of the assembled product). See [Checks](/docs/agents/designs#checks). |
| `guide` | string | The assembly guide in Markdown, with one `##` heading per step. Empty until written. |
| `activity` | array | The latest changes, newest last. Each: `at`, `by` (`person`, the name of an AI app or agent, or `Summonmade`) and `text`. |
| `orders` | array | Orders made from the design, newest first. Each: `id`, `part` and `status`. |
| `version` | integer | Grows with every change of the design. |
| `undo`, `redo` | array | The labels of the changes that undo can take back and redo can make again, newest last. |
| `createdAt`, `updatedAt` | string | ISO 8601 times. |

## The part object

| Field | Type | Values |
| --- | --- | --- |
| `id` | string | 1 to 40 lowercase letters, digits and hyphens, such as `body`. |
| `name` | string | What people call the part. |
| `process` | string | `pcb`, `pcb-assembly`, `3d-print`, `cnc` or `sheet-metal`. |
| `material`, `finish` | string | As in [the catalog](/docs/api/orders#the-catalog). An empty finish is the standard finish. |
| `quantity` | integer | Pieces in one product. |
| `color` | string | `#rrggbb`, or empty for the color of the material. |
| `position` | array | `[x, y, z]` in millimeters: where the part sits in the product. |
| `rotation` | array | `[x, y, z]` in degrees: about x first, then y, then z. |
| `code` | string | The script. For a circuit board, the tscircuit code, or empty for a board from KiCad. |
| `mesh` | object or null | `version`, `triangles`, `size` and `min` (`[x, y, z]` in millimeters, in the part's own coordinates), `volume` (mm³) and `area` (mm²). For a circuit board, the board with a block over the pads of each part. |
| `error` | string | Empty. A script that fails does not change the part. |
| `board` | object | Only on a circuit board part. See [The board object](#the-board-object). |

## The board object

| Field | Type | Values |
| --- | --- | --- |
| `version` | integer | Grows with each change of the board. [Download the board](#download-a-board) by this version. |
| `source` | string | `code` (tscircuit) or `kicad`. |
| `edits` | integer | The edits since the code ran or the project was imported. |
| `options` | object | `maskColor`, `silkscreen`, `finish`, `thickness` (mm) and `copperOz`. See [Board options](/docs/agents/designs#board-options). |
| `size` | array | Width and height of the board in millimeters. |
| `layers`, `components`, `nets` | integer | Copper layers, parts on the board and nets. |
| `openConnections` | integer | Connections that need copper. |
| `findings` | object | `errors` and `warnings` of the checks against the factory profile. |

## List designs

`GET /designs` answers `200` with `{ "designs": [...] }`. Each item has `id`, `title`, `parts` (the number of parts) and `updatedAt`. The last changed design comes first.

```sh
curl https://summonmade.com/api/v1/designs -H "Authorization: Bearer $SUMMONMADE_API_KEY"
```

## Create a design

`POST /designs` with a `title` and an optional `description`. It answers `201` with the design.

```sh
curl -X POST https://summonmade.com/api/v1/designs \
  -H "Authorization: Bearer $SUMMONMADE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"title": "Steel mug", "description": "A 350 ml mug with a black handle."}'
```

## Read a design

`GET /designs/{id}` answers `200` with the design.

## Change a design

`PUT /designs/{id}` with the fields to change: `title`, `description` or `guide`. An empty guide removes it. It answers `200` with the design. Undo takes the change back.

## Delete a design

`DELETE /designs/{id}` deletes the design with parts, files and history, and closes the live connections. Orders made from the design stay. It answers `200` with `{ "deleted": true }`.

## Make or change a part

`PUT /designs/{id}/parts/{part}` with the fields of the part and an optional `label` for the history. A new part needs `process`, `material` and `code`. For a part that exists, send only what changes; without `code`, the part keeps its shape.

Summonmade runs the script, keeps the mesh as a new version, checks the part and the product, and sends the design to every live connection. It answers `200` with `design`, `part`, `changed` (what the change did, in words) and `logs` (what the script wrote with `console.log`).

```sh
curl -X PUT https://summonmade.com/api/v1/designs/DS-7KQ2XW4P/parts/body \
  -H "Authorization: Bearer $SUMMONMADE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Body",
    "process": "3d-print",
    "material": "Stainless steel 316L (SLM)",
    "code": "return cylinder(95, 41).subtract(cylinder(95, 38).translate(0, 0, 6));",
    "label": "Make the body"
  }'
```

A script that fails changes nothing. The answer is `422`, and its `detail` names the line and the call, for example `The script of Body failed, so the design did not change. Line 2: cylinder(): height must be more than 0; it is -3.` A new part without `process`, `material` or `code` answers `400`. A design has at most 30 parts.

## Make or change a board

`PUT /designs/{id}/parts/{part}/board` with `code` (tscircuit code) or `kicad` (`{pcb, sch, pro}`, the text of the KiCad files), and optionally `options`, `name`, `process` (`pcb` or `pcb-assembly`), `material`, `quantity`, `position`, `rotation` and `label`. Without `code` and `kicad`, only the options, the name, the quantity or the place change. The fields are in [Circuit boards](/docs/agents/designs#circuit-boards).

Summonmade compiles the code or imports the project, checks the board against the factory profile, keeps the board and its solid as new versions, and sends the design to every live connection. It answers `200` with `design`, `part`, `changed`, `logs` (what the code wrote with `console.log`) and `findings`.

```sh
curl -X PUT https://summonmade.com/api/v1/designs/DS-7KQ2XW4P/parts/board/board \
  -H "Authorization: Bearer $SUMMONMADE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "LED board",
    "code": "export default () => (<board width=\"30mm\" height=\"20mm\" routingDisabled><resistor name=\"R1\" resistance=\"1k\" footprint=\"0603\" pcbX={0} pcbY={3} /><led name=\"D1\" color=\"red\" footprint=\"0603\" pcbX={6} pcbY={3} /><trace from=\".R1 > .pin2\" to=\".D1 > .anode\" /></board>)",
    "options": {"maskColor": "black", "finish": "enig"}
  }'
```

Code that does not compile, a KiCad file that cannot be read, or an option that the factory does not make answers `422`, and the design does not change. The `detail` names the line of the code or the rule of the factory profile, for example `Rule pcb.thickness (Board thickness): a board with 2 layers is 0.4, 0.6, 0.8, 1, 1.2, 1.6, 2 mm thick; 1.7 mm is not an option.` A part with another process answers `409`.

## Edit a board

`POST /designs/{id}/parts/{part}/board/edits` with `edits` (a list), optional `options` and an optional `label`. The edits are `move`, `rotate`, `connect`, `route` and `unroute`; see [Edit a board](/docs/agents/designs#edit-a-board). They run in order and make one step of the history. The board editor of the designer sends `circuitJson`, the board after the person's edit, which replaces the board before the edits run. It answers `200` as [Make or change a board](#make-or-change-a-board). An edit that cannot be made answers `422`, and the board does not change.

```sh
curl -X POST https://summonmade.com/api/v1/designs/DS-7KQ2XW4P/parts/board/board/edits \
  -H "Authorization: Bearer $SUMMONMADE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"edits": [{"op": "move", "ref": "D1", "x": 8, "y": 3}, {"op": "route"}], "label": "Route the LED board"}'
```

## Read the board checks

`GET /designs/{id}/parts/{part}/board/checks` answers `200` with `part`, `version` (the board version), `limits` (the factory profile that the checks used), `counts` (`errors`, `warnings` and `notes`) and `findings`. Each finding has `n` (its number on the look image), `severity`, `rule`, `profileRule`, `message`, `at` (`[x, y]` in millimeters on the board, y up, or null) and `ids` (the Circuit JSON elements).

## Download a board

`GET /designs/{id}/parts/{part}/board?v={version}` answers the board file as JSON: `format` (`summonmade.board/1`), `version`, `circuitJson` (the board as [Circuit JSON](https://github.com/tscircuit/circuit-json)), `options`, `findings` and `limits`. A board version never changes, so a view can keep the file. Without `v`, the answer is the current board.

## Get the look image of a board

`GET /designs/{id}/parts/{part}/board/look` answers a PNG of the board from the top, with a numbered square at each finding and the list of findings. Add `?theme=dark` for the dark page color.

## Remove a part

`DELETE /designs/{id}/parts/{part}` answers `200` with the design. Undo brings the part back.

## Undo and redo

`POST /designs/{id}/undo` takes back the last change, by anyone. `POST /designs/{id}/redo` makes the last undone change again. Both answer `200` with `design` and `label`, the change that they took back or made again. Without a change to take back or make again, they answer `409`. The design keeps its last 60 changes. A new change after an undo clears what redo could make again.

## Order a design

`POST /designs/{id}/order` with `shipCountry`, and optionally `quantity` (the number of products, 1 by default), `parts` (only these parts) and `notes` for the maker. It makes one order per part, because an order has one process and one material. Each order has the part's process, material and finish, its quantity times the number of products, the part's mesh as `{part}.stl`, and for a sheet-metal part made with `sheet()` the DXF of its flat blank as `{part}-flat.dxf`. Then each order goes to its quote.

A circuit board part gets its Gerber and drill files as `{part}-gerber.zip`, and for `pcb-assembly` its BOM as `{part}-bom.csv` and its pick-and-place list as `{part}-pick-and-place.csv`. The order has the board's finish, and the notes have the board options.

It answers `201` with `orders` (each a full [order](/docs/api/orders#the-order-object)), `skipped` (parts without an order, and why) and `design`. A failed check answers `409` with the checks to fix. A `pcb` part with only a script shape is skipped: make the board first.

```sh
curl -X POST https://summonmade.com/api/v1/designs/DS-7KQ2XW4P/order \
  -H "Authorization: Bearer $SUMMONMADE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"shipCountry": "DE", "quantity": 2}'
```

## Download a mesh

`GET /designs/{id}/parts/{part}/mesh?v={version}` answers the part's mesh as binary STL (`model/stl`), in millimeters, in the part's own coordinates. The version comes from `part.mesh.version`. A mesh version never changes, so a view can keep it. Without `v`, the answer is the current mesh.

## Get a picture

`GET /designs/{id}/picture` answers a picture of the assembled product, and `GET /designs/{id}/parts/{part}/picture` a picture of one part. Both are 640 × 640 PNG, in the isometric view of the Summonmade drawings: +x to the lower right, +y to the upper right, +z up. Add `?theme=dark` for the dark page color.

## The live connection

`GET /designs/{id}/live` with a WebSocket upgrade opens the live connection of a design. The website's session opens it from summonmade.com, an API key opens it in the `Authorization` header, and the designer inside a chat opens it with `?ticket=`.

Each message is JSON:

| Message | When |
| --- | --- |
| `{"type": "design", "design": {...}}` | At once when the connection opens, and after every change. |
| `{"type": "activity", "activity": {"at", "by", "text"}}` | While a change runs, for example "Making Handle.", or when a script fails. The next design message has the stored activity. |
| `{"type": "pong"}` | The answer to `{"type": "ping"}`. |

A view fetches a changed mesh when `part.mesh.version` changes, and a changed board when `part.board.version` changes. The connection closes with code `4404` when the design is deleted.

## Tickets

The designer inside a chat runs on another origin and gets no cookies. The `open_designer` tool gives the designer a ticket in `_meta.open`: `{ "design", "ticket", "expiresAt" }`. The ticket is valid for 2 hours, for one design of one account. Add it as `?ticket=` to the live connection and to every operation of that design, from any origin: the answers allow any origin, because only the ticket opens them. A ticket cannot delete the design. An expired or changed ticket answers `401`; the designer then asks the AI app to open it again.

```text
wss://summonmade.com/api/v1/designs/DS-7KQ2XW4P/live?ticket=…
https://summonmade.com/api/v1/designs/DS-7KQ2XW4P/parts/body/mesh?v=3&ticket=…
```
