Record element events
An integration can record the same events on an element as a person on site does in the app:
kind |
In the app |
|---|---|
delivered |
Delivered |
received_on_site |
Received on site |
installed |
Installed |
The app shows an integration’s record as Integration · {name}, for example Integration · Production control.
What you need
Section titled “What you need”- The permission Records element deliveries and installations (
element-events:write). It gives the integration the inspector role on its projects, because recording needs that role for a person too. An administrator adds it on Integrations; see Create an integration. - The project’s organisation uses the Takt board, as for a person’s records. Otherwise the call answers
403 FEATURE_OFF. - An access token whose scopes include
element-events:write.
Record an event
Section titled “Record an event”curl -X POST "https://api.whatsbuilt.fi/v1/projects/$PROJECT/element-events" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: load-0417-delivered" \ -d '{"kind":"delivered","global_ids":["2qL7xVb0P1hO3kQm9aZ001","2qL7xVb0P1hO3kQm9aZ002"],"load_ref":"LOAD-0417"}'| Field | What it is |
|---|---|
kind |
delivered, received_on_site or installed |
global_ids |
1–100 IFC GlobalIds of elements in the project, recorded together |
occurred_at |
When it happened, RFC 3339 with an offset. Without it the server’s time is used. It may be at most 14 days back and 5 minutes ahead; otherwise the answer is 400 EVENT_TIME_OUT_OF_RANGE |
load_ref |
The load or delivery reference, 1–64 characters. For delivered and received_on_site only |
The answer is 200:
{ "kind": "delivered", "recorded": [{ "id": "…", "global_id": "2qL7xVb0P1hO3kQm9aZ001", "kind": "delivered", "load_ref": "LOAD-0417", "created_via": "integration", "…": "…" }], "refused": [{ "global_id": "2qL7xVb0P1hO3kQm9aZ002", "code": "ALREADY_RECORDED", "event": { "…": "…" } }]}An element holds at most one standing event of each kind. An element that cannot be recorded comes back in refused with a reason, and the others are recorded:
code |
Reason |
|---|---|
ALREADY_RECORDED |
The element already has an event of this kind. event is that event |
ELEMENT_NOT_FOUND |
No model of the project has this GlobalId |
ELEMENT_REMOVED |
The element has been removed from the model |
Retry safely
Section titled “Retry safely”Send an Idempotency-Key header with every record: 1–255 visible ASCII characters that identify the record in your system, such as the load and the kind. When a connection drops and you do not know whether the call arrived, send the same call with the same key. The repeat returns the events the first call recorded and records nothing again.
Keys are per integration and project, and do not expire. A key stands for the body of the call that used it: kind, the set of global_ids in any order, load_ref and the moment of occurred_at. The same key with another body answers 422 IDEMPOTENCY_KEY_REUSED. A call that recorded no event leaves its key free, so its repeat runs as a new call.
Undo a record
Section titled “Undo a record”curl -X DELETE "https://api.whatsbuilt.fi/v1/projects/$PROJECT/element-events/$EVENT?reason=Wrong%20load" \ -H "Authorization: Bearer $TOKEN"The undone event stays in the history marked Undone, as when a person undoes it in the app. reason is optional, up to 500 characters. An integration can undo only its own records. Undoing it again returns the undone event unchanged.
Read the records
Section titled “Read the records”Every event, including those people recorded and those undone, is in GET /v1/element-events (Reads data); see Collect changes in a window. On an integration’s record created_via is integration and via_client_id is the integration’s client_id.
The error codes are on Errors and limits and the fields in the API reference.