Create API access

Updated: from version 1.11

An external system (for example MES, ERP or an analysis tool) reads PlantBeat data through the API. For this, each external system gets its own access with its own key. The API is read-only: nothing in PlantBeat or in the PLC can be changed through it.

An administrator creates the access entries.

Requirement: HTTPS

The API only responds over HTTPS.

  • PlantBeat Box: Under Settings › Access & security › Secure connection (HTTPS), encrypted access is set up. For details, see Secure connection (HTTPS).
  • Windows: PlantBeat opens its own HTTPS port for the API (5211 by default) as soon as there is an active access. This only takes effect after PlantBeat restarts. The card then shows "The access takes effect only after PlantBeat restarts: HTTPS on port 5211 opens then." Allow the port in the Windows firewall for the computers that query the API.

Create an access

  1. Open Settings, area Data, card API access.
  2. Under Name of the external system, enter a unique name, for example MES. The name must not contain a colon. Revoked access entries also keep their name reserved.
  3. If needed, choose an Expiry date. Without a date, the access does not expire.
  4. Only on a master in the PlantBeat Federation: under Lines (no selection = all), choose the lines the external system may see. Without a selection, the access applies to all lines, including lines paired later.
  5. Click Create access.
  6. PlantBeat shows the key: "Copy the key now. It is shown only this once." Copy it and hand it over securely to the people who look after the external system.

Warning

Treat the key like a password. If it is lost, it cannot be shown again. In that case, revoke the access and create a new one with a different name.

What the external system needs

The card API access shows the address of the API. On the box, this is for example https://plantbeat.local/odata/v1/, on Windows https://<computer name>:5211/odata/v1/.

The external system authenticates in one of two ways:

  • with the key as a bearer token (Authorization: Bearer <key>), or
  • with user and password: user = name of the access, password = key. Spreadsheet programs and analysis tools with an OData feed use this way.

Many tools only open the address if the querying computer trusts the PlantBeat certificate. There are two ways to achieve this:

  • Under Settings › Access & security, upload your own certificate that the computers in your plant already trust, or
  • on the card API access, use Download certificate to get the PlantBeat certificate and add it on the querying computer under "Trusted Root Certification Authorities".

With OpenAPI description (openapi.json), you download the technical description of the interface. It contains no key. Hand it over to the developers of the external system.

Change or revoke an access

  • With Edit, you change the expiry date and the line selection. Name and key stay the same, so the external system does not need to change anything. This is also how you extend an expired access.
  • With Revoke access, you block the access immediately. A revoked access can no longer be edited.
  • Under Recent access, you see for each access when the external system queried what. Every access is logged.

Tip

Create a separate access for each external system. Then you can revoke a single one without affecting the others.

API access entries are part of the configuration and are included in the data backup. If you restore an older backup, access entries revoked since then apply again.

Next steps