# Upload and update models

> An integration uploads IFC models and new versions, follows their processing, carries data from removed elements to new ones, and adds reference documents.

An integration, such as a design team's model server or a document management system, can upload a project's IFC models and their new versions, follow the processing, handle the elements a new version removed, and add reference documents, as a project administrator does on *Mallit* in the app. See [Upload an IFC model](/projektin-hallinta/tuo-ifc-malli/) for how the app shows the same.

## What you need

- The permission `models:write` for every write on this page except deleting a model, which needs `models:delete`. Either gives the integration the administrator role on its projects, because uploading and deleting models are administrator actions in the app. The administrator role comes only in projects of the integration's own organisation; in another organisation's project the writes answer `403 INSUFFICIENT_PROJECT_ROLE`. An organisation administrator chooses the permissions; see [Create an integration](/en/integrations/create-an-integration/).
- `models:read` to read model versions, carry-overs and reference documents. Downloading an IFC file and the removed-element reads also need the administrator role, so they need `models:write` as well.
- An [access token](/en/integrations/get-an-access-token/) whose scopes include them. The new elements are read with `elements:read`.

## Upload a model

1. Start the upload. Without `model_id` the file starts a new model:

```sh
curl -X POST "https://api.whatsbuilt.fi/v1/projects/$PROJECT/model-versions" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: rak-2026-11-20" \
  -d '{"filename":"RAK_runko.ifc"}'
```

The answer is `201` with the pending model version and a presigned upload address:

```json
{ "model_version": { "id": "9b2e…", "model_id": "9b2e…", "filename": "RAK_runko.ifc", "status": "pending", "version": null, "…": "…" },
  "upload_url": "https://…", "method": "PUT", "headers": { "Content-Type": "application/octet-stream" }, "expires_in": 3600 }
```

2. Upload the file with exactly those headers, at most 1 GB:

```sh
curl -X PUT "$UPLOAD_URL" -H "Content-Type: application/octet-stream" --data-binary @RAK_runko.ifc
```

3. Start the processing:

```sh
curl -X POST "https://api.whatsbuilt.fi/v1/projects/$PROJECT/model-versions/$VERSION/ingest" \
  -H "Authorization: Bearer $TOKEN"
```

The answer is `202` at once. Read `GET /v1/projects/{projectId}/model-versions/{versionId}` until `status` is `complete` or `failed`, a few seconds to some minutes. A complete version has its `version` number and `element_count`, and its elements come in `GET /v1/elements`; see [Collect changes in a window](/en/integrations/collect-changes/).

A repeat of step 1 with the same `Idempotency-Key` and body returns the same model version with `200` and a new upload address; once the file has been processed, `upload_url` is `null`. Each processing counts against the integration's hourly limit of 60 IFC files, like a person's: over it the answer is `429` with `Retry-After`.

## Upload a new version

Send the model's `model_id` in step 1, then steps 2 and 3 as above:

```sh
curl -X POST "https://api.whatsbuilt.fi/v1/projects/$PROJECT/model-versions" \
  -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  -H "Idempotency-Key: rak-2026-12-01" \
  -d '{"filename":"RAK_runko_rev_A.ifc","model_id":"9b2e…"}'
```

Labels, inspections and other data stay on the elements whose GlobalId the new file keeps. The new version's `diff` counts the elements `kept`, `added` and `removed`, and how many removed ones carry data. A model that has no complete version yet answers `409 UPLOAD_NOT_CLAIMABLE`, and one whose version is being processed `409 MODEL_BUSY`.

`POST …/model-versions/{versionId}/retry` processes a version again: a complete one as a new version of its model, a failed one in place. It also counts against the hourly limit.

## Removed elements and carry-over

An element missing from the new file is archived with its data: it comes in `GET /v1/elements` with `archived_at`. `GET /v1/projects/{projectId}/models/removed-summary` counts each model's removed elements, and `GET …/models/{modelId}/removed-elements` lists them with their label, inspections and plans.

When the designer gave an element a new GlobalId, carry its data to the new element (*Siirrä tiedot* in the app):

```sh
curl -X POST "https://api.whatsbuilt.fi/v1/projects/$PROJECT/models/$MODEL/carry-overs" \
  -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  -H "Idempotency-Key: rev-a-carry-1" \
  -d '{"pairs":[{"from":"1hOSvn6df7F8_7GcBWlRGQ","to":"2O2Fr$t4X7Zf8NOew3FLOH"}]}'
```

`from` is a removed element, `to` a live element of the current version. `GET …/models/{modelId}/carry-over-candidates?search=SK-1112` finds candidates, and with the carry-over feature `removed-elements` proposes one for each row. The label, inspections, plan rows and element events move in one transaction; a pair that would put two labels or two inspections with results on one element comes back with `status` `refused` and the code `LABEL_ON_BOTH` or `INSPECTION_ON_BOTH`, and the other pairs are carried. Each carried pair has a `carry_over_id`; all pairs of a call share a `batch_id`. A repeat with the same `Idempotency-Key` and body returns the first call's answer and moves nothing again. A carry-over still running 25 seconds after the request arrived answers `400 VALIDATION_ERROR` and carries nothing: carry fewer pairs at a time.

Take carry-overs back with their ids or the whole batch:

```sh
curl -X POST "https://api.whatsbuilt.fi/v1/projects/$PROJECT/models/$MODEL/carry-overs/undo" \
  -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  -d '{"batch_id":"5d0c…"}'
```

Work recorded on the new element after the carry-over stays there and is counted in `stayed`. An undo still running 25 seconds after the request arrived answers `400 VALIDATION_ERROR` and undoes nothing: undo fewer carry-overs at a time, by `carry_over_ids`. Carry-over needs the organisation's carry-over feature; without it these calls answer `403 FEATURE_OFF`, and `GET /v1/carry-overs` names the project in `skipped_projects` with `FEATURE_OFF`.

Mark removed elements resolved when nothing needs to move: `POST …/models/{modelId}/removed-elements/resolve` with `{"global_ids":[…]}` or `{"all":true}`. Their data stays.

## Delete a model

Deleting needs `models:delete`. `GET …/model-versions/{versionId}/impact` tells what deleting takes. `DELETE /v1/projects/{projectId}/model-versions/{versionId}` on a complete version deletes the whole model: every version and its elements. The model's labels and inspections are left without an element. Its element events and carry-overs stay as history: they keep the element's global id and name and show `model_deleted: true`. **This cannot be undone.** On a failed or unfinished upload it deletes that upload only, and answers `409 UPLOAD_HAS_LINKED_ELEMENTS` if its elements carry data.

## Reference documents

A reference document (*ohje*) is a PDF that a template or a step shows to the inspector. Add it to the project in three calls:

```sh
curl -X POST "https://api.whatsbuilt.fi/v1/projects/$PROJECT/reference-documents/uploads" \
  -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  -d '{"filename":"IV-kone_asennusohje.pdf","content_type":"application/pdf","byte_size":4404019}'

curl -X PUT "$UPLOAD_URL" -H "Content-Type: application/pdf" -H "Content-Length: 4404019" --data-binary @IV-kone_asennusohje.pdf

curl -X POST "https://api.whatsbuilt.fi/v1/projects/$PROJECT/reference-documents" \
  -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  -H "Idempotency-Key: iv-kone-ohje" \
  -d '{"key":"documents/…","filename":"IV-kone_asennusohje.pdf"}'
```

The last call checks that the upload finished and is a PDF of at most 20 MB, and answers `201` with the document; a repeat with the same `Idempotency-Key` answers `200` with the same document. Attaching it to a template comes with the inspection writes. Download one with `GET …/reference-documents/{documentId}/file`, which redirects to the file.

## Follow models, carry-overs and documents

These lists work in a window like the others:

- `GET /v1/model-versions`: one row per uploaded file. Every version of a model shares `model_id`; the highest complete `version` is the current one. A version changes as its processing moves on. Filter with `status` or `model_id`.
- `GET /v1/carry-overs`: each carry-over with `from_global_id` and `to_global_id`; an undone one is a change with `undone_at`. Filter with `batch_id`. A project whose organisation does not use carry-over is in `skipped_projects`.
- `GET /v1/reference-documents`: the project's reference documents. A document no template uses any more is deleted.

A deleted model comes as a deletion of each of its versions, elements and carry-overs.

The error codes are on [Errors and limits](/en/integrations/errors-and-limits/) and the fields in the [API reference](/en/api-reference/operations/createmodelversion/).
