# BCF 3.0 API and OpenCDE discovery

> The BCF 3.0 and OpenCDE Foundation 1.1 routes WhatsBuilt serves, who may call them, and how inspections appear as topics.

Base URL: `https://api.whatsbuilt.fi`. Everything under `/bcf/3.0` needs a bearer token; see [Sign-in for BCF clients](/en/integrations/authentication/).

## Discovery

`GET /foundation/versions` needs no token and returns where each API lives:

```json
{
  "versions": [
    { "api_id": "foundation", "version_id": "1.1", "api_base_url": "https://api.whatsbuilt.fi/foundation/1.1" },
    { "api_id": "bcf", "version_id": "3.0", "api_base_url": "https://api.whatsbuilt.fi/bcf/3.0" }
  ]
}
```

## Routes

`{id}` is the project id and `{guid}` the topic GUID. Every id in a path must be a UUID; anything else gets `400`.

| Method and path | Use | Role |
|:----------------|:----|:-----|
| `GET /foundation/versions` | Discovery | None |
| `GET /foundation/1.1/auth` | OAuth endpoints | None |
| `GET /foundation/1.1/current-user` | The signed-in user: `id` (email), `name` | Any user |
| `GET /bcf/3.0/projects` | Projects you can reach, at most 200, no paging | Member |
| `GET /bcf/3.0/projects/{id}` | `project_id`, `name` | Member |
| `GET /bcf/3.0/projects/{id}/extensions` | `topic_types`, `topic_statuses`, `topic_labels`, `priorities`, `stages` | Member |
| `GET /bcf/3.0/projects/{id}/topics` | Topics | Member |
| `POST /bcf/3.0/projects/{id}/topics` | Create a topic | Inspector |
| `GET /bcf/3.0/projects/{id}/topics/{guid}` | One topic | Member |
| `PUT /bcf/3.0/projects/{id}/topics/{guid}` | Update a topic | Inspector |
| `DELETE /bcf/3.0/projects/{id}/topics/{guid}` | Delete a topic | Administrator |
| `GET`, `POST …/topics/{guid}/comments` | List or create comments | Read: member. Write: inspector |
| `PUT …/topics/{guid}/comments/{guid}` | Update a comment | Inspector |
| `GET`, `POST …/topics/{guid}/viewpoints` | List or create viewpoints | Read: member. Write: inspector |
| `GET …/topics/{guid}/viewpoints/{guid}` | One viewpoint | Member |
| `GET …/topics/{guid}/viewpoints/{guid}/snapshot` | `302` to a signed image URL. `404` if the viewpoint has no image reference, or one this project cannot read. A `302` does not prove the file exists: the download itself can still fail | Member |
| `GET`, `PUT …/topics/{guid}/files` | IFC file references of a topic | Read: member. Write: inspector |

`documents` and `document_references` are not implemented.

## Roles

A project member has one of four project roles: viewer, inspector, administrator or owner, each including the rights of the one before it. An administrator of the account that owns the project counts as a project administrator and reaches the project without being a member. Calling a project you cannot reach returns no data.

## Response shapes

- Lists are bare JSON arrays, without paging metadata.
- An item of `GET /projects` has `id` and `name`, among other fields, while `GET /projects/{id}` returns `project_id` and `name`.
- Field names are BCF-style snake case. A topic has `guid`, `server_assigned_id`, `project_id`, `title`, `topic_type`, `topic_status`, `priority`, `assigned_to`, `labels`, `description`, `stage`, `creation_author`, `creation_date`, `modified_author`, `modified_date` and `due_date`.
- A viewpoint has `guid`, `snapshot_key`, `snapshot_type`, `camera_data`, `components_data`, `creation_author` and `creation_date`. These names are WhatsBuilt's own, not the BCF 3.0 viewpoint schema.
- `creation_author`, `modified_author` and a comment's `author` are always the signed-in user. A value sent in the request body is ignored.

## Querying topics and comments

`GET …/topics` and `GET …/comments` accept OData parameters.

| Parameter | Values |
|:----------|:-------|
| `$top` | 1 to 9223372036854775807; above 200 reads as 200. Default 50 |
| `$skip` | 0 to 9223372036854775807 |
| `$orderby` | Topics: `creation_date`, `modified_date`, `server_assigned_id`, each `asc` or `desc`; default newest `modified_date` first. Comments: `date`, `asc` or `desc`; default oldest first |
| `$filter` | See below |

A `$top` or `$skip` above 9223372036854775807, a field the list does not name and a malformed clause get `400`.

### Filters

Join conditions with `and`. Put text in single quotes, and write dates in ISO 8601 without quotes:

```text
topic_status eq 'Open' and modified_date gt 2025-01-01T00:00:00Z
labels eq 'Safety'
```

| List | Field | Operators |
|:-----|:------|:----------|
| Topics | `creation_author`, `modified_author`, `assigned_to`, `stage`, `topic_status`, `topic_type`, `priority`, `creation_date`, `modified_date` | `eq`, `ne`, `gt`, `lt`, `ge`, `le` |
| Topics | `labels` | `eq` means the topic has the label, `ne` means it does not |
| Comments | `author`, `date` | `eq`, `ne`, `gt`, `lt`, `ge`, `le` |

Do not use `gt`, `lt`, `ge` or `le` on `labels`. The API accepts them, but they work like `eq`.

## Writing

- **Creating a topic.** `title` is required. A new topic without a status gets `Open`, without a priority `Normal` and without labels `[]`. You may send your own `guid`.
- **Updating a topic.** `PUT` replaces the topic as a whole, as the OpenCDE Foundation API 1.1 (section 1.3) requires: send every field. A field you leave out or send as `null` gets what a create gives it: `topic_status` becomes `Open`, `priority` `Normal`, `labels` `[]` and the other fields empty. `title` is required. To change one field, read the topic, change the field and send the whole topic back.
- **Fields of the wrong type are refused.** A body must be a JSON object. `title`, `topic_type`, `topic_status`, `priority`, `assigned_to`, `description`, `stage`, `due_date`, `comment`, `snapshot_key` and `snapshot_type` take text or `null`; `labels` takes a list of texts or `null`; the cameras and the components take an object or `null`. Anything else gets `400` with code `VALIDATION_ERROR` and a message such as `Validation failed: title: expected a string`. An empty text counts as left out, except in `title`. Fields WhatsBuilt does not keep, such as `bim_snippet`, `reference_links` and `index`, are ignored.
- **Comments.** A comment needs `comment` or `viewpoint_guid`. `PUT` replaces the comment as a whole, like a topic: a left-out or `null` `comment` or `viewpoint_guid` is cleared. To keep the viewpoint when you change the text, send its `viewpoint_guid` again.
- **Status and other values are not checked.** `topic_status` and the other topic values are free text; the API does not compare them with `/extensions`.
- **Images.** You cannot upload an image through this API. `POST …/viewpoints` reads `snapshot_key`, not BCF's `snapshot_data`. It accepts a key in WhatsBuilt's storage format for the same project, but it does not check that the file exists and does not create one. Use only the key of an image that is already stored, or the later download fails. A viewpoint you create can carry a camera and components, but no new image. Send the camera as `perspective_camera`, `orthogonal_camera` or `camera_data`, and the components as `components` or `components_data`.

## Statuses come from `/extensions`, per project

Read the allowed values from `GET …/extensions` for each project. Do not hard-code them, and do not infer them from a project's inspection history. The response is the project's stored extensions row if it has one, and stored values can differ from the defaults below. Creating inspection topics creates the row if it is missing. The defaults are the same with or without a row:

| List | Defaults |
|:-----|:---------|
| `topic_statuses` | `Open`, `In Progress`, `Resolved`, `Closed` |
| `priorities` | `Critical`, `Major`, `Normal`, `Minor` |

A topic can also hold a status that is not on its project's list, because statuses are free text. A topic created without a status is `Open` even on a project whose list does not contain `Open`.

## Inspections as topics

In WhatsBuilt a BCF topic is a finding (*havainto*). Every inspection is also published as topics, created before the inspection starts: one topic of type `Inspection` per element inspection, and one of type `InspectionStep` per step. `server_assigned_id` carries the order: `INSP-00042` for the inspection, `INSP-00042-01` for its first step.

| What happens on the step | `InspectionStep` status |
|:-------------------------|:------------------------|
| Not recorded yet, or reopened | `Open` |
| Fails (*Hylätty*) | `Open` |
| Passes (*Hyväksytty*) with no failure before it | `Closed` |
| Passes after a failure | `Resolved` |
| N/A (*Ei koske*) with no failure before it | `Closed` |
| N/A after a failure | unchanged |

The `Inspection` topic becomes `Closed` once at least one result is recorded and no required or failed step is unfinished. An optional step with no result can stay `Open` under a `Closed` parent. A `Closed` parent returns to `Open` when this stops being true, for example when a required step reopens. A step without a topic counts by its result. A required step's open topic keeps the parent `Open` after a waiver.

Treat these two topic types as read-only. The next recorded result overwrites the status and description of a step topic, except when waiving a failure or completing a checklist while a failed check remains waived. Those leave the topic unchanged and add no automatic comment.

## Limits

- Protected requests, BCF included, share one gateway route with a target of 50 requests per second and a burst of 100. All callers and all other signed-in traffic on that route count towards it.
- Each discovery route has its own target of 10 requests per second and a burst of 20.
- These are targets, not guarantees. A throttled request can get `429`.

## See also

- [Sign-in for BCF clients](/en/integrations/authentication/)
- [Data model](/en/integrations/data-model/)
