# Create and link QR labels

> An integration creates QR labels, links them to elements, takes them out of use and deletes them, and follows the labels in a window.

An integration, such as a precast factory's production system, can create the QR labels it prints, link a label to its element, take a label out of use and delete it, as a project administrator does in the app. Each label holds a GS1 Digital Link with its GIAI; see [QR codes and scan URLs](/en/integrations/qr-codes/).

## What you need

- The permission `elements:write` to create, link and take labels out of use, and `elements:delete` to delete them. Either gives the integration the administrator role on its projects, because taking a label out of use and deleting it are administrator actions in the app. The administrator role comes only in projects of the integration's own organisation. In another organisation's project, such as a contractor's, its role is viewer or inspector as that project's administrator chose: there taking labels out of use and deleting them answer `403 INSUFFICIENT_PROJECT_ROLE`, and linking a label needs the inspector role and the project's setting that lets inspectors link labels; see [Integrations in another organisation's project](/en/integrations/other-organisations-projects/). An organisation administrator chooses the permissions; see [Create an integration](/en/integrations/create-an-integration/).
- An [access token](/en/integrations/get-an-access-token/) whose scopes include them. Reading the labels needs only `elements:read`.

## Create labels

Labels for elements, one each:

```sh
curl -X POST "https://api.whatsbuilt.fi/v1/projects/$PROJECT/labels" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: casting-2026-11-19" \
  -d '{"element_global_ids":["2qL7xVb0P1hO3kQm9aZ002","2qL7xVb0P1hO3kQm9aZ003"]}'
```

Or blank labels, linked to elements later: `{"count": 50}`. Send `count` or `element_global_ids`, not both; at most 500 a call.

An element that already has a label, or is not in the current model, gets none; `skipped` counts them. The answer is `201` with the new labels:

```json
{ "labels": [{ "id": "6f1c…", "giai": "6430001WB000000012842", "code": "Hq4ZtR", "digital_link": "https://qr.whatsbuilt.fi/8004/6430001WB000000012842",
  "element_global_id": "2qL7xVb0P1hO3kQm9aZ002", "status": "assigned", "…": "…" }], "skipped": 0 }
```

A repeat with the same `Idempotency-Key` and body returns the labels of the first call with `200` and creates nothing. The organisation's hourly label limits apply: a call over them answers `429` with `Retry-After`.

## Link a label to an element

```sh
curl -X POST "https://api.whatsbuilt.fi/v1/projects/$PROJECT/labels/$LABEL/assign" \
  -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
  -d '{"element_global_id":"2qL7xVb0P1hO3kQm9aZ004"}'
```

This links a blank label, or one whose element was removed from the project. An element carries one label: a second answers `409 ASSET_ALREADY_LABELLED`. A label that is on another element answers `409 CONFLICT`, unless the body has `"move": true`: then the label moves to the new element, as it does in the app. Move a label only when the sticker itself is moved; otherwise take it out of use and create a new one. A label out of use cannot be moved.

## Take a label out of use

`POST /v1/projects/{projectId}/labels/{labelId}/retire` unlinks the label from its element, and a scan of it says that the label is out of use. It cannot be linked again (`409 LABEL_RETIRED`); create a new label for the element.

## Delete a label

`DELETE /v1/projects/{projectId}/labels/{labelId}` deletes the label, and a scan of it finds nothing. Take a label out of use instead when it may already be on site: its history stays.

## Follow the labels

`GET /v1/labels` lists labels in a window like the other lists; see [Collect changes in a window](/en/integrations/collect-changes/). `element_global_id` is the element the label is on; `status` is `unassigned`, `assigned`, `active` (scanned at least once) or `retired`. The first scan of a label is a change; later scans are not. A deleted label comes as a deletion. `status=retired` narrows the list to labels out of use.

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