# Maintenance, handover and exports

> An integration writes maintenance entries, reads elements and places, builds exports, reports and the handover package, and manages the organisation's reference documents.

An integration, such as a property management system or the contractor's document archive, can do what a person does in the app once a project is built: write the maintenance log, look an element up with its properties, take the files the project's *Export* menu gives, the reports and the handover package, and keep the organisation's reference documents. The phase of a project and the handover to the maintaining organisation are in [Projects and people](/en/integrations/projects-and-people/).

## What it needs

| Operation | Permission | Project role |
|:----------|:-----------|:-------------|
| Read maintenance entries | *Reads the maintenance log* (`maintenance:read`, or `read`) | viewer |
| Write and change maintenance entries | *Writes to the maintenance log* (`maintenance:write`) | inspector |
| Read elements, their properties, counts and places | *Reads elements, their properties and labels* (`elements:read`, or `read`) | viewer |
| Start the CSV exports, the as-built file and the handover package, and download them | *Exports* (`exports:read`, or `read`) | admin |
| Start the PDF report and download it | *Exports* (`exports:read`, or `read`) | inspector |
| Start the Markdown report and download it | *Exports* (`exports:read`, or `read`) | inspector where the organisation has the PDF report, admin otherwise |
| Delete a project's reference document | *Uploads models and manages their versions and reference documents* (`models:write`) | admin |
| The organisation's reference documents and usage | *Acts as the organisation's admin* (`organisation:admin`) | – |
| Download an organisation reference document | `models:read` (or `read`) | – |

`maintenance:write` makes the integration an inspector on its projects. An inspector changes its own entries; a project admin changes any.

Every export needs the project role the same export needs in the app, in the organisation's own projects too and for an app acting for a person. `exports:read` is a read permission and does not raise the integration's role. `models:write` or `members:write`, for example, make the integration an admin; `maintenance:write` or `findings:write` make it an inspector. On another organisation's project the role is the one its admin chose. The organisation's admin picks the permissions; see [Create an integration](/en/integrations/create-an-integration/).

The maintenance log needs the maintenance phase in the project's organisation. Without it, the maintenance calls answer `403 FEATURE_OFF` and `GET /v1/maintenance-entries` names the project in `skipped_projects` with `FEATURE_OFF`.

## Maintenance entries

An entry goes on one element, only while the project is in maintenance (`409 PROJECT_NOT_IN_FM` otherwise):

```sh
curl -X POST "https://api.whatsbuilt.fi/v1/projects/$PROJECT/maintenance-entries" \
  -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{"global_id": "2O2Fr$t4X7Zf8NOew3FLOH", "log_type": "repair", "title": "Sealant renewed", "description": "North face", "occurred_at": "2026-11-18T10:00:00+02:00"}'
```

- `log_type` is `routine_check`, `repair`, `replacement`, `incident` or `certification`. `title` is at most 200 characters, `description` at most 4000.
- `occurred_at` is when the work was done, default now. It may be at most 14 days back (`400 EVENT_TIME_OUT_OF_RANGE`), unless the project takes historical entries. A time in the past is marked `entered_later`.
- The answer is the entry, `201`. A repeat with the same `Idempotency-Key` and body returns it with `200`; if the entry is gone, `410 RESOURCE_DELETED`.
- `PATCH /v1/projects/{projectId}/maintenance-entries/{entryId}` changes `log_type`, `title`, `description` or `occurred_at`.

The app shows the entry with the integration's name, *Integration · {name}*, and an app acting for a person as *{person} · via {app}*. `GET /v1/maintenance-entries` lists the entries of every project in a window, with `log_type` and `global_id` filters; see [Collect changes in a window](/en/integrations/collect-changes/).

## Elements and places

These reads answer what the app's element page and place browser show. They are snapshots: read when asked, with no window.

| Read | What it answers |
|:-----|:----------------|
| `GET /v1/projects/{projectId}/elements/{globalId}` | One element with its properties by property set, and `moved_to` for an archived element whose data was carried over |
| `POST /v1/projects/{projectId}/elements/query` | Elements by IFC class, storey, text and property conditions, 200 a page with `cursor`, and value counts for an `in` condition |
| `GET /v1/projects/{projectId}/element-properties` | Every property the elements have, with its most common values |
| `GET /v1/projects/{projectId}/element-counts` | Element counts by IFC class and by storey |
| `GET /v1/projects/{projectId}/places?node=…` | The place tree: buildings, storeys, spaces, zones and systems with counts, open findings and inspections in progress |

```sh
curl -X POST "https://api.whatsbuilt.fi/v1/projects/$PROJECT/elements/query" \
  -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  -d '{"ifc_type": "IfcColumn", "properties": [{"pset": "Pset_ConcreteElementGeneral", "property": "StrengthClass", "op": "in", "values": ["C30/37", "C40/50"]}]}'
```

`model_version_id` narrows each read to one model version. To collect all elements and their changes, use `GET /v1/elements`.

## Exports, reports and the handover package

An export is a job: start it, read it until it is no longer `queued` or `running`, then download its files.

```sh
curl -X POST "https://api.whatsbuilt.fi/v1/projects/$PROJECT/export-jobs" \
  -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{"kind": "report_pdf", "params": {"language": "fi"}}'
```

| `kind` | The file |
|:-------|:---------|
| `csv_topics`, `csv_assets`, `csv_inspections` | The app's CSV exports; see [Exports](/en/integrations/exports/) for the columns |
| `as_built_csv` | One row per element with its as-built dates; `params.stages` picks the template that dates each stage |
| `report_md` | The inspection report in Markdown |
| `report_pdf` | The PDF report, where the organisation has it (`403 FEATURE_OFF` otherwise) |
| `handover` | The handover package: a ZIP with the BCF file, the CSV files, the report and the finding photos, with `manifest.json` |

The answer is `202` with the job. Today a job is built while the call runs, so it usually answers `done`, `refused` (too large or too slow, `message` says which) or `failed`; read `GET /v1/projects/{projectId}/export-jobs/{jobId}` while it is `queued` or `running`. Then:

```sh
curl "https://api.whatsbuilt.fi/v1/projects/$PROJECT/export-jobs/$JOB/download?file=0" -H "Authorization: Bearer $TOKEN"
```

answers `{ "url": "…", "expires_in": 60 }`. Start the download within 60 seconds; ask again for a new link. Each file has `size_bytes` and `sha256`. The files are kept for 24 hours; after that the job is `expired` and the link answers `410 EXPORT_EXPIRED`. A job that is not done answers `409 EXPORT_NOT_DONE`.

- Today a job is built within about 20 seconds, and a handover package may be at most 100 MB. On a larger project `handover` and `as_built_csv` end `refused` until exports are built in the background.
- If the call times out or answers `503`, repeat it with the same `Idempotency-Key` and read the job. A job cut off before it ends reads `failed` a minute after it started. A `failed` job is started again with a new key.
- `report_pdf`, `handover` and `as_built_csv` draw from the project's limits of 20 an hour each, shared with the app. The CSV exports share a limit of 20 an hour and `report_md` has its own 20; the app's own exports do not draw from them (`429`). A refused or failed job gives its draw back.
- `GET /v1/projects/{projectId}/export-jobs` lists the jobs this integration started in the last 7 days. Another integration's or a person's jobs are never shown.

## Reference documents

`DELETE /v1/projects/{projectId}/reference-documents/{documentId}` deletes a project's PDF that no template uses. A template that still has it answers `409 DOCUMENT_IN_USE` with `details.template_ids`; take it off the template first. Uploading is in [Upload and update models](/en/integrations/models/).

The organisation's own reference documents, which its own templates use, are kept the same way under `/v1/organisation/reference-documents`: `POST …/uploads` for an upload URL, a `PUT` of the file, then `POST /v1/organisation/reference-documents` with the `key`. A repeat with the same `key` returns the same document with `200`. `GET …/{documentId}/file` downloads it. `DELETE …/{documentId}` deletes it, and is refused with `409 DOCUMENT_IN_USE` while a template has it.

## The organisation's usage

`GET /v1/organisation/analytics?from=…&to=…` answers what the app's *Analytics* page shows: event counts per kind, in total and per UTC day, by default for the last 30 days.

## Errors

| Code | When |
|:-----|:-----|
| `403 INSUFFICIENT_SCOPE` | The token lacks the permission |
| `403 INSUFFICIENT_PROJECT_ROLE` | The project role is too low, also for the export's kind, or an inspector changes another's entry |
| `403 INSUFFICIENT_ROLE` | An organisation call by an app whose person is not the organisation's admin |
| `403 FEATURE_OFF` | The organisation does not use the maintenance phase or the PDF report |
| `409 PROJECT_NOT_IN_FM` | The project is not in maintenance |
| `409 DOCUMENT_IN_USE` | A template has the document |
| `409 EXPORT_NOT_DONE`, `410 EXPORT_EXPIRED` | The job has no files, or they are gone |
| `410 RESOURCE_DELETED` | A repeated key whose entry was deleted |
| `429 RATE_LIMITED` | An hourly export limit is used up |

The rest are in [Errors and limits](/en/integrations/errors-and-limits/).
